@telia/teddy 0.7.16 → 0.7.26

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.
Files changed (72) hide show
  1. package/dist/components/card/card.cjs +52 -52
  2. package/dist/components/card/card.js +52 -52
  3. package/dist/components/checkbox-card-group/checkbox-card-group-content.cjs +64 -0
  4. package/dist/components/checkbox-card-group/checkbox-card-group-content.d.ts +5 -0
  5. package/dist/components/checkbox-card-group/checkbox-card-group-content.js +64 -0
  6. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.cjs +1465 -0
  7. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.d.ts +12 -0
  8. package/dist/components/checkbox-card-group/checkbox-card-group-indicator.js +1446 -0
  9. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.cjs +15 -0
  10. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.d.ts +5 -0
  11. package/dist/components/checkbox-card-group/checkbox-card-group-item-body.js +15 -0
  12. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.cjs +65 -0
  13. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.d.ts +14 -0
  14. package/dist/components/checkbox-card-group/checkbox-card-group-item-title.js +65 -0
  15. package/dist/components/checkbox-card-group/checkbox-card-group-item.cjs +66 -0
  16. package/dist/components/checkbox-card-group/checkbox-card-group-item.d.ts +22 -0
  17. package/dist/components/checkbox-card-group/checkbox-card-group-item.js +66 -0
  18. package/dist/components/checkbox-card-group/checkbox-card-group-label.cjs +29 -0
  19. package/dist/components/checkbox-card-group/checkbox-card-group-label.d.ts +65 -0
  20. package/dist/components/checkbox-card-group/checkbox-card-group-label.js +29 -0
  21. package/dist/components/checkbox-card-group/checkbox-card-group-root.cjs +42 -0
  22. package/dist/components/checkbox-card-group/checkbox-card-group-root.d.ts +39 -0
  23. package/dist/components/checkbox-card-group/checkbox-card-group-root.js +42 -0
  24. package/dist/components/checkbox-card-group/index.cjs +7 -0
  25. package/dist/components/checkbox-card-group/index.d.ts +76 -0
  26. package/dist/components/checkbox-card-group/index.js +7 -0
  27. package/dist/components/index.cjs +6 -5
  28. package/dist/components/index.d.ts +1 -0
  29. package/dist/components/index.js +2 -1
  30. package/dist/components/modal/index.cjs +2 -2
  31. package/dist/components/modal/index.js +1 -1
  32. package/dist/components/modal/modal-close.cjs +2 -2
  33. package/dist/components/modal/modal-close.js +2 -2
  34. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.cjs +2 -2
  35. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.js +2 -2
  36. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.cjs +2 -2
  37. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.js +1 -1
  38. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.cjs +2 -2
  39. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.js +2 -2
  40. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.cjs +3 -3
  41. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.js +2 -2
  42. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.cjs +2 -2
  43. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.js +2 -2
  44. package/dist/components/navigation-menu/global-navigation/global-navigation-root.cjs +4 -4
  45. package/dist/components/navigation-menu/global-navigation/global-navigation-root.js +4 -4
  46. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.cjs +2 -2
  47. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.js +2 -2
  48. package/dist/components/navigation-menu/global-navigation/global-navigation-search.cjs +2 -2
  49. package/dist/components/navigation-menu/global-navigation/global-navigation-search.js +2 -2
  50. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.cjs +2 -2
  51. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.js +2 -2
  52. package/dist/components/navigation-menu/global-navigation/index.cjs +2 -2
  53. package/dist/components/navigation-menu/global-navigation/index.js +1 -1
  54. package/dist/components/navigation-menu/index.cjs +3 -3
  55. package/dist/components/navigation-menu/index.js +1 -1
  56. package/dist/components/navigation-menu/navigation-menu.cjs +4 -4
  57. package/dist/components/navigation-menu/navigation-menu.js +1 -1
  58. package/dist/components/radio-card-group/index.cjs +2 -2
  59. package/dist/components/radio-card-group/index.js +1 -1
  60. package/dist/components/radio-card-group/radio-card-group-content.cjs +2 -2
  61. package/dist/components/radio-card-group/radio-card-group-content.js +2 -2
  62. package/dist/components/radio-card-group/radio-card-group-item-title.cjs +21 -1328
  63. package/dist/components/radio-card-group/radio-card-group-item-title.js +21 -1309
  64. package/dist/components/radio-card-group/radio-card-group-item.cjs +3 -3
  65. package/dist/components/radio-card-group/radio-card-group-item.js +3 -3
  66. package/dist/main.cjs +6 -5
  67. package/dist/main.js +2 -1
  68. package/dist/style.css +425 -213
  69. package/dist/tokens/color/variables.cjs +32 -32
  70. package/dist/tokens/color/variables.d.ts +32 -32
  71. package/dist/tokens/color/variables.js +32 -32
  72. package/package.json +5 -5
@@ -1,15 +1,8 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import React__default, { useEffect } from "react";
3
- import clsx from "clsx";
4
- import { MY_PAGE_RETAILER_LINKS, MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, getLinks, getActiveSubLink, DEFAULT_PRIVATE_LINKS, DEFAULT_BUSINESS_LINKS, DEFAULT_MDU_LINKS } from "../navigation-menu/global-navigation/utils.js";
5
- import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
6
- import { useComposedRefs } from "../../utils/composeRefs.js";
7
- import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
8
- import { composeEventHandlers } from "../../utils/composeEventHandlers.js";
9
- import { Slot } from "@radix-ui/react-slot";
10
- import { useControllableState } from "@radix-ui/react-use-controllable-state";
11
- import { mergeStyles } from "../../utils/generate-styling/index.js";
12
- import { teddyMotionDuration300 } from "../../tokens/motion/variables.js";
1
+ import "react/jsx-runtime";
2
+ import "clsx";
3
+ import "react";
4
+ import "./radio-card-group-root.js";
5
+ import "@radix-ui/react-slot";
13
6
  import "../metric-meter/metric-meter.js";
14
7
  import "../footer/index.js";
15
8
  import "../pagination/index.js";
@@ -23,1332 +16,51 @@ import "../collapsible/index.js";
23
16
  import "../meter-bar/index.js";
24
17
  import "../skeleton/index.js";
25
18
  import "../checkbox/index.js";
19
+ import { c } from "../checkbox-card-group/checkbox-card-group-indicator.js";
26
20
  import "../toast/toast-root.js";
27
21
  import "sonner";
28
22
  import "../toggletip/index.js";
29
23
  import "../breadcrumbs/index.js";
30
- import { s as styles$2, rootClassName as rootClassName$2, Root as Root$2 } from "./radio-card-group-root.js";
31
- import { GroupLabel } from "./radio-card-group-label.js";
32
24
  import "../ribbon/index.js";
33
25
  import "../expandable-card/index.js";
34
26
  import "../color-dot/color-dot-root.js";
35
27
  import "../progress-bar/progress-bar.js";
36
28
  import "../notabene/index.js";
37
29
  import "../tooltip/index.js";
38
- import { List as List$1 } from "../list/index.js";
30
+ import "../list/index.js";
39
31
  import "../scroll-area/index.js";
40
- import { Tabs } from "../tabs/index.js";
41
- import { Drawer } from "../drawer/index.js";
32
+ import "../tabs/index.js";
33
+ import "../drawer/index.js";
42
34
  import "../image/image.js";
43
35
  import "../chip/index.js";
44
36
  import "../../assets/sprite.6511e521-teddy.svg";
45
- import { rootClassName as rootClassName$3, RootContext as RootContext$1, Root as Root$3 } from "../modal/modal-root.js";
46
- import { Trigger as Trigger$1 } from "../modal/modal-trigger.js";
47
- import { Content as Content$2 } from "../modal/modal-content.js";
48
- import { Title as Title$1 } from "../modal/modal-title.js";
49
- import { Description } from "../modal/modal-description.js";
50
- import { Overlay } from "../modal/modal-overlay.js";
51
- import { Group } from "../modal/modal-group.js";
52
- import * as DrawerPrimitive from "@radix-ui/react-dialog";
53
- import { Icon } from "../icon/icon.js";
54
37
  import "../notification/index.js";
55
38
  import "../radio-group/index.js";
56
- import { Box } from "../box/box.js";
57
- import { Flex } from "../flex/flex.js";
39
+ import "../box/box.js";
40
+ import "../flex/flex.js";
58
41
  import "../card/index.js";
59
- import { Grid } from "../grid/grid.js";
42
+ import "../grid/grid.js";
60
43
  import "../toggle/toggle.js";
61
44
  import "../accordion/index.js";
62
45
  import "../link/link.js";
63
46
  import "../badge/badge.js";
64
47
  import "../badge/alert-badge.js";
65
- import { CounterBadge } from "../badge/counter-badge.js";
66
- import { Button } from "../button/button.js";
48
+ import "../badge/counter-badge.js";
49
+ import "../button/button.js";
67
50
  import "../field-error-text/field-error-text.js";
68
51
  import "../helper-text/helper-text.js";
69
52
  import "../input/index.js";
70
53
  import "../label/label.js";
71
54
  import "../spinner/spinner.js";
72
- import { Text } from "../text/text.js";
73
- import { TextField } from "../text-field/index.js";
74
- import { Heading } from "../heading/heading.js";
75
- import { TextSpacing } from "../text-spacing/text-spacing.js";
55
+ import "../text/text.js";
56
+ import "../text-field/index.js";
57
+ import "../heading/heading.js";
58
+ import "../visually-hidden/visually-hidden.js";
59
+ import "../text-spacing/text-spacing.js";
76
60
  import "../container/container.js";
77
61
  import "../carousel/carousel-root.js";
78
62
  import "../slider/slider.js";
79
- import { s as styles$3 } from "../../modal.module-DuP4in7f.js";
80
- import { Image } from "../modal/modal-image.js";
81
- import { Indicator as Indicator$1 } from "./radio-card-group-indicator.js";
82
- import { Body } from "./radio-card-group-item-body.js";
83
- import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
84
- import { useSize } from "../../utils/useSize.js";
85
- const Title = React__default.forwardRef(
86
- ({ className, children, asChild, ...props }, forwardRef) => {
87
- const classes = clsx([styles$2[`${rootClassName$2}__title`]], className);
88
- return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: "150", className: styles$2[`${rootClassName$2}__title-wrapper`], children: [
89
- asChild ? /* @__PURE__ */ jsx(Slot, { ...props, ref: forwardRef, className: classes, children }) : /* @__PURE__ */ jsx(Text, { variant: "paragraph-100-bold", ref: forwardRef, className: classes, children }),
90
- /* @__PURE__ */ jsx(Indicator$1, {})
91
- ] });
92
- }
93
- );
94
- Title.displayName = "Title";
95
- const Content$1 = React__default.forwardRef(
96
- ({ className, children, ...props }, forwardRef) => {
97
- const classes = clsx([styles$2[`${rootClassName$2}__content-wrapper`]], className);
98
- return /* @__PURE__ */ jsx(Flex, { direction: "column", width: "100%", gap: "50", ...props, ref: forwardRef, className: classes, children });
99
- }
100
- );
101
- Content$1.displayName = "Content";
102
- const ItemContext = React__default.createContext(void 0);
103
- const Item$1 = React__default.forwardRef(
104
- ({ className, children, value, ...props }, forwardedRef) => {
105
- const classes = clsx([styles$2[`${rootClassName$2}__card-item`]], className);
106
- const context = React__default.useContext(ItemContext);
107
- const ref = useComposedRefs(forwardedRef, context == null ? void 0 : context.triggerRef);
108
- const id = props.id || (context == null ? void 0 : context.id);
109
- return /* @__PURE__ */ jsxs(RadioGroupPrimitive.Item, { value, id, ...props, asChild: false, ref, className: classes, children: [
110
- props.imageUrl ? /* @__PURE__ */ jsx(Flex, { className: clsx([styles$2[`${rootClassName$2}__illustration`]], className), justify: "center", align: "center", children: /* @__PURE__ */ jsx("img", { src: props.imageUrl, alt: value }) }) : null,
111
- /* @__PURE__ */ jsx(Content$1, { children })
112
- ] });
113
- }
114
- );
115
- Item$1.displayName = "Item";
116
- Root$2.displayName = "RadioCardGroup";
117
- GroupLabel.displayName = "RadioCardGroup.GroupLabel";
118
- Item$1.displayName = "RadioCardGroup.Item";
119
- Title.displayName = "RadioCardGroup.Title";
120
- Body.displayName = "RadioCardGroup.Body";
121
- const RadioCardGroup = Object.assign(Root$2, {
122
- GroupLabel,
123
- Item: Item$1,
124
- Title,
125
- Body
126
- });
127
- const Close = React__default.forwardRef(
128
- ({ className, ...props }, forwardedRef) => {
129
- const classes = clsx([styles$3[`${rootClassName$3}__close`]], {
130
- [styles$3[`${rootClassName$3}__close--floating`]]: props.slot === "floating",
131
- className
132
- });
133
- const imageRef = React__default.useContext(RootContext$1).imageRef;
134
- const [hasImage, setHasImage] = React__default.useState(false);
135
- useEffect(() => {
136
- if (imageRef == null ? void 0 : imageRef.current) {
137
- setHasImage(true);
138
- }
139
- }, [imageRef]);
140
- return /* @__PURE__ */ jsx(DrawerPrimitive.Close, { ...props, className: classes, ref: forwardedRef, asChild: true, children: props.children || /* @__PURE__ */ jsx(
141
- Button,
142
- {
143
- variant: hasImage ? "primary-negative" : "tertiary-purple",
144
- iconOnly: true,
145
- "aria-label": props["aria-label"] ?? "Lukk",
146
- children: /* @__PURE__ */ jsx(Icon, { name: "close" })
147
- }
148
- ) });
149
- }
150
- );
151
- Close.displayName = "Close";
152
- const Modal = Root$3;
153
- Modal.displayName = "Modal";
154
- Modal.Trigger = Trigger$1;
155
- Modal.Trigger.displayName = "Modal.Trigger";
156
- Modal.Content = Content$2;
157
- Modal.Content.displayName = "Modal.Content";
158
- Modal.Title = Title$1;
159
- Modal.Title.displayName = "Modal.Title";
160
- Modal.Description = Description;
161
- Modal.Description.displayName = "Modal.Description";
162
- Modal.Overlay = Overlay;
163
- Modal.Overlay.displayName = "Modal.Overlay";
164
- Modal.Group = Group;
165
- Modal.Group.displayName = "Modal.Group";
166
- Modal.Close = Close;
167
- Modal.Close.displayName = "Modal.Close";
168
- Modal.Image = Image;
169
- Modal.Image.displayName = "Modal.Image";
170
- const styles$1 = {
171
- "teddy-navigation-menu": "_teddy-navigation-menu_6p30v_1",
172
- "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_6p30v_34",
173
- "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_6p30v_37",
174
- "teddy-navigation-menu__list": "_teddy-navigation-menu__list_6p30v_40",
175
- "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_6p30v_66",
176
- "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_6p30v_87",
177
- "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_6p30v_106",
178
- "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_6p30v_112",
179
- "teddy-navigation-menu__content": "_teddy-navigation-menu__content_6p30v_187",
180
- "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_6p30v_219",
181
- "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_6p30v_239",
182
- "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_6p30v_245",
183
- "teddy-navigation-menu__link": "_teddy-navigation-menu__link_6p30v_313",
184
- "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_6p30v_333",
185
- "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_6p30v_339"
186
- };
187
- const rootClassName$1 = "teddy-navigation-menu";
188
- const NavigationMenuContext = React__default.createContext({
189
- selectedTopMenu: void 0,
190
- setSelectedTopMenu: () => {
191
- },
192
- contentRef: { current: null },
193
- focusProxyRef: { current: null },
194
- topMenuRef: { current: null },
195
- id: "",
196
- dir: "ltr",
197
- orientation: "horizontal",
198
- onEntryKeyDown: () => {
199
- },
200
- onFocusProxyEnter: () => {
201
- },
202
- onContentFocusOutside: () => {
203
- }
204
- });
205
- const Root$1 = React__default.forwardRef(
206
- ({ className, defaultTopMenuValue, topMenuValue, onTopMenuValueChange, ...props }, forwardRef) => {
207
- const [selectedTopMenu, setSelectedTopMenu] = useControllableState({
208
- defaultProp: defaultTopMenuValue,
209
- prop: topMenuValue,
210
- onChange: onTopMenuValueChange
211
- });
212
- const contentRef = React__default.useRef(null);
213
- const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
214
- const timerRef = React__default.useRef(void 0);
215
- const restoreContentTabOrderRef = React__default.useRef(() => {
216
- });
217
- const focusProxyRef = React__default.useRef(null);
218
- const topMenuRef = React__default.useRef(null);
219
- const id = React__default.useId();
220
- const handleContentEntry = React__default.useCallback((side = "start") => {
221
- if (contentRef.current) {
222
- restoreContentTabOrderRef.current();
223
- const candidates = getTabbableCandidates(contentRef.current);
224
- if (candidates.length) focusFirst(side === "start" ? candidates : candidates.reverse());
225
- }
226
- }, []);
227
- const handleContentExit = React__default.useCallback(() => {
228
- if (contentRef.current) {
229
- const candidates = getTabbableCandidates(contentRef.current);
230
- if (candidates.length) restoreContentTabOrderRef.current = removeFromTabOrder(candidates);
231
- }
232
- }, []);
233
- React__default.useEffect(() => {
234
- timerRef.current = setTimeout(() => {
235
- setAllowAnimationOfHeight(true);
236
- }, 500);
237
- return () => {
238
- timerRef.current && clearTimeout(timerRef.current);
239
- };
240
- }, []);
241
- const classes = clsx([styles$1[`${rootClassName$1}`]], className);
242
- return /* @__PURE__ */ jsx(
243
- NavigationMenuContext.Provider,
244
- {
245
- value: {
246
- contentRef,
247
- focusProxyRef,
248
- topMenuRef,
249
- id,
250
- dir: props.dir || "ltr",
251
- orientation: props.orientation || "horizontal",
252
- onEntryKeyDown: handleContentEntry,
253
- onFocusProxyEnter: handleContentEntry,
254
- onContentFocusOutside: handleContentExit,
255
- selectedTopMenu,
256
- setSelectedTopMenu
257
- },
258
- children: /* @__PURE__ */ jsx(
259
- NavigationMenuPrimitive.Root,
260
- {
261
- ...props,
262
- style: allowAnimationOfHeight ? mergeStyles(props.style, { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 }) : props.style,
263
- ref: forwardRef,
264
- className: classes
265
- }
266
- )
267
- }
268
- );
269
- }
270
- );
271
- Root$1.displayName = "NavigationMenu";
272
- const TopMenuList = React__default.forwardRef(
273
- ({ className, ...props }, forwardRef) => {
274
- const classes = clsx([styles$1[`${rootClassName$1}__top-menu-list`]], className);
275
- const context = React__default.useContext(NavigationMenuContext);
276
- const ref = useComposedRefs(context.topMenuRef, forwardRef);
277
- return /* @__PURE__ */ jsx("ul", { ...props, ref, className: classes });
278
- }
279
- );
280
- TopMenuList.displayName = "NavigationMenu.TopMenuList";
281
- const TopMenuItem = React__default.forwardRef(
282
- ({ className, ...props }, forwardRef) => {
283
- const classes = clsx([styles$1[`${rootClassName$1}__top-menu-item`]], className);
284
- return /* @__PURE__ */ jsx("li", { ...props, ref: forwardRef, className: classes });
285
- }
286
- );
287
- const TopMenuTrigger = React__default.forwardRef(
288
- ({ className, asChild, active, ...props }, forwardRef) => {
289
- const classes = clsx(
290
- [styles$1[`${rootClassName$1}__top-menu-trigger`], styles$1[`${rootClassName$1}__top-menu-trigger--small`]],
291
- className
292
- );
293
- const Comp = asChild ? Slot : "button";
294
- const context = React__default.useContext(NavigationMenuContext);
295
- const innerRef = React__default.useRef(null);
296
- const ref = useComposedRefs(innerRef, forwardRef);
297
- const isOpen = context.selectedTopMenu === props.value;
298
- return /* @__PURE__ */ jsxs(Fragment, { children: [
299
- /* @__PURE__ */ jsx(
300
- Comp,
301
- {
302
- ...props,
303
- ref,
304
- className: classes,
305
- "data-state": isOpen ? "open" : "closed",
306
- "data-active": active ? "true" : void 0,
307
- "aria-expanded": isOpen,
308
- "aria-controls": makeContentId({ value: props.value, baseId: context.id }),
309
- ...{ [ITEM_DATA_ATTR]: "" },
310
- onClick: composeEventHandlers(props.onClick, () => {
311
- context.setSelectedTopMenu(props.value);
312
- }),
313
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
314
- var _a;
315
- const verticalEntryKey = context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
316
- const entryKey = { horizontal: "ArrowDown", vertical: verticalEntryKey }[context.orientation];
317
- if (isOpen && event.key === entryKey) {
318
- context.onEntryKeyDown();
319
- return event.preventDefault();
320
- }
321
- const isFocusNavigationKey = ["Home", "End", ...ARROW_KEYS].includes(event.key);
322
- if (isFocusNavigationKey) {
323
- const triggers = (_a = context.topMenuRef.current) == null ? void 0 : _a.querySelectorAll(`[${ITEM_DATA_ATTR}]`);
324
- if (!triggers) return;
325
- let candidateNodes = Array.from(triggers == null ? void 0 : triggers.values());
326
- const prevItemKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
327
- const prevKeys = [prevItemKey, "ArrowUp", "End"];
328
- if (prevKeys.includes(event.key)) candidateNodes.reverse();
329
- if (ARROW_KEYS.includes(event.key)) {
330
- const currentIndex = candidateNodes.indexOf(event.currentTarget);
331
- candidateNodes = candidateNodes.slice(currentIndex + 1);
332
- focusFirst(candidateNodes);
333
- event.preventDefault();
334
- }
335
- }
336
- })
337
- }
338
- ),
339
- isOpen && /* @__PURE__ */ jsx(
340
- VisuallyHidden,
341
- {
342
- tabIndex: 0,
343
- ref: context.focusProxyRef,
344
- onFocus: (event) => {
345
- const content = context.contentRef.current;
346
- const prevFocusedElement = event.relatedTarget;
347
- const wasTriggerFocused = prevFocusedElement === innerRef.current;
348
- const wasFocusFromContent = content == null ? void 0 : content.contains(prevFocusedElement);
349
- if (wasTriggerFocused || !wasFocusFromContent) {
350
- context.onFocusProxyEnter(wasTriggerFocused ? "start" : "end");
351
- }
352
- }
353
- }
354
- )
355
- ] });
356
- }
357
- );
358
- const List = React__default.forwardRef(
359
- ({ className, variant, value, ...props }, forwardRef) => {
360
- const classes = clsx([styles$1[`${rootClassName$1}__list`]], [styles$1[`${rootClassName$1}__list--${variant}`]], className);
361
- const context = React__default.useContext(NavigationMenuContext);
362
- const refOnOpen = useComposedRefs(context.contentRef, forwardRef);
363
- const hasTopMenu = context.selectedTopMenu !== void 0;
364
- const isOpen = context.selectedTopMenu === value;
365
- if (!isOpen) return null;
366
- return /* @__PURE__ */ jsx(
367
- NavigationMenuPrimitive.List,
368
- {
369
- ref: hasTopMenu ? refOnOpen : forwardRef,
370
- id: value && makeContentId({ value, baseId: context.id }),
371
- ...props,
372
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
373
- var _a;
374
- if (!value) return;
375
- const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
376
- const isTabKey = event.key === "Tab" && !isMetaKey;
377
- if (isTabKey) {
378
- const candidates = getTabbableCandidates(event.currentTarget);
379
- const focusedElement = document.activeElement;
380
- const index = candidates.findIndex((candidate) => candidate === focusedElement);
381
- const isMovingBackwards = event.shiftKey;
382
- const nextCandidates = isMovingBackwards ? candidates.slice(0, index).reverse() : candidates.slice(index + 1, candidates.length);
383
- if (focusFirst(nextCandidates)) {
384
- event.preventDefault();
385
- } else {
386
- (_a = context.focusProxyRef.current) == null ? void 0 : _a.focus();
387
- context.onContentFocusOutside();
388
- }
389
- }
390
- }),
391
- className: classes
392
- }
393
- );
394
- }
395
- );
396
- List.displayName = "NavigationMenu.List";
397
- const Separator = React__default.forwardRef(({ className, ...props }, forwardRef) => {
398
- const classes = clsx(
399
- [styles$1[`${rootClassName$1}__separator`]],
400
- className
401
- );
402
- return /* @__PURE__ */ jsx(Box, { width: "100%", p: "0", m: "0", ...props, ref: forwardRef, className: classes, asChild: true, children: /* @__PURE__ */ jsx("hr", {}) });
403
- });
404
- Separator.displayName = "NavigationMenu.Separator";
405
- const Item = React__default.forwardRef(
406
- ({ className, ...props }, forwardRef) => {
407
- const classes = clsx([styles$1[`${rootClassName$1}__item`]], className);
408
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Item, { ...props, ref: forwardRef, className: classes });
409
- }
410
- );
411
- Item.displayName = "NavigationMenu.Item";
412
- const Trigger = React__default.forwardRef(
413
- ({ className, active, variant = "default", ...props }, forwardRef) => {
414
- const classes = clsx(
415
- [styles$1[`${rootClassName$1}__trigger`]],
416
- [styles$1[`${rootClassName$1}__trigger--${variant}`]],
417
- className
418
- );
419
- const innerRef = React__default.useRef(null);
420
- const ref = useComposedRefs(forwardRef, innerRef);
421
- return /* @__PURE__ */ jsx(
422
- NavigationMenuPrimitive.Trigger,
423
- {
424
- ...props,
425
- ref,
426
- "data-active": active ? "true" : void 0,
427
- className: classes,
428
- "data-text": getLabelFromChildren(props.children)
429
- }
430
- );
431
- }
432
- );
433
- Trigger.displayName = "NavigationMenu.Trigger";
434
- const Content = React__default.forwardRef(
435
- ({ className, variant = "default", ...props }, forwardRef) => {
436
- const classes = clsx(
437
- [styles$1[`${rootClassName$1}__content`]],
438
- [styles$1[`${rootClassName$1}__content--${variant}`]],
439
- className
440
- );
441
- return /* @__PURE__ */ jsx(
442
- NavigationMenuPrimitive.Content,
443
- {
444
- ...props,
445
- ref: forwardRef,
446
- className: classes
447
- }
448
- );
449
- }
450
- );
451
- const Link = React__default.forwardRef(
452
- ({ className, variant = "default", ...props }, forwardRef) => {
453
- const classes = clsx([styles$1[`${rootClassName$1}__link`]], [styles$1[`${rootClassName$1}__link--${variant}`]], className);
454
- return /* @__PURE__ */ jsx(
455
- NavigationMenuPrimitive.Link,
456
- {
457
- ...props,
458
- ref: forwardRef,
459
- className: classes,
460
- "data-text": getLabelFromChildren(props.children)
461
- }
462
- );
463
- }
464
- );
465
- Link.displayName = "NavigationMenu.Link";
466
- const Indicator = React__default.forwardRef(
467
- ({ className, ...props }, forwardRef) => {
468
- const classes = clsx([styles$1[`${rootClassName$1}__indicator`]], className);
469
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Indicator, { ...props, ref: forwardRef, className: classes });
470
- }
471
- );
472
- Indicator.displayName = "NavigationMenu.Indicator";
473
- const Viewport = React__default.forwardRef(
474
- ({ className, ...props }, forwardRef) => {
475
- const classes = clsx([styles$1[`${rootClassName$1}__viewport`]], className);
476
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Viewport, { ...props, ref: forwardRef, className: classes });
477
- }
478
- );
479
- Viewport.displayName = "NavigationMenu.Viewport";
480
- const Sub = React__default.forwardRef(
481
- ({ className, ...props }, forwardRef) => {
482
- const classes = clsx([styles$1[`${rootClassName$1}__sub`]], className);
483
- return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Sub, { ...props, ref: forwardRef, className: classes });
484
- }
485
- );
486
- Sub.displayName = "NavigationMenu.Sub";
487
- function getLabelFromChildren(children) {
488
- function findLabel(node) {
489
- if (typeof node === "string") {
490
- return node;
491
- }
492
- if (React__default.isValidElement(node) && node.props.children) {
493
- return findLabel(node.props.children);
494
- }
495
- if (Array.isArray(node)) {
496
- for (let i = node.length - 1; i >= 0; i--) {
497
- const label = findLabel(node[i]);
498
- if (label) {
499
- return label;
500
- }
501
- }
502
- }
503
- return void 0;
504
- }
505
- return findLabel(children);
506
- }
507
- function getTabbableCandidates(container) {
508
- const nodes = [];
509
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
510
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
511
- acceptNode: (node) => {
512
- const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
513
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
514
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
515
- }
516
- });
517
- while (walker.nextNode()) nodes.push(walker.currentNode);
518
- return nodes;
519
- }
520
- function focusFirst(candidates) {
521
- const previouslyFocusedElement = document.activeElement;
522
- return candidates.some((candidate) => {
523
- if (candidate === previouslyFocusedElement) return true;
524
- candidate.focus();
525
- return document.activeElement !== previouslyFocusedElement;
526
- });
527
- }
528
- function removeFromTabOrder(candidates) {
529
- candidates.forEach((candidate) => {
530
- candidate.dataset.tabindex = candidate.getAttribute("tabindex") || "";
531
- candidate.setAttribute("tabindex", "-1");
532
- });
533
- return () => {
534
- candidates.forEach((candidate) => {
535
- const prevTabIndex = candidate.dataset.tabindex;
536
- candidate.setAttribute("tabindex", prevTabIndex);
537
- });
538
- };
539
- }
540
- const ITEM_DATA_ATTR = "data-teddy-top-selector-trigger";
541
- const ARROW_KEYS = ["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"];
542
- function makeContentId(args) {
543
- return `teddy-navigation-menu-${args.baseId}-${args.value}-content`;
544
- }
545
- const NavigationMenu = Object.assign(Root$1, {
546
- List,
547
- Separator,
548
- Item,
549
- Trigger,
550
- Content,
551
- Link,
552
- Indicator,
553
- Viewport,
554
- Sub,
555
- TopMenuList,
556
- TopMenuItem,
557
- TopMenuTrigger
558
- });
559
- const styles = {
560
- "teddy-global-navigation": "_teddy-global-navigation_1eacg_1",
561
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1eacg_6",
562
- "teddy-global-navigation__top-icon-wrapper": "_teddy-global-navigation__top-icon-wrapper_1eacg_26",
563
- "teddy-global-navigation__top-menu-icons": "_teddy-global-navigation__top-menu-icons_1eacg_31",
564
- "teddy-global-navigation__link": "_teddy-global-navigation__link_1eacg_35",
565
- "teddy-global-navigation__header": "_teddy-global-navigation__header_1eacg_48",
566
- "teddy-global-navigation__colored-box": "_teddy-global-navigation__colored-box_1eacg_51",
567
- "teddy-global-navigation__colored-box--mobile": "_teddy-global-navigation__colored-box--mobile_1eacg_55",
568
- "teddy-global-navigation__sublink-button--mobile": "_teddy-global-navigation__sublink-button--mobile_1eacg_59",
569
- "teddy-global-navigation__list": "_teddy-global-navigation__list_1eacg_65",
570
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1eacg_70",
571
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1eacg_73",
572
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1eacg_77",
573
- "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1eacg_84",
574
- "close-viewport": "_close-viewport_1eacg_1",
575
- "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_1eacg_101",
576
- "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1eacg_104"
577
- };
578
- function MyPages(props) {
579
- var _a, _b;
580
- const rootContext = React__default.useContext(RootContext);
581
- const isLoggedIn = (((_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.name.length) || 0) > 0;
582
- return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
583
- /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: ((_b = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _b.name.length) ? /* @__PURE__ */ jsxs("button", { "data-di-mask": true, children: [
584
- /* @__PURE__ */ jsx(Icon, { name: "end-user", size: "sm" }),
585
- rootContext.loggedInUser.name
586
- ] }) : /* @__PURE__ */ jsxs("button", { children: [
587
- /* @__PURE__ */ jsx(Icon, { name: "login", size: "sm" }),
588
- "Logg inn"
589
- ] }) }) }),
590
- /* @__PURE__ */ jsxs(Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
591
- /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
592
- isLoggedIn ? /* @__PURE__ */ jsx(LoggedInContent, {}) : /* @__PURE__ */ jsx(LoggedOutContent, {}),
593
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
594
- ] })
595
- ] });
596
- }
597
- function LoggedOutContent() {
598
- return /* @__PURE__ */ jsxs(Grid, { gap: "400", children: [
599
- /* @__PURE__ */ jsx(Drawer.Title, { children: "Logg inn" }),
600
- /* @__PURE__ */ jsxs(TextSpacing, { children: [
601
- /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Privat" }),
602
- /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: MY_PAGE_LINKS.link, children: [
603
- MY_PAGE_LINKS.name,
604
- " ",
605
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
606
- ] }) })
607
- ] }),
608
- /* @__PURE__ */ jsxs(TextSpacing, { children: [
609
- /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Bedrift" }),
610
- /* @__PURE__ */ jsx(Grid, { gap: "150", children: LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: link.link, children: [
611
- link.name,
612
- " ",
613
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
614
- ] }) })) })
615
- ] })
616
- ] });
617
- }
618
- function LoggedInContent() {
619
- var _a, _b, _c;
620
- const rootContext = React__default.useContext(RootContext);
621
- const isRetailerLoggedIn = (_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.isRetailer;
622
- if (isRetailerLoggedIn) {
623
- return /* @__PURE__ */ jsxs(TextSpacing, { children: [
624
- /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
625
- (_b = MY_PAGE_RETAILER_LINKS.links) == null ? void 0 : _b.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link)),
626
- /* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
627
- ] });
628
- }
629
- return /* @__PURE__ */ jsxs(Fragment, { children: [
630
- /* @__PURE__ */ jsx(Drawer.Title, { children: "Mine sider" }),
631
- /* @__PURE__ */ jsxs(Tabs, { defaultValue: "private", children: [
632
- /* @__PURE__ */ jsxs(Tabs.List, { children: [
633
- /* @__PURE__ */ jsx(Tabs.Trigger, { value: "private", children: "Privat" }),
634
- /* @__PURE__ */ jsx(Tabs.Trigger, { value: "business", children: "Bedrift" })
635
- ] }),
636
- /* @__PURE__ */ jsxs(TextSpacing, { children: [
637
- /* @__PURE__ */ jsxs(Tabs.Content, { value: "private", children: [
638
- /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
639
- (_c = MY_PAGE_LINKS.links) == null ? void 0 : _c.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
640
- ] }),
641
- /* @__PURE__ */ jsxs(Tabs.Content, { value: "business", children: [
642
- /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Bedriftsportaler" }),
643
- LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
644
- ] }),
645
- /* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
646
- ] })
647
- ] })
648
- ] });
649
- }
650
- MyPages.displayName = "MyPages";
651
- const SearchField = React__default.forwardRef(
652
- (props, forwardRef) => {
653
- const ref = React__default.useRef(null);
654
- const context = React__default.useContext(RootContext);
655
- const composedRef = useComposedRefs(forwardRef, ref);
656
- return /* @__PURE__ */ jsx(
657
- "form",
658
- {
659
- onSubmit: (e) => {
660
- var _a, _b;
661
- if (context == null ? void 0 : context.onSearchSubmit) {
662
- context.onSearchSubmit(e, (_a = ref.current) == null ? void 0 : _a.value);
663
- }
664
- if (!window || e.isDefaultPrevented()) return;
665
- e.preventDefault();
666
- window.location.href = `/sok?q=${encodeURIComponent(((_b = ref.current) == null ? void 0 : _b.value) || "")}`;
667
- },
668
- children: /* @__PURE__ */ jsxs(TextField, { ...props, children: [
669
- /* @__PURE__ */ jsx(TextField.Label, { children: "Søk i innhold" }),
670
- /* @__PURE__ */ jsxs(TextField.InputGroup, { children: [
671
- /* @__PURE__ */ jsx(Icon, { name: "search" }),
672
- /* @__PURE__ */ jsx(
673
- TextField.Input,
674
- {
675
- ref: composedRef,
676
- value: context == null ? void 0 : context.searchValue,
677
- onChange: (e) => {
678
- var _a, _b;
679
- if (((_a = ref.current) == null ? void 0 : _a.value) && (context == null ? void 0 : context.onSearchInputChange)) {
680
- context == null ? void 0 : context.onSearchInputChange(e, (_b = ref.current) == null ? void 0 : _b.value);
681
- }
682
- },
683
- onKeyDown: (e) => {
684
- if (context == null ? void 0 : context.onSearchKeyDown) {
685
- context.onSearchKeyDown(e);
686
- }
687
- },
688
- placeholder: "Søk her"
689
- }
690
- ),
691
- /* @__PURE__ */ jsx(TextField.ClearButton, { onClick: () => {
692
- if (context == null ? void 0 : context.onClear) {
693
- context.onClear();
694
- }
695
- } })
696
- ] }),
697
- /* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
698
- ] })
699
- }
700
- );
701
- }
702
- );
703
- SearchField.displayName = "SearchField";
704
- function Search(props) {
705
- const rootContext = React__default.useContext(RootContext);
706
- const additionalSearchContent = rootContext == null ? void 0 : rootContext.additionalSearchContent;
707
- const searchFieldRef = React__default.useRef(null);
708
- return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
709
- /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
710
- /* @__PURE__ */ jsx(Icon, { name: "search", size: "sm" }),
711
- " Søk"
712
- ] }) }) }),
713
- /* @__PURE__ */ jsxs(
714
- Drawer.Content,
715
- {
716
- size: rootContext == null ? void 0 : rootContext.drawerSize,
717
- onOpenAutoFocus: (e) => {
718
- var _a;
719
- e.preventDefault();
720
- (_a = searchFieldRef.current) == null ? void 0 : _a.focus();
721
- },
722
- children: [
723
- /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
724
- /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
725
- /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
726
- additionalSearchContent ? additionalSearchContent : null,
727
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
728
- ]
729
- }
730
- )
731
- ] });
732
- }
733
- Search.displayName = "Search";
734
- const ShoppingCart = React__default.forwardRef(() => {
735
- const rootContext = React__default.useContext(RootContext);
736
- const shoppingCartContent = rootContext == null ? void 0 : rootContext.shoppingCart;
737
- const numberOfItemsInCart = (rootContext == null ? void 0 : rootContext.shoppingCartNumberOfItems) || 0;
738
- const titleSuffix = numberOfItemsInCart > 0 ? `(${numberOfItemsInCart})` : "";
739
- if (!numberOfItemsInCart) return null;
740
- return /* @__PURE__ */ jsxs(Drawer, { open: rootContext == null ? void 0 : rootContext.isCartOpen, onOpenChange: rootContext == null ? void 0 : rootContext.onCartOpenChange, children: [
741
- /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
742
- /* @__PURE__ */ jsxs("div", { className: clsx([styles[`${rootClassName}__item-wrapper`]]), children: [
743
- /* @__PURE__ */ jsx(Icon, { name: "cart", size: "sm" }),
744
- numberOfItemsInCart > 0 && /* @__PURE__ */ jsx("span", { className: clsx([styles[`${rootClassName}__item-count`]]), children: /* @__PURE__ */ jsx(CounterBadge, { variant: "attention", children: numberOfItemsInCart }) })
745
- ] }),
746
- "Handlekurv"
747
- ] }) }) }),
748
- /* @__PURE__ */ jsxs(Drawer.Content, { size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
749
- /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
750
- /* @__PURE__ */ jsxs(Drawer.Title, { children: [
751
- "Handlekurv ",
752
- titleSuffix
753
- ] }),
754
- shoppingCartContent ? shoppingCartContent : null,
755
- /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
756
- ] })
757
- ] });
758
- });
759
- ShoppingCart.displayName = "ShoppingCart";
760
- const Desktop = React__default.forwardRef(() => {
761
- const rootContext = React__default.useContext(RootContext);
762
- const [showMenu, setShowMenu] = React__default.useState(false);
763
- const [isClientSide, setIsClientSide] = React__default.useState(false);
764
- const topMenuRef = React__default.useRef(null);
765
- const topMenuSize = useSize(topMenuRef.current);
766
- React__default.useEffect(() => {
767
- setIsClientSide(true);
768
- }, []);
769
- if (!rootContext) return null;
770
- const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
771
- const shouldShowViewport = links.flatMap((link) => link.links || []).some((link) => {
772
- var _a;
773
- const sameParent = link.link.split("/")[1] === (rootContext == null ? void 0 : rootContext.pathname.split("/")[1]) || !link.link && (rootContext == null ? void 0 : rootContext.pathname) === "/";
774
- return (((_a = link.links) == null ? void 0 : _a.length) || 0) > 0 && link.name === (rootContext == null ? void 0 : rootContext.specifiedLink) && sameParent;
775
- });
776
- const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
777
- const { selectedMenuItem, setSelectedMenuItem, linkComponent: Link2, specifiedLink, setSpecifiedLink } = rootContext;
778
- const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
779
- const handleInteractions = (linkName) => {
780
- setSpecifiedLink(linkName || "");
781
- setSelectedMenuItem(linkName || "", true);
782
- };
783
- const viewPortHeight = shouldShowViewport ? "333px" : void 0;
784
- return /* @__PURE__ */ jsxs(Fragment, { children: [
785
- /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__top-menu-color`], children: /* @__PURE__ */ jsx(
786
- "div",
787
- {
788
- style: mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
789
- className: styles[`${rootClassName}__top-menu-wrapper`],
790
- children: /* @__PURE__ */ jsxs(NavigationMenu.TopMenuList, { ref: topMenuRef, children: [
791
- links.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
792
- NavigationMenu.TopMenuTrigger,
793
- {
794
- value: link.name,
795
- asChild: true,
796
- onClick: () => {
797
- rootContext.setPathname(link.link);
798
- setSpecifiedLink("");
799
- },
800
- 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 })
801
- }
802
- ) }, link.name)),
803
- /* @__PURE__ */ jsx(NavigationMenu.Item, { style: { marginLeft: "auto" } }),
804
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
805
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
806
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
807
- ] })
808
- }
809
- ) }),
810
- links.map((link) => {
811
- var _a;
812
- return /* @__PURE__ */ jsx(NavigationMenu.List, { value: link.name, children: (_a = link.links) == null ? void 0 : _a.map(
813
- (subLink) => /* @__PURE__ */ jsxs(
814
- NavigationMenu.Item,
815
- {
816
- value: subLink.name,
817
- onMouseEnter: () => setShowMenu(true),
818
- onMouseLeave: () => setShowMenu(false),
819
- children: [
820
- subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
821
- Link2,
822
- {
823
- href: subLink.link,
824
- onMouseEnter: () => handleInteractions(),
825
- onClick: () => handleInteractions(),
826
- children: /* @__PURE__ */ jsx(
827
- "img",
828
- {
829
- src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
830
- draggable: "false",
831
- alt: "Telia logo"
832
- }
833
- )
834
- }
835
- ) : /* @__PURE__ */ jsx(
836
- "a",
837
- {
838
- href: subLink.link,
839
- onMouseEnter: () => handleInteractions(),
840
- onClick: () => handleInteractions(),
841
- children: /* @__PURE__ */ jsx(
842
- "img",
843
- {
844
- src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
845
- draggable: "false",
846
- alt: "Telia logo"
847
- }
848
- )
849
- }
850
- ) }) : /* @__PURE__ */ jsx(
851
- NavigationMenu.Link,
852
- {
853
- asChild: true,
854
- active: selectedMenuItem === subLink.name && currentLocation === subLink.link,
855
- onFocus: () => {
856
- handleInteractions(subLink.name);
857
- setShowMenu(true);
858
- },
859
- children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(
860
- Link2,
861
- {
862
- onMouseEnter: () => handleInteractions(subLink.name),
863
- onClick: () => {
864
- handleInteractions(subLink.name);
865
- setShowMenu(false);
866
- },
867
- href: subLink.link,
868
- children: subLink.name
869
- }
870
- ) : /* @__PURE__ */ jsx(
871
- "a",
872
- {
873
- onMouseEnter: () => handleInteractions(subLink.name),
874
- onClick: () => {
875
- handleInteractions(subLink.name);
876
- setShowMenu(false);
877
- },
878
- onFocus: () => {
879
- setShowMenu(true);
880
- },
881
- href: subLink.link,
882
- children: subLink.name
883
- }
884
- )
885
- }
886
- ),
887
- /* @__PURE__ */ jsx(
888
- "div",
889
- {
890
- style: mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
891
- className: styles[`${rootClassName}__viewport-wrapper`],
892
- "data-state": showMenu ? "open" : "closed",
893
- children: isClientSide && /* @__PURE__ */ jsx(NavigationMenu.Content, { children: !!specifiedLink && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
894
- subLink.links && subLink.links.length > 0 && /* @__PURE__ */ jsx(
895
- HightlightedLinksDesktop,
896
- {
897
- listName: subLink.name,
898
- setShowMenu,
899
- links: subLink.links
900
- }
901
- ),
902
- subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(
903
- HightlightedLinksDesktop,
904
- {
905
- colored: true,
906
- listName: "Nyttige snarveier",
907
- setShowMenu,
908
- links: subLink.highlightedLinks
909
- }
910
- )
911
- ] }) })
912
- }
913
- )
914
- ]
915
- },
916
- subLink.name
917
- )
918
- ) }, link.name);
919
- })
920
- ] });
921
- });
922
- Desktop.displayName = "Desktop";
923
- const HightlightedLinksDesktop = ({ links, listName, colored, setShowMenu }) => {
924
- const rootContext = React__default.useContext(RootContext);
925
- if (!rootContext) return null;
926
- const { linkComponent: Link2, setSpecifiedLink, setSelectedMenuItem } = rootContext;
927
- const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
928
- const firstPart = links.slice(0, 4);
929
- const secondPart = links.slice(4);
930
- return /* @__PURE__ */ jsxs(Box, { pt: "40px", pb: "40px", className: colored ? styles[`${rootClassName}__colored-box`] : "", children: [
931
- /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listName }),
932
- /* @__PURE__ */ jsxs(Flex, { gap: "400", children: [
933
- /* @__PURE__ */ jsx(Box, { children: firstPart == null ? void 0 : firstPart.map((subSubLink) => {
934
- return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
935
- NavigationMenu.Link,
936
- {
937
- asChild: true,
938
- variant: "small",
939
- active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
940
- onClick: () => {
941
- rootContext.setPathname(subSubLink.link);
942
- setSpecifiedLink("");
943
- setSelectedMenuItem("", true);
944
- setShowMenu(false);
945
- },
946
- 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: [
947
- subSubLink.name,
948
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
949
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
950
- subSubLink.name,
951
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
952
- ] }) })
953
- }
954
- ) }, subSubLink.name);
955
- }) }),
956
- /* @__PURE__ */ jsx(Box, { children: secondPart.map((subSubLink) => {
957
- return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
958
- NavigationMenu.Link,
959
- {
960
- asChild: true,
961
- variant: "small",
962
- active: getActiveSubLink(currentLocation, links || []) === subSubLink.link,
963
- onClick: () => {
964
- rootContext.setPathname(subSubLink.link);
965
- setSpecifiedLink("");
966
- setSelectedMenuItem("", true);
967
- setShowMenu(false);
968
- },
969
- 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: [
970
- subSubLink.name,
971
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
972
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", align: "center", children: [
973
- subSubLink.name,
974
- /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
975
- ] }) })
976
- }
977
- ) }, subSubLink.name);
978
- }) })
979
- ] })
980
- ] });
981
- };
982
- function Mobile(props) {
983
- const [specifiedLink, setSpecifiedLink] = React__default.useState("");
984
- const rootContext = React__default.useContext(RootContext);
985
- const drawerRef = React__default.useRef(null);
986
- if (!rootContext) return null;
987
- const links = getLinks(rootContext.pathname.includes("bedrift/utstyrsavtale"), rootContext.customLinks);
988
- const { linkComponent: NavLink } = rootContext;
989
- const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
990
- const linkClasses = clsx([styles[`${rootClassName}__link`]]);
991
- const headerClasses = clsx([styles[`${rootClassName}__header`]]);
992
- return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
993
- Flex,
994
- {
995
- flexGrow: "1",
996
- justify: "between",
997
- align: "center",
998
- gap: "200",
999
- className: styles[`${rootClassName}__top-icon-wrapper`],
1000
- children: [
1001
- /* @__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" }) }) }) }),
1002
- /* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, className: styles[`${rootClassName}__top-menu-icons`], children: [
1003
- /* @__PURE__ */ jsx(Search, {}),
1004
- /* @__PURE__ */ jsx(ShoppingCart, {}),
1005
- /* @__PURE__ */ jsx(MyPages, {}),
1006
- /* @__PURE__ */ jsxs(Drawer, { children: [
1007
- /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
1008
- /* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
1009
- " Meny"
1010
- ] }) }) }),
1011
- /* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
1012
- /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
1013
- !specifiedLink ? /* @__PURE__ */ jsxs(Fragment, { children: [
1014
- /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
1015
- /* @__PURE__ */ jsxs(
1016
- Tabs,
1017
- {
1018
- value: rootContext.selectedDomainItem,
1019
- onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
1020
- children: [
1021
- /* @__PURE__ */ jsx(Tabs.List, { children: links.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { asChild: true, value: link.name, children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name }) }, link.name)) }),
1022
- /* @__PURE__ */ jsx(Fragment, { children: links.map((link) => {
1023
- var _a, _b;
1024
- return /* @__PURE__ */ jsxs(Tabs.Content, { value: link.name, children: [
1025
- /* @__PURE__ */ jsx(Box, { mt: "400", children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1026
- (subLink) => subLink.links && subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Box, { onClick: () => setSpecifiedLink(subLink.name), className: linkClasses, children: [
1027
- /* @__PURE__ */ jsx(Heading, { asChild: true, variant: "title-300", children: /* @__PURE__ */ jsx(Button, { className: styles[`${rootClassName}__sublink-button--mobile`], children: subLink.name }) }),
1028
- /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1029
- ] }) : /* @__PURE__ */ jsx(Fragment, { children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, className: linkClasses, children: [
1030
- /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", className: headerClasses, children: subLink.name }),
1031
- /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1032
- ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, className: linkClasses, children: [
1033
- /* @__PURE__ */ jsx(Heading, { variant: "title-300", as: "h2", children: subLink.name }),
1034
- /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "md" })
1035
- ] }) })
1036
- ) }),
1037
- link.highlightedLinks && ((_b = link.highlightedLinks) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
1038
- HighlightedLinks,
1039
- {
1040
- item: link,
1041
- links: link.highlightedLinks,
1042
- drawerRef,
1043
- listTitle: "Nyttige snarveier"
1044
- }
1045
- ) }) })
1046
- ] }, link.name);
1047
- }) })
1048
- ]
1049
- }
1050
- )
1051
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1052
- /* @__PURE__ */ jsx(Drawer.Title, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "secondary", onClick: () => setSpecifiedLink(""), children: [
1053
- /* @__PURE__ */ jsx(Icon, { name: "arrow-left" }),
1054
- "Tilbake"
1055
- ] }) }),
1056
- /* @__PURE__ */ jsx(Box, { mt: "100", children: links.filter((item) => item.name === rootContext.selectedDomainItem).map(
1057
- (link) => {
1058
- var _a;
1059
- return (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1060
- (subLink) => subLink.links && subLink.links.length > 0 && subLink.name === specifiedLink && /* @__PURE__ */ jsxs(Fragment, { children: [
1061
- /* @__PURE__ */ jsx(
1062
- HighlightedLinks,
1063
- {
1064
- item: subLink,
1065
- listTitle: subLink.name,
1066
- links: subLink.links,
1067
- drawerRef
1068
- }
1069
- ),
1070
- subLink.highlightedLinks && subLink.highlightedLinks.length > 0 && /* @__PURE__ */ jsx(Box, { className: styles[`${rootClassName}__colored-box--mobile`], children: /* @__PURE__ */ jsx(Box, { mt: "400", pt: "250", pb: "250", pl: "300", children: /* @__PURE__ */ jsx(
1071
- HighlightedLinks,
1072
- {
1073
- item: subLink,
1074
- listTitle: "Nyttige snarveier",
1075
- links: subLink.highlightedLinks,
1076
- drawerRef
1077
- }
1078
- ) }) })
1079
- ] })
1080
- );
1081
- }
1082
- ) })
1083
- ] })
1084
- ] })
1085
- ] })
1086
- ] })
1087
- ]
1088
- }
1089
- ) });
1090
- }
1091
- Mobile.displayName = "Mobile";
1092
- const HighlightedLinks = ({
1093
- listTitle,
1094
- links,
1095
- item,
1096
- drawerRef
1097
- }) => {
1098
- const rootContext = React__default.useContext(RootContext);
1099
- if (!rootContext) return null;
1100
- const { linkComponent: NavLink } = rootContext;
1101
- const currentLocation = rootContext.pathname;
1102
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1103
- /* @__PURE__ */ jsx(Heading, { pl: "100", pb: "100", variant: "title-200", as: "h2", children: listTitle }),
1104
- /* @__PURE__ */ jsx(List$1, { gap: "10", pl: "25", children: links == null ? void 0 : links.map((subSubLink) => /* @__PURE__ */ jsx(List$1.Item, { children: /* @__PURE__ */ jsx(
1105
- NavigationMenu.Link,
1106
- {
1107
- asChild: true,
1108
- variant: "small",
1109
- active: getActiveSubLink(currentLocation, item.links || []) === subSubLink.link,
1110
- onClick: () => {
1111
- var _a;
1112
- (_a = drawerRef == null ? void 0 : drawerRef.current) == null ? void 0 : _a.click();
1113
- rootContext.setPathname(subSubLink.link);
1114
- },
1115
- 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: [
1116
- subSubLink.name,
1117
- subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1118
- ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "icon" in subSubLink ? "25" : "100", align: "center", children: [
1119
- subSubLink.name,
1120
- subSubLink.icon ? /* @__PURE__ */ jsx(Icon, { name: subSubLink.icon }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1121
- ] }) })
1122
- }
1123
- ) }, subSubLink.name)) })
1124
- ] });
1125
- };
1126
- const DesktopSimplified = React__default.forwardRef(() => {
1127
- var _a;
1128
- const rootContext = React__default.useContext(RootContext);
1129
- const isRetailerLoggedIn = (_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.isRetailer;
1130
- if (!rootContext) return null;
1131
- const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
1132
- const isBusinessRental = rootContext.pathname.includes("bedrift/utstyrsavtale");
1133
- const links = getLinks(isBusinessRental, rootContext.customLinks);
1134
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1135
- links.map((link) => {
1136
- var _a2;
1137
- return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
1138
- (_a2 = link.links) == null ? void 0 : _a2.map((subLink) => /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
1139
- 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(
1140
- "img",
1141
- {
1142
- src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
1143
- draggable: "false",
1144
- alt: "Telia logo"
1145
- }
1146
- ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
1147
- "img",
1148
- {
1149
- src: "https://www.telia.no/globalassets/static/svg/telia-primary-default-v2.svg",
1150
- draggable: "false",
1151
- alt: "Telia logo"
1152
- }
1153
- ) }) }),
1154
- subLink.name === "Hjem" && isBusinessRental && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, children: /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name }) })
1155
- ] }, subLink.name)),
1156
- /* @__PURE__ */ jsx(Box, { ml: "auto" }),
1157
- /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
1158
- isRetailerLoggedIn && /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
1159
- ] }, link.name);
1160
- }),
1161
- /* @__PURE__ */ jsx(NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
1162
- ] });
1163
- });
1164
- DesktopSimplified.displayName = "DesktopSimplified";
1165
- function MobileSimplified(props) {
1166
- const rootContext = React__default.useContext(RootContext);
1167
- if (!rootContext) return null;
1168
- const { linkComponent: NavLink } = rootContext;
1169
- const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1170
- return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
1171
- /* @__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" }) }) }) }),
1172
- /* @__PURE__ */ jsx(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
1173
- ] }) });
1174
- }
1175
- MobileSimplified.displayName = "MobileSimplified";
1176
- const rootClassName = "teddy-global-navigation";
1177
- const RootContext = React__default.createContext(null);
1178
- function Root({
1179
- className,
1180
- appKey,
1181
- loggedInUser,
1182
- linkComponent,
1183
- onLogoutClick,
1184
- shoppingCart,
1185
- shoppingCartNumberOfItems,
1186
- onSearchSubmit,
1187
- additionalSearchContent,
1188
- isCartOpen,
1189
- onCartOpenChange,
1190
- drawerSize = "md",
1191
- isSimplified,
1192
- customLinks,
1193
- currentPath,
1194
- onSearchInputChange,
1195
- onSearchKeyDown,
1196
- searchValue,
1197
- onClear,
1198
- ...props
1199
- }) {
1200
- const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
1201
- const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath, customLinks));
1202
- const [pathname, setPathname] = React__default.useState(currentPath || "");
1203
- const [specifiedLink, setSpecifiedLink] = React__default.useState(getInitialMenuItem(currentPath, customLinks));
1204
- const classes = clsx([styles[`${rootClassName}`]], className);
1205
- useEffect(() => {
1206
- setPathname(currentPath || "");
1207
- }, [currentPath]);
1208
- return /* @__PURE__ */ jsx(
1209
- RootContext.Provider,
1210
- {
1211
- value: {
1212
- appKey,
1213
- loggedInUser,
1214
- selectedMenuItem,
1215
- setSelectedMenuItem(v, onlyStateChange) {
1216
- if (appKey === "open-pages" && !onlyStateChange) return;
1217
- setSelectedMenuItem(v);
1218
- },
1219
- linkComponent,
1220
- selectedDomainItem,
1221
- setSelectedDomainItem(v, onlyStateChange) {
1222
- if (appKey === "open-pages" && !onlyStateChange) return;
1223
- setSelectedDomainItem(v);
1224
- },
1225
- pathname,
1226
- setPathname(v) {
1227
- if (appKey === "open-pages") return;
1228
- setPathname(v);
1229
- },
1230
- onLogoutClick,
1231
- shoppingCart,
1232
- shoppingCartNumberOfItems,
1233
- onSearchSubmit,
1234
- additionalSearchContent,
1235
- isCartOpen,
1236
- onCartOpenChange,
1237
- drawerSize,
1238
- specifiedLink,
1239
- setSpecifiedLink,
1240
- onSearchInputChange,
1241
- onSearchKeyDown,
1242
- searchValue,
1243
- onClear,
1244
- customLinks
1245
- },
1246
- children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1247
- NavigationMenu,
1248
- {
1249
- topMenuValue: selectedDomainItem,
1250
- onTopMenuValueChange: setSelectedDomainItem,
1251
- value: selectedMenuItem,
1252
- onValueChange: (v) => {
1253
- if (v === "" || appKey === "open-pages") return;
1254
- setSelectedMenuItem(v);
1255
- },
1256
- children: [
1257
- /* @__PURE__ */ jsxs(Box, { display: { sm: "none", lg: "block" }, children: [
1258
- isSimplified && /* @__PURE__ */ jsx(DesktopSimplified, {}),
1259
- !isSimplified && /* @__PURE__ */ jsx(Desktop, {})
1260
- ] }),
1261
- /* @__PURE__ */ jsxs(Box, { display: { lg: "none" }, children: [
1262
- isSimplified && /* @__PURE__ */ jsx(MobileSimplified, {}),
1263
- !isSimplified && /* @__PURE__ */ jsx(Mobile, {})
1264
- ] })
1265
- ]
1266
- }
1267
- ) })
1268
- }
1269
- );
1270
- }
1271
- Root.displayName = "Root";
1272
- function getInitialDomain(currentPath, customLinks) {
1273
- const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
1274
- const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
1275
- const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
1276
- if (!currentPath) return privateLinks.name;
1277
- const locationArray = currentPath ? currentPath.split("/") : [];
1278
- const domainPartOfLocation = `/${locationArray[1].toLowerCase()}/`;
1279
- const initDomain = domainPartOfLocation === businessLinks.link ? businessLinks.name : domainPartOfLocation === mduLinks.link ? mduLinks.name : privateLinks.name;
1280
- return initDomain;
1281
- }
1282
- function getInitialMenuItem(currentPath, customLinks) {
1283
- var _a, _b, _c, _d, _e, _f;
1284
- const privateLinks = (customLinks == null ? void 0 : customLinks.privateLinks) || DEFAULT_PRIVATE_LINKS;
1285
- const businessLinks = (customLinks == null ? void 0 : customLinks.businessLinks) || DEFAULT_BUSINESS_LINKS;
1286
- const mduLinks = (customLinks == null ? void 0 : customLinks.mduLinks) || DEFAULT_MDU_LINKS;
1287
- if (!currentPath) return;
1288
- const locationArray = currentPath ? currentPath.split("/") : [];
1289
- const initialDomain = getInitialDomain(currentPath, customLinks);
1290
- if (initialDomain === businessLinks.name) {
1291
- const mainMenuPartOfLocation2 = locationArray[2];
1292
- return (_b = (_a = businessLinks.links) == null ? void 0 : _a.find(
1293
- (link) => {
1294
- var _a2;
1295
- return link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`));
1296
- }
1297
- )) == null ? void 0 : _b.name;
1298
- }
1299
- if (initialDomain === mduLinks.name) {
1300
- const mainMenuPartOfLocation2 = locationArray[2];
1301
- return (_d = (_c = mduLinks.links) == null ? void 0 : _c.find((link) => link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`)) == null ? void 0 : _d.name;
1302
- }
1303
- const mainMenuPartOfLocation = locationArray[1];
1304
- return (_f = (_e = privateLinks.links) == null ? void 0 : _e.find((link) => {
1305
- var _a2;
1306
- return link.name.toLowerCase() === mainMenuPartOfLocation || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
1307
- })) == null ? void 0 : _f.name;
1308
- }
1309
- Root.displayName = "GlobalNavigation";
1310
- const GlobalNavigation = Root;
63
+ import "./radio-card-group-indicator.js";
1311
64
  export {
1312
- Content$1 as C,
1313
- Close,
1314
- Content$1 as Content,
1315
- Desktop as D,
1316
- Desktop,
1317
- DesktopSimplified,
1318
- GlobalNavigation as G,
1319
- GlobalNavigation,
1320
- HighlightedLinks as H,
1321
- HighlightedLinks,
1322
- ItemContext as I,
1323
- Item$1 as Item,
1324
- ItemContext,
1325
- Modal as M,
1326
- Mobile,
1327
- MobileSimplified,
1328
- Modal,
1329
- MyPages,
1330
- NavigationMenu as N,
1331
- NavigationMenu,
1332
- RadioCardGroup as R,
1333
- RadioCardGroup,
1334
- Separator as S,
1335
- Search,
1336
- SearchField,
1337
- Separator,
1338
- ShoppingCart,
1339
- Title,
1340
- Item$1 as a,
1341
- Close as b,
1342
- MyPages as c,
1343
- SearchField as d,
1344
- Search as e,
1345
- ShoppingCart as f,
1346
- Mobile as g,
1347
- DesktopSimplified as h,
1348
- MobileSimplified as i,
1349
- rootClassName as j,
1350
- RootContext as k,
1351
- Root as l,
1352
- rootClassName$1 as r,
1353
- rootClassName$1 as rootClassName
65
+ c as Title
1354
66
  };