@telia/teddy 0.0.60 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/breadcrumbs/breadcrumbs-link.d.ts +1 -1
- package/dist/components/breadcrumbs/index.d.ts +1 -1
- package/dist/components/card/card-illustration.d.ts +1 -1
- package/dist/components/card/card-link.d.ts +1 -1
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/chip/chip-indicator.d.ts +1 -1
- package/dist/components/chip/index.d.ts +1 -1
- package/dist/components/expandable-card/expandable-card-button.d.ts +3 -3
- package/dist/components/expandable-card/index.d.ts +4 -4
- package/dist/components/index.cjs +11 -4
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +9 -5
- package/dist/components/modal/modal.cjs +3 -2
- package/dist/components/modal/modal.js +3 -2
- package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.js +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.js +1 -2
- package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.js +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.js +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.cjs +12 -682
- package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.js +12 -682
- package/dist/components/navigation-menu/global-navigation/global-navigation-root.cjs +4 -5
- package/dist/components/navigation-menu/global-navigation/global-navigation-root.js +4 -5
- package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.cjs +2 -2
- package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.js +2 -2
- package/dist/components/navigation-menu/global-navigation/global-navigation-search.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-search.js +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.cjs +2 -3
- package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.js +2 -3
- package/dist/components/navigation-menu/global-navigation/index.cjs +2 -2
- package/dist/components/navigation-menu/global-navigation/index.js +1 -1
- package/dist/components/navigation-menu/index.cjs +3 -4
- package/dist/components/navigation-menu/index.js +2 -3
- package/dist/components/navigation-menu/navigation-menu.cjs +55 -436
- package/dist/components/navigation-menu/navigation-menu.d.ts +9 -1
- package/dist/components/navigation-menu/navigation-menu.js +55 -419
- package/dist/components/notabene/notabene-icon.d.ts +1 -1
- package/dist/components/notification/notification.d.ts +1 -1
- package/dist/components/radio-card-group/radio-card-group-content.cjs +3 -2
- package/dist/components/radio-card-group/radio-card-group-content.js +3 -2
- package/dist/components/radio-card-group/radio-card-group-item-body.cjs +3 -2
- package/dist/components/radio-card-group/radio-card-group-item-body.js +3 -2
- package/dist/components/radio-card-group/radio-card-group-item-title.cjs +1137 -51
- package/dist/components/radio-card-group/radio-card-group-item-title.js +1148 -63
- package/dist/components/radio-card-group/radio-card-group-item.cjs +3 -2
- package/dist/components/radio-card-group/radio-card-group-item.js +3 -2
- package/dist/components/scroll-area/index.d.ts +3 -3
- package/dist/components/scroll-area/scroll-area-button.d.ts +3 -3
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/tabs/tabs-scroll-button.d.ts +3 -3
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/text-field/text-field-button.d.ts +2 -2
- package/dist/components/toast/index.cjs +10 -0
- package/dist/components/toast/index.d.ts +9 -0
- package/dist/components/toast/index.js +7 -0
- package/dist/components/toast/toast-root.cjs +121 -0
- package/dist/components/toast/toast-root.d.ts +9 -0
- package/dist/components/toast/toast-root.js +121 -0
- package/dist/components/toggle/toggle.d.ts +1 -1
- package/dist/components/toggletip/index.cjs +31 -0
- package/dist/components/toggletip/index.d.ts +33 -0
- package/dist/components/toggletip/index.js +31 -0
- package/dist/components/toggletip/toggletip-anchor.cjs +33 -0
- package/dist/components/toggletip/toggletip-anchor.d.ts +6 -0
- package/dist/components/toggletip/toggletip-anchor.js +16 -0
- package/dist/components/toggletip/toggletip-arrow.cjs +38 -0
- package/dist/components/toggletip/toggletip-arrow.d.ts +6 -0
- package/dist/components/toggletip/toggletip-arrow.js +21 -0
- package/dist/components/toggletip/toggletip-close.cjs +48 -0
- package/dist/components/toggletip/toggletip-close.d.ts +10 -0
- package/dist/components/toggletip/toggletip-close.js +31 -0
- package/dist/components/toggletip/toggletip-content.cjs +80 -0
- package/dist/components/toggletip/toggletip-content.d.ts +16 -0
- package/dist/components/toggletip/toggletip-content.js +63 -0
- package/dist/components/toggletip/toggletip-footer.cjs +10 -0
- package/dist/components/toggletip/toggletip-footer.d.ts +6 -0
- package/dist/components/toggletip/toggletip-footer.js +10 -0
- package/dist/components/toggletip/toggletip-heading.cjs +25 -0
- package/dist/components/toggletip/toggletip-heading.d.ts +6 -0
- package/dist/components/toggletip/toggletip-heading.js +25 -0
- package/dist/components/toggletip/toggletip-portal.cjs +31 -0
- package/dist/components/toggletip/toggletip-portal.d.ts +11 -0
- package/dist/components/toggletip/toggletip-portal.js +14 -0
- package/dist/components/toggletip/toggletip-root.cjs +36 -0
- package/dist/components/toggletip/toggletip-root.d.ts +26 -0
- package/dist/components/toggletip/toggletip-root.js +19 -0
- package/dist/components/toggletip/toggletip-trigger.cjs +33 -0
- package/dist/components/toggletip/toggletip-trigger.d.ts +10 -0
- package/dist/components/toggletip/toggletip-trigger.js +16 -0
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/main.cjs +11 -4
- package/dist/main.js +9 -5
- package/dist/style.css +3458 -2751
- package/dist/toggletip.module-A6XIfaD_.cjs +10 -0
- package/dist/toggletip.module-BUx6_4pv.js +11 -0
- package/dist/utils/generate-styling/grid.d.ts +24 -24
- package/dist/utils/generate-styling/index.d.ts +16 -16
- package/dist/utils/generate-styling/util.d.ts +2 -2
- package/package.json +17 -15
|
@@ -1,685 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { NavigationMenu } from "../navigation-menu.js";
|
|
6
|
-
import { Box } from "../../box/box.js";
|
|
7
|
-
import { Drawer } from "../../drawer/index.js";
|
|
1
|
+
import "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "../../drawer/index.js";
|
|
4
|
+
import { b } from "../../radio-card-group/radio-card-group-item-title.js";
|
|
8
5
|
import "../../../assets/sprite.269ba410-teddy.svg";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { useComposedRefs } from "../../../utils/composeRefs.js";
|
|
17
|
-
import "../../badge/badge.js";
|
|
18
|
-
import "../../badge/alert-badge.js";
|
|
19
|
-
import { CounterBadge } from "../../badge/counter-badge.js";
|
|
20
|
-
import { useSize } from "../../../utils/useSize.js";
|
|
21
|
-
import { mergeStyles } from "../../../utils/generate-styling/index.js";
|
|
22
|
-
import { useCallbackRef } from "../../../utils/useCallbackRef.js";
|
|
23
|
-
import { teddyMotionDuration300 } from "../../../tokens/motion/variables.js";
|
|
24
|
-
import { Flex } from "../../flex/flex.js";
|
|
25
|
-
import { Accordion } from "../../accordion/index.js";
|
|
26
|
-
import { VisuallyHidden } from "../../visually-hidden/visually-hidden.js";
|
|
27
|
-
import { Link } from "../../link/link.js";
|
|
28
|
-
import { List } from "../../list/index.js";
|
|
29
|
-
const styles = {
|
|
30
|
-
"teddy-global-navigation": "_teddy-global-navigation_1m6ra_1",
|
|
31
|
-
"teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1m6ra_6",
|
|
32
|
-
"teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1m6ra_9",
|
|
33
|
-
"teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1m6ra_6",
|
|
34
|
-
"teddy-global-navigation__link": "_teddy-global-navigation__link_1m6ra_26",
|
|
35
|
-
"teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1m6ra_29",
|
|
36
|
-
"teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1m6ra_32",
|
|
37
|
-
"teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1m6ra_36",
|
|
38
|
-
"teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1m6ra_43",
|
|
39
|
-
"close-viewport": "_close-viewport_1m6ra_1",
|
|
40
|
-
"teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1m6ra_54",
|
|
41
|
-
"teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_1m6ra_64",
|
|
42
|
-
"teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_1m6ra_80"
|
|
43
|
-
};
|
|
44
|
-
function MyPages(props) {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
const rootContext = React__default.useContext(RootContext);
|
|
47
|
-
const isLoggedIn = (((_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.name.length) || 0) > 0;
|
|
48
|
-
return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
|
|
49
|
-
/* @__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: [
|
|
50
|
-
/* @__PURE__ */ jsx(Icon, { name: "end-user", size: "sm" }),
|
|
51
|
-
rootContext.loggedInUser.name
|
|
52
|
-
] }) : /* @__PURE__ */ jsxs("button", { children: [
|
|
53
|
-
/* @__PURE__ */ jsx(Icon, { name: "login", size: "sm" }),
|
|
54
|
-
"Logg inn"
|
|
55
|
-
] }) }) }),
|
|
56
|
-
/* @__PURE__ */ jsxs(Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
|
|
57
|
-
/* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
|
|
58
|
-
isLoggedIn ? /* @__PURE__ */ jsx(LoggedInContent, {}) : /* @__PURE__ */ jsx(LoggedOutContent, {}),
|
|
59
|
-
/* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
|
|
60
|
-
] })
|
|
61
|
-
] });
|
|
62
|
-
}
|
|
63
|
-
function LoggedOutContent() {
|
|
64
|
-
return /* @__PURE__ */ jsxs(Grid, { gap: "400", children: [
|
|
65
|
-
/* @__PURE__ */ jsx(Drawer.Title, { children: "Logg inn" }),
|
|
66
|
-
/* @__PURE__ */ jsxs(TextSpacing, { children: [
|
|
67
|
-
/* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Privat" }),
|
|
68
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: MY_PAGE_LINKS.link, children: [
|
|
69
|
-
MY_PAGE_LINKS.name,
|
|
70
|
-
" ",
|
|
71
|
-
/* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
|
|
72
|
-
] }) })
|
|
73
|
-
] }),
|
|
74
|
-
/* @__PURE__ */ jsxs(TextSpacing, { children: [
|
|
75
|
-
/* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Bedrift" }),
|
|
76
|
-
/* @__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: [
|
|
77
|
-
link.name,
|
|
78
|
-
" ",
|
|
79
|
-
/* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
|
|
80
|
-
] }) })) })
|
|
81
|
-
] })
|
|
82
|
-
] });
|
|
83
|
-
}
|
|
84
|
-
function LoggedInContent() {
|
|
85
|
-
var _a;
|
|
86
|
-
const rootContext = React__default.useContext(RootContext);
|
|
87
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
-
/* @__PURE__ */ jsx(Drawer.Title, { children: "Dine sider" }),
|
|
89
|
-
/* @__PURE__ */ jsxs(Tabs, { defaultValue: "private", children: [
|
|
90
|
-
/* @__PURE__ */ jsxs(Tabs.List, { children: [
|
|
91
|
-
/* @__PURE__ */ jsx(Tabs.Trigger, { value: "private", children: "Privat" }),
|
|
92
|
-
/* @__PURE__ */ jsx(Tabs.Trigger, { value: "business", children: "Bedrift" })
|
|
93
|
-
] }),
|
|
94
|
-
/* @__PURE__ */ jsxs(TextSpacing, { children: [
|
|
95
|
-
/* @__PURE__ */ jsxs(Tabs.Content, { value: "private", children: [
|
|
96
|
-
/* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
|
|
97
|
-
(_a = MY_PAGE_LINKS.links) == null ? void 0 : _a.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))
|
|
98
|
-
] }),
|
|
99
|
-
/* @__PURE__ */ jsxs(Tabs.Content, { value: "business", children: [
|
|
100
|
-
/* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Bedriftsportaler" }),
|
|
101
|
-
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))
|
|
102
|
-
] }),
|
|
103
|
-
/* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
|
|
104
|
-
] })
|
|
105
|
-
] })
|
|
106
|
-
] });
|
|
107
|
-
}
|
|
108
|
-
MyPages.displayName = "MyPages";
|
|
109
|
-
const SearchField = React__default.forwardRef(
|
|
110
|
-
(props, forwardRef) => {
|
|
111
|
-
const ref = React__default.useRef(null);
|
|
112
|
-
const context = React__default.useContext(RootContext);
|
|
113
|
-
const composedRef = useComposedRefs(forwardRef, ref);
|
|
114
|
-
return /* @__PURE__ */ jsx(
|
|
115
|
-
"form",
|
|
116
|
-
{
|
|
117
|
-
onSubmit: (e) => {
|
|
118
|
-
var _a, _b;
|
|
119
|
-
console.log("Search submitted,111");
|
|
120
|
-
if (context == null ? void 0 : context.onSearchSubmit) {
|
|
121
|
-
context.onSearchSubmit(e, (_a = ref.current) == null ? void 0 : _a.value);
|
|
122
|
-
}
|
|
123
|
-
if (!window || e.isDefaultPrevented())
|
|
124
|
-
return;
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
window.location.href = `/sok?q=${encodeURIComponent(((_b = ref.current) == null ? void 0 : _b.value) || "")}`;
|
|
127
|
-
},
|
|
128
|
-
children: /* @__PURE__ */ jsxs(TextField, { ...props, children: [
|
|
129
|
-
/* @__PURE__ */ jsx(TextField.Label, { children: "Søk i innhold" }),
|
|
130
|
-
/* @__PURE__ */ jsxs(TextField.InputGroup, { children: [
|
|
131
|
-
/* @__PURE__ */ jsx(Icon, { name: "search" }),
|
|
132
|
-
/* @__PURE__ */ jsx(TextField.Input, { ref: composedRef, placeholder: "Søk her" }),
|
|
133
|
-
/* @__PURE__ */ jsx(TextField.ClearButton, {})
|
|
134
|
-
] }),
|
|
135
|
-
/* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
|
|
136
|
-
] })
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
SearchField.displayName = "SearchField";
|
|
142
|
-
function Search(props) {
|
|
143
|
-
const rootContext = React__default.useContext(RootContext);
|
|
144
|
-
const searchFieldRef = React__default.useRef(null);
|
|
145
|
-
return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
|
|
146
|
-
/* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
|
|
147
|
-
/* @__PURE__ */ jsx(Icon, { name: "search", size: "sm" }),
|
|
148
|
-
" Søk"
|
|
149
|
-
] }) }) }),
|
|
150
|
-
/* @__PURE__ */ jsxs(
|
|
151
|
-
Drawer.Content,
|
|
152
|
-
{
|
|
153
|
-
size: rootContext == null ? void 0 : rootContext.drawerSize,
|
|
154
|
-
onOpenAutoFocus: (e) => {
|
|
155
|
-
var _a;
|
|
156
|
-
e.preventDefault();
|
|
157
|
-
(_a = searchFieldRef.current) == null ? void 0 : _a.focus();
|
|
158
|
-
},
|
|
159
|
-
children: [
|
|
160
|
-
/* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
|
|
161
|
-
/* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
|
|
162
|
-
/* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
|
|
163
|
-
/* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
)
|
|
167
|
-
] });
|
|
168
|
-
}
|
|
169
|
-
Search.displayName = "Search";
|
|
170
|
-
const ShoppingCart = React__default.forwardRef(() => {
|
|
171
|
-
const rootContext = React__default.useContext(RootContext);
|
|
172
|
-
const shoppingCartContent = rootContext == null ? void 0 : rootContext.shoppingCart;
|
|
173
|
-
const numberOfItemsInCart = (rootContext == null ? void 0 : rootContext.shoppingCartNumberOfItems) || 0;
|
|
174
|
-
const titleSuffix = numberOfItemsInCart > 0 ? `(${numberOfItemsInCart})` : "";
|
|
175
|
-
if (!numberOfItemsInCart)
|
|
176
|
-
return null;
|
|
177
|
-
return /* @__PURE__ */ jsxs(Drawer, { open: rootContext == null ? void 0 : rootContext.isCartOpen, onOpenChange: rootContext == null ? void 0 : rootContext.onCartOpenChange, children: [
|
|
178
|
-
/* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
|
|
179
|
-
/* @__PURE__ */ jsxs("div", { className: clsx([styles[`${rootClassName}__item-wrapper`]]), children: [
|
|
180
|
-
/* @__PURE__ */ jsx(Icon, { name: "cart", size: "sm" }),
|
|
181
|
-
numberOfItemsInCart > 0 && /* @__PURE__ */ jsx("span", { className: clsx([styles[`${rootClassName}__item-count`]]), children: /* @__PURE__ */ jsx(CounterBadge, { variant: "attention", children: numberOfItemsInCart }) })
|
|
182
|
-
] }),
|
|
183
|
-
"Handlekurv"
|
|
184
|
-
] }) }) }),
|
|
185
|
-
/* @__PURE__ */ jsxs(Drawer.Content, { size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
|
|
186
|
-
/* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
|
|
187
|
-
/* @__PURE__ */ jsxs(Drawer.Title, { children: [
|
|
188
|
-
"Handlekurv ",
|
|
189
|
-
titleSuffix
|
|
190
|
-
] }),
|
|
191
|
-
shoppingCartContent ? shoppingCartContent : null,
|
|
192
|
-
/* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
|
|
193
|
-
] })
|
|
194
|
-
] });
|
|
195
|
-
});
|
|
196
|
-
ShoppingCart.displayName = "ShoppingCart";
|
|
197
|
-
const scrollDistanceDownThreshold = 200;
|
|
198
|
-
const scrollDistanceUpThreshold = 50;
|
|
199
|
-
const ANIMATION_DURATION = 300;
|
|
200
|
-
const Desktop = React__default.forwardRef(() => {
|
|
201
|
-
const rootContext = React__default.useContext(RootContext);
|
|
202
|
-
const [hideMenu, setHideMenu] = React__default.useState(null);
|
|
203
|
-
const lastScrollDirection = React__default.useRef();
|
|
204
|
-
const scrollStartPos = React__default.useRef(0);
|
|
205
|
-
const lastScrollPos = React__default.useRef(0);
|
|
206
|
-
const topMenuRef = React__default.useRef(null);
|
|
207
|
-
const viewPortRef = React__default.useRef(null);
|
|
208
|
-
const shouldShowViewport = [...PRIVATE_LINKS.links, ...BUSINESS_LINKS.links, ...MDU_LINKS.links].some(
|
|
209
|
-
(link) => !!getActiveSubLink((rootContext == null ? void 0 : rootContext.pathname) || "", link.links) || link.links.length && link.link === (rootContext == null ? void 0 : rootContext.pathname)
|
|
210
|
-
);
|
|
211
|
-
const viewPortSize = useSize(viewPortRef.current);
|
|
212
|
-
const topMenuSize = useSize(topMenuRef.current);
|
|
213
|
-
const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
|
|
214
|
-
const viewPortHeight = shouldShowViewport ? "47px" : void 0;
|
|
215
|
-
const animationTimer = React__default.useRef(0);
|
|
216
|
-
const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
|
|
217
|
-
const timerRef = React__default.useRef(void 0);
|
|
218
|
-
React__default.useEffect(() => {
|
|
219
|
-
timerRef.current = setTimeout(() => {
|
|
220
|
-
setAllowAnimationOfHeight(true);
|
|
221
|
-
}, 500);
|
|
222
|
-
return () => {
|
|
223
|
-
timerRef.current && clearTimeout(timerRef.current);
|
|
224
|
-
};
|
|
225
|
-
}, []);
|
|
226
|
-
const handleScroll = () => {
|
|
227
|
-
let compensateHight = 0;
|
|
228
|
-
if (animationTimer.current > 0) {
|
|
229
|
-
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
230
|
-
if (animationTimer.current + ANIMATION_DURATION > currentTime) {
|
|
231
|
-
compensateHight = ((topMenuSize == null ? void 0 : topMenuSize.height) || 0) + ((viewPortSize == null ? void 0 : viewPortSize.height) || 0);
|
|
232
|
-
} else {
|
|
233
|
-
animationTimer.current = 0;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const scrollY = window.scrollY;
|
|
237
|
-
const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
|
|
238
|
-
const scrollDistance = Math.abs(scrollStartPos.current - scrollY);
|
|
239
|
-
if (scrollDirection !== lastScrollDirection.current) {
|
|
240
|
-
scrollStartPos.current = scrollY;
|
|
241
|
-
}
|
|
242
|
-
if (!hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "down" && scrollDistance > scrollDistanceDownThreshold + compensateHight) {
|
|
243
|
-
setHideMenu(true);
|
|
244
|
-
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
245
|
-
animationTimer.current = currentTime;
|
|
246
|
-
}
|
|
247
|
-
if (hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "up" && scrollDistance > scrollDistanceUpThreshold + compensateHight || scrollY === 0) {
|
|
248
|
-
setHideMenu(false);
|
|
249
|
-
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
250
|
-
animationTimer.current = currentTime;
|
|
251
|
-
}
|
|
252
|
-
lastScrollDirection.current = scrollDirection;
|
|
253
|
-
lastScrollPos.current = scrollY;
|
|
254
|
-
};
|
|
255
|
-
const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
|
|
256
|
-
React__default.useEffect(() => {
|
|
257
|
-
window.addEventListener("scroll", throttledScrollHandler);
|
|
258
|
-
return () => {
|
|
259
|
-
window.removeEventListener("scroll", throttledScrollHandler);
|
|
260
|
-
};
|
|
261
|
-
}, [throttledScrollHandler]);
|
|
262
|
-
if (!rootContext)
|
|
263
|
-
return null;
|
|
264
|
-
function resetAndShowMenu() {
|
|
265
|
-
lastScrollDirection.current = null;
|
|
266
|
-
scrollStartPos.current = window.scrollY;
|
|
267
|
-
lastScrollPos.current = window.scrollY;
|
|
268
|
-
setHideMenu(false);
|
|
269
|
-
}
|
|
270
|
-
const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
|
|
271
|
-
const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
|
|
272
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
273
|
-
/* @__PURE__ */ jsx(
|
|
274
|
-
"div",
|
|
275
|
-
{
|
|
276
|
-
style: mergeStyles(
|
|
277
|
-
{ ["--teddy-top-menu-height"]: topMenuHeight },
|
|
278
|
-
allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
|
|
279
|
-
),
|
|
280
|
-
className: styles[`${rootClassName}__top-menu-wrapper`],
|
|
281
|
-
"data-state": hideMenu ? "closed" : "open",
|
|
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)) })
|
|
291
|
-
}
|
|
292
|
-
),
|
|
293
|
-
LINKS.map((link) => {
|
|
294
|
-
var _a;
|
|
295
|
-
return /* @__PURE__ */ jsxs(NavigationMenu.List, { onFocus: resetAndShowMenu, value: link.name, children: [
|
|
296
|
-
(_a = link.links) == null ? void 0 : _a.map((subLink) => {
|
|
297
|
-
var _a2, _b;
|
|
298
|
-
return /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
|
|
299
|
-
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(
|
|
300
|
-
"img",
|
|
301
|
-
{
|
|
302
|
-
src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
|
|
303
|
-
draggable: "false",
|
|
304
|
-
alt: "Telia logo"
|
|
305
|
-
}
|
|
306
|
-
) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
|
|
307
|
-
"img",
|
|
308
|
-
{
|
|
309
|
-
src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
|
|
310
|
-
draggable: "false",
|
|
311
|
-
alt: "Telia logo"
|
|
312
|
-
}
|
|
313
|
-
) }) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
|
|
314
|
-
NavigationMenu.Trigger,
|
|
315
|
-
{
|
|
316
|
-
asChild: true,
|
|
317
|
-
active: currentLocation === subLink.link,
|
|
318
|
-
onClick: () => {
|
|
319
|
-
rootContext.setPathname(subLink.link);
|
|
320
|
-
},
|
|
321
|
-
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 })
|
|
322
|
-
}
|
|
323
|
-
) : /* @__PURE__ */ jsx(
|
|
324
|
-
NavigationMenu.Link,
|
|
325
|
-
{
|
|
326
|
-
asChild: true,
|
|
327
|
-
active: currentLocation === subLink.link,
|
|
328
|
-
onClick: () => {
|
|
329
|
-
rootContext.setPathname(subLink.link);
|
|
330
|
-
},
|
|
331
|
-
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 })
|
|
332
|
-
}
|
|
333
|
-
),
|
|
334
|
-
/* @__PURE__ */ jsx(NavigationMenu.Content, { children: /* @__PURE__ */ jsx("ul", { children: (_b = subLink.links) == null ? void 0 : _b.map((subSubLink) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
335
|
-
NavigationMenu.Link,
|
|
336
|
-
{
|
|
337
|
-
asChild: true,
|
|
338
|
-
active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
|
|
339
|
-
onClick: () => {
|
|
340
|
-
rootContext.setPathname(subSubLink.link);
|
|
341
|
-
},
|
|
342
|
-
variant: "small",
|
|
343
|
-
children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: subSubLink.name }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: subSubLink.name })
|
|
344
|
-
}
|
|
345
|
-
) }, subSubLink.name)) }) })
|
|
346
|
-
] }, subLink.name);
|
|
347
|
-
}),
|
|
348
|
-
/* @__PURE__ */ jsx(Box, { ml: "auto" }),
|
|
349
|
-
/* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
|
|
350
|
-
/* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
|
|
351
|
-
/* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
|
|
352
|
-
] }, link.name);
|
|
353
|
-
}),
|
|
354
|
-
/* @__PURE__ */ jsx(
|
|
355
|
-
"div",
|
|
356
|
-
{
|
|
357
|
-
style: mergeStyles(
|
|
358
|
-
{ ["--teddy-viewport-wrapper-height"]: viewPortHeight },
|
|
359
|
-
allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
|
|
360
|
-
),
|
|
361
|
-
className: styles[`${rootClassName}__viewport-wrapper`],
|
|
362
|
-
"data-state": hideMenu === null ? "" : hideMenu ? "closed" : "open",
|
|
363
|
-
children: /* @__PURE__ */ jsx(
|
|
364
|
-
NavigationMenu.Viewport,
|
|
365
|
-
{
|
|
366
|
-
onFocus: resetAndShowMenu,
|
|
367
|
-
ref: viewPortRef,
|
|
368
|
-
className: styles[`${rootClassName}__viewport`]
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
] });
|
|
374
|
-
});
|
|
375
|
-
Desktop.displayName = "Desktop";
|
|
376
|
-
function useDebounceCallback(callback, delay) {
|
|
377
|
-
const handleCallback = useCallbackRef(callback);
|
|
378
|
-
const debounceTimerRef = React__default.useRef(0);
|
|
379
|
-
React__default.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
|
|
380
|
-
return React__default.useCallback(() => {
|
|
381
|
-
window.clearTimeout(debounceTimerRef.current);
|
|
382
|
-
debounceTimerRef.current = window.setTimeout(handleCallback, delay);
|
|
383
|
-
}, [handleCallback, delay]);
|
|
384
|
-
}
|
|
385
|
-
function Mobile(props) {
|
|
386
|
-
const rootContext = React__default.useContext(RootContext);
|
|
387
|
-
const drawerRef = React__default.useRef(null);
|
|
388
|
-
if (!rootContext)
|
|
389
|
-
return null;
|
|
390
|
-
const { linkComponent: NavLink } = rootContext;
|
|
391
|
-
const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
|
|
392
|
-
const linkClasses = clsx([styles[`${rootClassName}__link`]]);
|
|
393
|
-
const currentLocation = rootContext.pathname;
|
|
394
|
-
return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
|
|
395
|
-
/* @__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" }) }) }) }),
|
|
396
|
-
/* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: [
|
|
397
|
-
/* @__PURE__ */ jsx(ShoppingCart, {}),
|
|
398
|
-
/* @__PURE__ */ jsx(MyPages, {}),
|
|
399
|
-
/* @__PURE__ */ jsxs(Drawer, { children: [
|
|
400
|
-
/* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
|
|
401
|
-
/* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
|
|
402
|
-
" Meny"
|
|
403
|
-
] }) }) }),
|
|
404
|
-
/* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
|
|
405
|
-
/* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
|
|
406
|
-
/* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
|
|
407
|
-
/* @__PURE__ */ jsx(SearchField, {}),
|
|
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, { 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)) }),
|
|
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);
|
|
496
|
-
}
|
|
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" }) }) })
|
|
505
|
-
] })
|
|
506
|
-
] })
|
|
507
|
-
] })
|
|
508
|
-
] }) });
|
|
509
|
-
}
|
|
510
|
-
Mobile.displayName = "Mobile";
|
|
511
|
-
const DesktopSimplified = React__default.forwardRef(() => {
|
|
512
|
-
const rootContext = React__default.useContext(RootContext);
|
|
513
|
-
if (!rootContext)
|
|
514
|
-
return null;
|
|
515
|
-
const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
|
|
516
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
517
|
-
LINKS.map((link) => {
|
|
518
|
-
var _a;
|
|
519
|
-
return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
|
|
520
|
-
(_a = link.links) == null ? void 0 : _a.map((subLink) => /* @__PURE__ */ jsx(NavigationMenu.Item, { value: subLink.name, children: subLink.name === "Logo" && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
|
|
521
|
-
"img",
|
|
522
|
-
{
|
|
523
|
-
src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
|
|
524
|
-
draggable: "false",
|
|
525
|
-
alt: "Telia logo"
|
|
526
|
-
}
|
|
527
|
-
) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
|
|
528
|
-
"img",
|
|
529
|
-
{
|
|
530
|
-
src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
|
|
531
|
-
draggable: "false",
|
|
532
|
-
alt: "Telia logo"
|
|
533
|
-
}
|
|
534
|
-
) }) }) }, subLink.name)),
|
|
535
|
-
/* @__PURE__ */ jsx(Box, { ml: "auto" }),
|
|
536
|
-
/* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
|
|
537
|
-
] }, link.name);
|
|
538
|
-
}),
|
|
539
|
-
/* @__PURE__ */ jsx(NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
|
|
540
|
-
] });
|
|
541
|
-
});
|
|
542
|
-
DesktopSimplified.displayName = "DesktopSimplified";
|
|
543
|
-
function MobileSimplified(props) {
|
|
544
|
-
const rootContext = React__default.useContext(RootContext);
|
|
545
|
-
if (!rootContext)
|
|
546
|
-
return null;
|
|
547
|
-
const { linkComponent: NavLink } = rootContext;
|
|
548
|
-
const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
|
|
549
|
-
return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
|
|
550
|
-
/* @__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" }) }) }) }),
|
|
551
|
-
/* @__PURE__ */ jsx(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
|
|
552
|
-
] }) });
|
|
553
|
-
}
|
|
554
|
-
MobileSimplified.displayName = "MobileSimplified";
|
|
555
|
-
const rootClassName = "teddy-global-navigation";
|
|
556
|
-
const RootContext = React__default.createContext(null);
|
|
557
|
-
function Root({
|
|
558
|
-
className,
|
|
559
|
-
appKey,
|
|
560
|
-
loggedInUser,
|
|
561
|
-
linkComponent,
|
|
562
|
-
onLogoutClick,
|
|
563
|
-
shoppingCart,
|
|
564
|
-
shoppingCartNumberOfItems,
|
|
565
|
-
onSearchSubmit,
|
|
566
|
-
isCartOpen,
|
|
567
|
-
onCartOpenChange,
|
|
568
|
-
drawerSize = "md",
|
|
569
|
-
isSimplified,
|
|
570
|
-
currentPath,
|
|
571
|
-
...props
|
|
572
|
-
}) {
|
|
573
|
-
const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
|
|
574
|
-
const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath));
|
|
575
|
-
const [pathname, setPathname] = React__default.useState(currentPath || "");
|
|
576
|
-
const classes = clsx([styles[`${rootClassName}`]], className);
|
|
577
|
-
return /* @__PURE__ */ jsx(
|
|
578
|
-
RootContext.Provider,
|
|
579
|
-
{
|
|
580
|
-
value: {
|
|
581
|
-
appKey,
|
|
582
|
-
loggedInUser,
|
|
583
|
-
selectedMenuItem,
|
|
584
|
-
setSelectedMenuItem(v, onlyStateChange) {
|
|
585
|
-
if (appKey === "open-pages" && !onlyStateChange)
|
|
586
|
-
return;
|
|
587
|
-
setSelectedMenuItem(v);
|
|
588
|
-
},
|
|
589
|
-
linkComponent,
|
|
590
|
-
selectedDomainItem,
|
|
591
|
-
setSelectedDomainItem(v, onlyStateChange) {
|
|
592
|
-
if (appKey === "open-pages" && !onlyStateChange)
|
|
593
|
-
return;
|
|
594
|
-
setSelectedDomainItem(v);
|
|
595
|
-
},
|
|
596
|
-
pathname,
|
|
597
|
-
setPathname(v) {
|
|
598
|
-
if (appKey === "open-pages")
|
|
599
|
-
return;
|
|
600
|
-
setPathname(v);
|
|
601
|
-
},
|
|
602
|
-
onLogoutClick,
|
|
603
|
-
shoppingCart,
|
|
604
|
-
shoppingCartNumberOfItems,
|
|
605
|
-
onSearchSubmit,
|
|
606
|
-
isCartOpen,
|
|
607
|
-
onCartOpenChange,
|
|
608
|
-
drawerSize
|
|
609
|
-
},
|
|
610
|
-
children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
|
|
611
|
-
NavigationMenu,
|
|
612
|
-
{
|
|
613
|
-
topMenuValue: selectedDomainItem,
|
|
614
|
-
onTopMenuValueChange: setSelectedDomainItem,
|
|
615
|
-
value: selectedMenuItem,
|
|
616
|
-
onValueChange: (v) => {
|
|
617
|
-
if (v === "" || appKey === "open-pages")
|
|
618
|
-
return;
|
|
619
|
-
setSelectedMenuItem(v);
|
|
620
|
-
},
|
|
621
|
-
children: [
|
|
622
|
-
/* @__PURE__ */ jsxs(Box, { display: { sm: "none", lg: "block" }, children: [
|
|
623
|
-
isSimplified && /* @__PURE__ */ jsx(DesktopSimplified, {}),
|
|
624
|
-
!isSimplified && /* @__PURE__ */ jsx(Desktop, {})
|
|
625
|
-
] }),
|
|
626
|
-
/* @__PURE__ */ jsxs(Box, { display: { lg: "none" }, children: [
|
|
627
|
-
isSimplified && /* @__PURE__ */ jsx(MobileSimplified, {}),
|
|
628
|
-
!isSimplified && /* @__PURE__ */ jsx(Mobile, {})
|
|
629
|
-
] })
|
|
630
|
-
]
|
|
631
|
-
}
|
|
632
|
-
) })
|
|
633
|
-
}
|
|
634
|
-
);
|
|
635
|
-
}
|
|
636
|
-
Root.displayName = "Root";
|
|
637
|
-
function getInitialDomain(currentPath) {
|
|
638
|
-
if (!currentPath)
|
|
639
|
-
return PRIVATE_LINKS.name;
|
|
640
|
-
const locationArray = currentPath ? currentPath.split("/") : [];
|
|
641
|
-
const domainPartOfLocation = `/${locationArray[1].toLowerCase()}/`;
|
|
642
|
-
const initDomain = domainPartOfLocation === BUSINESS_LINKS.link ? BUSINESS_LINKS.name : domainPartOfLocation === MDU_LINKS.link ? MDU_LINKS.name : PRIVATE_LINKS.name;
|
|
643
|
-
return initDomain;
|
|
644
|
-
}
|
|
645
|
-
function getInitialMenuItem(currentPath) {
|
|
646
|
-
var _a, _b, _c, _d, _e, _f;
|
|
647
|
-
if (!currentPath)
|
|
648
|
-
return;
|
|
649
|
-
const locationArray = currentPath ? currentPath.split("/") : [];
|
|
650
|
-
const initialDomain = getInitialDomain(currentPath);
|
|
651
|
-
if (initialDomain === "Bedrift") {
|
|
652
|
-
const mainMenuPartOfLocation2 = locationArray[2];
|
|
653
|
-
return (_b = (_a = BUSINESS_LINKS.links) == null ? void 0 : _a.find(
|
|
654
|
-
(link) => {
|
|
655
|
-
var _a2;
|
|
656
|
-
return link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`));
|
|
657
|
-
}
|
|
658
|
-
)) == null ? void 0 : _b.name;
|
|
659
|
-
}
|
|
660
|
-
if (initialDomain === "Borettslag") {
|
|
661
|
-
const mainMenuPartOfLocation2 = locationArray[2];
|
|
662
|
-
return (_d = (_c = MDU_LINKS.links) == null ? void 0 : _c.find((link) => link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`)) == null ? void 0 : _d.name;
|
|
663
|
-
}
|
|
664
|
-
const mainMenuPartOfLocation = locationArray[1];
|
|
665
|
-
return (_f = (_e = PRIVATE_LINKS.links) == null ? void 0 : _e.find((link) => {
|
|
666
|
-
var _a2;
|
|
667
|
-
return link.link === `/${mainMenuPartOfLocation}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
|
|
668
|
-
})) == null ? void 0 : _f.name;
|
|
669
|
-
}
|
|
670
|
-
Root.displayName = "GlobalNavigation";
|
|
671
|
-
const GlobalNavigation = Root;
|
|
6
|
+
import "../../icon/icon.js";
|
|
7
|
+
import "../../button/button.js";
|
|
8
|
+
import "../../grid/grid.js";
|
|
9
|
+
import "../../heading/heading.js";
|
|
10
|
+
import "../../text-spacing/text-spacing.js";
|
|
11
|
+
import "../../tabs/index.js";
|
|
12
|
+
import "./utils.js";
|
|
672
13
|
export {
|
|
673
|
-
|
|
674
|
-
GlobalNavigation as G,
|
|
675
|
-
Mobile as M,
|
|
676
|
-
MyPages,
|
|
677
|
-
RootContext as R,
|
|
678
|
-
SearchField as S,
|
|
679
|
-
Search as a,
|
|
680
|
-
ShoppingCart as b,
|
|
681
|
-
DesktopSimplified as c,
|
|
682
|
-
MobileSimplified as d,
|
|
683
|
-
Root as e,
|
|
684
|
-
rootClassName as r
|
|
14
|
+
b as MyPages
|
|
685
15
|
};
|