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