@dnanpm/styleguide 3.12.3 → 4.0.0
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/build/cjs/components/Button/Button.d.ts +1 -7
- package/build/cjs/components/Button/Button.js +3 -3
- package/build/cjs/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/cjs/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/cjs/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/cjs/components/Chip/Chip.d.ts +2 -18
- package/build/cjs/components/Chip/Chip.js +2 -2
- package/build/cjs/components/Drawer/Drawer.d.ts +0 -7
- package/build/cjs/components/Drawer/Drawer.js +1 -1
- package/build/cjs/components/Footer/Components/FooterComponents.js +0 -1
- package/build/cjs/components/Hero/Hero.js +3 -2
- package/build/cjs/components/Icon/Icon.d.ts +2 -8
- package/build/cjs/components/Icon/Icon.js +3 -10
- package/build/cjs/components/Input/Input.d.ts +1 -10
- package/build/cjs/components/LabelText/LabelText.d.ts +1 -6
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +1 -1
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/cjs/components/Modal/Modal.d.ts +0 -5
- package/build/cjs/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/cjs/components/ReadMore/ReadMore.js +2 -8
- package/build/cjs/components/Tab/Tab.d.ts +2 -30
- package/build/cjs/components/Tab/Tab.js +2 -33
- package/build/cjs/components/Tabs/Tabs.d.ts +1 -9
- package/build/cjs/components/Tabs/Tabs.js +9 -17
- package/build/cjs/components/index.d.ts +0 -4
- package/build/cjs/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/cjs/index.js +0 -8
- package/build/cjs/themes/themeComponents/navigation.js +0 -4
- package/build/es/components/Button/Button.d.ts +1 -7
- package/build/es/components/Button/Button.js +3 -3
- package/build/es/components/ButtonArrow/ButtonArrow.d.ts +1 -7
- package/build/es/components/ButtonArrow/ButtonArrow.js +2 -2
- package/build/es/components/ButtonIcon/ButtonIcon.js +3 -3
- package/build/es/components/Chip/Chip.d.ts +2 -18
- package/build/es/components/Chip/Chip.js +2 -2
- package/build/es/components/Drawer/Drawer.d.ts +0 -7
- package/build/es/components/Drawer/Drawer.js +1 -1
- package/build/es/components/Footer/Components/FooterComponents.js +0 -1
- package/build/es/components/Hero/Hero.js +3 -2
- package/build/es/components/Icon/Icon.d.ts +2 -8
- package/build/es/components/Icon/Icon.js +3 -10
- package/build/es/components/Input/Input.d.ts +1 -10
- package/build/es/components/LabelText/LabelText.d.ts +1 -6
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +1 -1
- package/build/es/components/MainHeaderNavigation/ChildComponents/MinicartTooltip.js +2 -2
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +1 -7
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.js +1 -3
- package/build/es/components/MainHeaderNavigation/context/NavContext.d.ts +0 -1
- package/build/es/components/MainHeaderNavigation/context/NavContext.js +0 -1
- package/build/es/components/Modal/Modal.d.ts +0 -5
- package/build/es/components/ReadMore/ReadMore.d.ts +0 -20
- package/build/es/components/ReadMore/ReadMore.js +2 -8
- package/build/es/components/Tab/Tab.d.ts +2 -30
- package/build/es/components/Tab/Tab.js +2 -33
- package/build/es/components/Tabs/Tabs.d.ts +1 -9
- package/build/es/components/Tabs/Tabs.js +9 -17
- package/build/es/components/index.d.ts +0 -4
- package/build/es/hooks/useCloseOutsideOrElementClicked.js +1 -1
- package/build/es/index.js +0 -4
- package/build/es/themes/themeComponents/navigation.js +1 -3
- package/package.json +12 -12
- package/build/cjs/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/cjs/components/ButtonRound/ButtonRound.js +0 -37
- package/build/cjs/components/Icons/index.js +0 -224
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -59
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -259
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/cjs/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -168
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/cjs/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/cjs/components/MainNavigation/ChildComponents/LinkModifier.js +0 -38
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -104
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -62
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/cjs/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -26
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/cjs/components/MainNavigation/ChildComponents/MobileMenu.js +0 -193
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/cjs/components/MainNavigation/ChildComponents/PageSearch.js +0 -23
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/cjs/components/MainNavigation/ChildComponents/Ribbon.js +0 -74
- package/build/cjs/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/cjs/components/MainNavigation/MainNavigation.js +0 -319
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/cjs/components/MainNavigation/context/MobileMenuContext.js +0 -11
- package/build/cjs/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/cjs/components/MainNavigation/context/NavContext.js +0 -46
- package/build/cjs/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/cjs/components/MainNavigation/globalNavStyles.js +0 -94
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/cjs/components/SecondaryNavigation/SecondaryNavigation.js +0 -207
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/cjs/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -34
- package/build/cjs/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/cjs/components/TooltipMenu/TooltipMenu.js +0 -76
- package/build/es/components/ButtonRound/ButtonRound.d.ts +0 -10
- package/build/es/components/ButtonRound/ButtonRound.js +0 -29
- package/build/es/components/Icons/index.js +0 -109
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/BusinessMenu.js +0 -51
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/DesktopMenu.js +0 -251
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.d.ts +0 -10
- package/build/es/components/MainNavigation/ChildComponents/HeaderNavigationElements.js +0 -159
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.d.ts +0 -4
- package/build/es/components/MainNavigation/ChildComponents/LanguageSelector.js +0 -30
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.d.ts +0 -9
- package/build/es/components/MainNavigation/ChildComponents/LinkModifier.js +0 -29
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/LoginTooltip.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.d.ts +0 -24
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenu.js +0 -96
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +0 -57
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.d.ts +0 -7
- package/build/es/components/MainNavigation/ChildComponents/MinicartTooltip.js +0 -18
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.d.ts +0 -3
- package/build/es/components/MainNavigation/ChildComponents/MobileMenu.js +0 -185
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.d.ts +0 -6
- package/build/es/components/MainNavigation/ChildComponents/PageSearch.js +0 -15
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.d.ts +0 -13
- package/build/es/components/MainNavigation/ChildComponents/Ribbon.js +0 -66
- package/build/es/components/MainNavigation/MainNavigation.d.ts +0 -38
- package/build/es/components/MainNavigation/MainNavigation.js +0 -311
- package/build/es/components/MainNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/es/components/MainNavigation/context/MobileMenuContext.js +0 -7
- package/build/es/components/MainNavigation/context/NavContext.d.ts +0 -29
- package/build/es/components/MainNavigation/context/NavContext.js +0 -42
- package/build/es/components/MainNavigation/globalNavStyles.d.ts +0 -13
- package/build/es/components/MainNavigation/globalNavStyles.js +0 -89
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.d.ts +0 -90
- package/build/es/components/SecondaryNavigation/SecondaryNavigation.js +0 -199
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.d.ts +0 -10
- package/build/es/components/TooltipMenu/ChildComponents/TooltipMenuExportedStyles.js +0 -31
- package/build/es/components/TooltipMenu/TooltipMenu.d.ts +0 -45
- package/build/es/components/TooltipMenu/TooltipMenu.js +0 -68
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var icons = require('@dnanpm/icons');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var reactSpring = require('react-spring');
|
|
8
|
-
var styledComponents = require('styled-components');
|
|
9
|
-
var theme = require('../../../themes/theme.js');
|
|
10
|
-
var navigation = require('../../../themes/themeComponents/navigation.js');
|
|
11
|
-
var styledUtils = require('../../../utils/styledUtils.js');
|
|
12
|
-
var Icon = require('../../Icon/Icon.js');
|
|
13
|
-
var MobileMenuContext = require('../context/MobileMenuContext.js');
|
|
14
|
-
var NavContext = require('../context/NavContext.js');
|
|
15
|
-
var globalNavStyles = require('../globalNavStyles.js');
|
|
16
|
-
var BusinessMenu = require('./BusinessMenu.js');
|
|
17
|
-
var LinkModifier = require('./LinkModifier.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
|
-
|
|
21
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
|
-
|
|
23
|
-
const MobileMenuWrapper = styledComponents.styled.div `
|
|
24
|
-
width: ${100 * navigation.menuLevelsAmount}%;
|
|
25
|
-
`;
|
|
26
|
-
const mobileMenuWithRibbon = `calc(100vh - ${navigation.mobileNavMaxHeight} - ${navigation.ribbonHeight})`;
|
|
27
|
-
const mobileMenuNoRibbon = `calc(100vh - ${navigation.mobileNavMaxHeight})`;
|
|
28
|
-
const MobileMenuContainer = styledComponents.styled.div `
|
|
29
|
-
width: 100%;
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: ${navigation.mobileNavMaxHeight};
|
|
32
|
-
left: 0;
|
|
33
|
-
overflow: hidden;
|
|
34
|
-
overflow-y: auto;
|
|
35
|
-
transition: max-height 0.2s ease-in-out;
|
|
36
|
-
background: ${theme.default.color.background.white.default};
|
|
37
|
-
max-height: ${mobileMenuNoRibbon};
|
|
38
|
-
height: ${mobileMenuNoRibbon};
|
|
39
|
-
${styledUtils.media.md `
|
|
40
|
-
top: calc(${navigation.mobileNavMaxHeight} + ${navigation.ribbonHeight});
|
|
41
|
-
max-height: ${mobileMenuWithRibbon};
|
|
42
|
-
height: ${mobileMenuWithRibbon};
|
|
43
|
-
`};
|
|
44
|
-
`;
|
|
45
|
-
const MenuLinkBackLink = styledComponents.styled(globalNavStyles.MenuLink) ``;
|
|
46
|
-
const MobileMenu = styledComponents.styled.div `
|
|
47
|
-
background: ${theme.default.color.background.white.default};
|
|
48
|
-
${globalNavStyles.MenuList} {
|
|
49
|
-
display: block;
|
|
50
|
-
float: left;
|
|
51
|
-
width: ${100 / navigation.menuLevelsAmount}%;
|
|
52
|
-
position: relative;
|
|
53
|
-
min-height: ${mobileMenuNoRibbon};
|
|
54
|
-
${styledUtils.media.md `
|
|
55
|
-
min-height: ${mobileMenuWithRibbon};
|
|
56
|
-
`};
|
|
57
|
-
&:first-of-type {
|
|
58
|
-
background: ${theme.default.color.background.white.default};
|
|
59
|
-
> ${globalNavStyles.MenuItem} > ${globalNavStyles.MenuLink} {
|
|
60
|
-
font-weight: ${theme.default.fontWeight.medium};
|
|
61
|
-
border-bottom: 1px solid ${theme.default.color.line.L04};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
&:not(:first-of-type) {
|
|
65
|
-
background: ${theme.default.color.background.sand.default};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
${globalNavStyles.MenuItem} {
|
|
69
|
-
display: block;
|
|
70
|
-
&:last-of-type {
|
|
71
|
-
margin-bottom: 2rem;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
${globalNavStyles.MenuLink}, ${globalNavStyles.MenuLinkWithChildren} {
|
|
76
|
-
line-height: ${theme.default.lineHeight.default};
|
|
77
|
-
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 1.75)}
|
|
78
|
-
${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.5)}
|
|
79
|
-
${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 1.75)}
|
|
80
|
-
${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 2)};
|
|
81
|
-
font-size: ${theme.default.fontSize.default};
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-grow: 1;
|
|
84
|
-
align-items: center;
|
|
85
|
-
justify-content: space-between;
|
|
86
|
-
}
|
|
87
|
-
${MenuLinkBackLink} {
|
|
88
|
-
font-weight: ${theme.default.fontWeight.medium};
|
|
89
|
-
background: ${theme.default.color.background.white.default};
|
|
90
|
-
color: ${theme.default.color.text.pink};
|
|
91
|
-
justify-content: flex-start;
|
|
92
|
-
span.dnasg-icon {
|
|
93
|
-
margin-right: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 4)};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
${globalNavStyles.MenuLink}:hover {
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
100
|
-
const MenuItemBackLink = ({ currentLevel }) => {
|
|
101
|
-
const { handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = React.useContext(NavContext.default);
|
|
102
|
-
const levels = {
|
|
103
|
-
level1Items,
|
|
104
|
-
level2Items,
|
|
105
|
-
};
|
|
106
|
-
const menuElementLevel = `level${currentLevel - 1}Items`;
|
|
107
|
-
const menuElements = levels[menuElementLevel];
|
|
108
|
-
const mobileMenuBackClick = (e) => {
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
handleNavMenuClick(null, `level${currentLevel - 1}Mobile`);
|
|
111
|
-
};
|
|
112
|
-
const tabNavigationDisabled = scrollPosition !== currentLevel - 1;
|
|
113
|
-
const backLink = getBackLink(menuElements, currentLevel - 1);
|
|
114
|
-
return (React__default.default.createElement(globalNavStyles.MenuItem, { key: `back-${backLink.id}`, "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
115
|
-
React__default.default.createElement(MenuLinkBackLink, { role: "menuitem", as: "button", onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
116
|
-
React__default.default.createElement(Icon.default, { icon: icons.ChevronLeft, size: "1rem" }),
|
|
117
|
-
backLink.titles[lang])));
|
|
118
|
-
};
|
|
119
|
-
const CreateSubMenuItem = ({ menuItem, currentLevel, itemIndex }) => {
|
|
120
|
-
var _a;
|
|
121
|
-
const { handleNavMenuClick, menuLevel: { scrollPosition }, lang, currentUrl, } = React.useContext(NavContext.default);
|
|
122
|
-
const { mobileMenuRef } = React.useContext(MobileMenuContext.default);
|
|
123
|
-
const hasChildren = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.pages) === null || _a === void 0 ? void 0 : _a.length;
|
|
124
|
-
const indexLevel = currentLevel - 1;
|
|
125
|
-
const tabNavigationDisabled = () => scrollPosition !== indexLevel;
|
|
126
|
-
const menuUrl = menuItem.urls[lang] || '';
|
|
127
|
-
const mobileMenuClick = (element) => (e) => {
|
|
128
|
-
var _a;
|
|
129
|
-
if (typeof ((_a = mobileMenuRef === null || mobileMenuRef === void 0 ? void 0 : mobileMenuRef.current) === null || _a === void 0 ? void 0 : _a.scroll) === 'function') {
|
|
130
|
-
mobileMenuRef.current.scroll({
|
|
131
|
-
top: 0,
|
|
132
|
-
left: 0,
|
|
133
|
-
behavior: 'smooth',
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
e.preventDefault();
|
|
137
|
-
handleNavMenuClick(element.id, `level${currentLevel}Mobile`);
|
|
138
|
-
};
|
|
139
|
-
if (hasChildren && currentLevel < 3) {
|
|
140
|
-
return (React__default.default.createElement(globalNavStyles.MenuItem, { key: menuItem.id, "aria-haspopup": "true", "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, isActive: LinkModifier.isSelected(currentUrl, menuUrl) },
|
|
141
|
-
React__default.default.createElement(globalNavStyles.MenuLink, { as: "button", onClick: mobileMenuClick(menuItem), role: "menuitem", tabIndex: tabNavigationDisabled() ? -1 : undefined },
|
|
142
|
-
menuItem.titles[lang],
|
|
143
|
-
React__default.default.createElement(Icon.default, { icon: icons.ChevronRight, size: "1rem" }))));
|
|
144
|
-
}
|
|
145
|
-
return (React__default.default.createElement(globalNavStyles.MenuItem, { key: menuItem.id, role: "menuitem", "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, isActive: LinkModifier.isSelected(currentUrl, menuUrl, true) },
|
|
146
|
-
React__default.default.createElement(LinkModifier.default, { menuItem: menuItem, tabIndex: tabNavigationDisabled() })));
|
|
147
|
-
};
|
|
148
|
-
const SubMenuMobile = ({ currentLevel, menuItem }) => {
|
|
149
|
-
const navElements = menuItem.pages;
|
|
150
|
-
if (!navElements.length) {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
154
|
-
currentLevel > 1 && React__default.default.createElement(MenuItemBackLink, { currentLevel: currentLevel }),
|
|
155
|
-
navElements.map((subMenuItem, index) => (React__default.default.createElement(CreateSubMenuItem, { menuItem: subMenuItem, currentLevel: currentLevel, key: subMenuItem.id, itemIndex: index })))));
|
|
156
|
-
};
|
|
157
|
-
const NavigationMenuMobile = () => {
|
|
158
|
-
const { items, menuLevel, level1Items, level2Items } = React.useContext(NavContext.default);
|
|
159
|
-
const { mainNavigation } = items;
|
|
160
|
-
if (!(mainNavigation === null || mainNavigation === void 0 ? void 0 : mainNavigation.pages.length)) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
164
|
-
React__default.default.createElement(globalNavStyles.MenuList, { role: "menu", "aria-hidden": menuLevel.scrollPosition !== 0, "aria-disabled": menuLevel.scrollPosition !== 0, "data-testid": "mobile-nav-menu-level-1", isInView: menuLevel.scrollPosition === 0 },
|
|
165
|
-
React__default.default.createElement(SubMenuMobile, { currentLevel: 1, menuItem: mainNavigation }),
|
|
166
|
-
React__default.default.createElement(globalNavStyles.MenuItem, { key: "business-item", "aria-hidden": menuLevel.scrollPosition !== 0, role: "menuitem" },
|
|
167
|
-
React__default.default.createElement(BusinessMenu.default, null))),
|
|
168
|
-
menuLevel.level1Mobile !== null && (React__default.default.createElement(globalNavStyles.MenuList, { role: "menu", "aria-hidden": menuLevel.scrollPosition !== 1, "aria-disabled": menuLevel.scrollPosition !== 1, "data-testid": "mobile-nav-menu-level-2", isInView: menuLevel.scrollPosition === 1 },
|
|
169
|
-
React__default.default.createElement(SubMenuMobile, { currentLevel: 2, menuItem: level1Items[menuLevel.level1Mobile] }))),
|
|
170
|
-
menuLevel.level2Mobile !== null && (React__default.default.createElement(globalNavStyles.MenuList, { role: "menu", "aria-hidden": menuLevel.scrollPosition !== 2, "aria-disabled": menuLevel.scrollPosition !== 2, "data-testid": "mobile-nav-menu-level-3", isInView: menuLevel.scrollPosition === 2 },
|
|
171
|
-
React__default.default.createElement(SubMenuMobile, { currentLevel: 3, menuItem: level2Items[menuLevel.level2Mobile] })))));
|
|
172
|
-
};
|
|
173
|
-
const RenderMobileMenu = () => {
|
|
174
|
-
const { menuLevel, isMobileMenuOpen } = React.useContext(NavContext.default);
|
|
175
|
-
const mobileMenuRef = React.useRef(null);
|
|
176
|
-
const slidingMenuAnimation = reactSpring.useSpring({
|
|
177
|
-
transform: `translateX(${(menuLevel.scrollPosition / navigation.menuLevelsAmount) * -100}%)`,
|
|
178
|
-
});
|
|
179
|
-
const mobileMenuContext = React.useMemo(() => ({
|
|
180
|
-
mobileMenuRef,
|
|
181
|
-
}), [mobileMenuRef]);
|
|
182
|
-
if (!isMobileMenuOpen) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
return (React__default.default.createElement(MobileMenuContainer, { ref: mobileMenuRef },
|
|
186
|
-
React__default.default.createElement(MobileMenuContext.default.Provider, { value: mobileMenuContext },
|
|
187
|
-
React__default.default.createElement(MobileMenu, null,
|
|
188
|
-
React__default.default.createElement(MobileMenuWrapper, null,
|
|
189
|
-
React__default.default.createElement(reactSpring.animated.div, { style: slidingMenuAnimation },
|
|
190
|
-
React__default.default.createElement(NavigationMenuMobile, null)))))));
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
exports.default = RenderMobileMenu;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var icons = require('@dnanpm/icons');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var Icon = require('../../Icon/Icon.js');
|
|
8
|
-
var NavContext = require('../context/NavContext.js');
|
|
9
|
-
var MainNavTooltipMenu = require('./MainNavTooltipMenu.js');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
|
-
|
|
15
|
-
const PageSearch = ({ searchLabel }) => {
|
|
16
|
-
const globalStateString = 'search';
|
|
17
|
-
const { navZIndex, searchComponent: SearchComponent } = React.useContext(NavContext.default);
|
|
18
|
-
return (React__default.default.createElement(MainNavTooltipMenu.default, { zIndex: navZIndex + 1, tooltipRight: "0", contentComponent: SearchComponent, contentWidth: "100%", globalStateString: globalStateString, fullWidthDesktop: true, closeWhenTagClicked: ['a'] },
|
|
19
|
-
React__default.default.createElement(Icon.default, { icon: icons.Search, size: "2rem" }),
|
|
20
|
-
React__default.default.createElement("span", null, searchLabel)));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.default = PageSearch;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { LangProps } from '../../../types/language';
|
|
3
|
-
export interface RibbonDataProps {
|
|
4
|
-
ribbonLink: LangProps;
|
|
5
|
-
ribbonIcon: string;
|
|
6
|
-
ribbonTexts: LangProps;
|
|
7
|
-
}
|
|
8
|
-
interface Props {
|
|
9
|
-
ribbonData: RibbonDataProps[];
|
|
10
|
-
lang?: string;
|
|
11
|
-
}
|
|
12
|
-
declare const Ribbon: ({ ribbonData, lang }: Props) => React.JSX.Element;
|
|
13
|
-
export default Ribbon;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var styledComponents = require('styled-components');
|
|
7
|
-
var theme = require('../../../themes/theme.js');
|
|
8
|
-
var navigation = require('../../../themes/themeComponents/navigation.js');
|
|
9
|
-
var styledUtils = require('../../../utils/styledUtils.js');
|
|
10
|
-
var Icon = require('../../Icon/Icon.js');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
|
-
|
|
16
|
-
const RibbonContainer = styledComponents.styled.div `
|
|
17
|
-
display: none;
|
|
18
|
-
${styledUtils.media.md `
|
|
19
|
-
background: ${theme.default.color.background.sand.E01};
|
|
20
|
-
display: block;
|
|
21
|
-
`};
|
|
22
|
-
`;
|
|
23
|
-
const RibbonItems = styledComponents.styled.div `
|
|
24
|
-
max-width: 1290px;
|
|
25
|
-
height: ${navigation.ribbonHeight};
|
|
26
|
-
padding: 0 ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2)};
|
|
27
|
-
margin: 0 auto;
|
|
28
|
-
display: flex;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
align-items: center;
|
|
31
|
-
`;
|
|
32
|
-
const RibbonColumn = styledComponents.styled.div `
|
|
33
|
-
flex: 1 1 auto;
|
|
34
|
-
display: flex;
|
|
35
|
-
justify-content: center;
|
|
36
|
-
align-items: center;
|
|
37
|
-
color: ${theme.default.color.text.gray};
|
|
38
|
-
font-size: ${theme.default.fontSize.xs};
|
|
39
|
-
border-right: 2px solid ${theme.default.color.line.L03};
|
|
40
|
-
&:last-of-type {
|
|
41
|
-
border: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
span.dnasg-icon {
|
|
45
|
-
margin-right: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 0.5)};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
a {
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
color: ${theme.default.color.text.gray};
|
|
52
|
-
&:hover,
|
|
53
|
-
&:focus,
|
|
54
|
-
&:active {
|
|
55
|
-
text-decoration: none;
|
|
56
|
-
color: ${theme.default.color.text.pink};
|
|
57
|
-
border: none;
|
|
58
|
-
outline: none;
|
|
59
|
-
}
|
|
60
|
-
&:focus {
|
|
61
|
-
text-decoration: underline;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
const Ribbon = ({ ribbonData, lang = 'fi' }) => (React__default.default.createElement(RibbonContainer, null,
|
|
66
|
-
React__default.default.createElement(RibbonItems, null, ribbonData.map(ribbon => (React__default.default.createElement(RibbonColumn, { key: `ribbon-${ribbon.ribbonIcon}` },
|
|
67
|
-
ribbon.ribbonLink[lang] && (React__default.default.createElement("a", { href: ribbon.ribbonLink[lang] },
|
|
68
|
-
React__default.default.createElement(Icon.default, { name: ribbon.ribbonIcon, size: "1rem" }),
|
|
69
|
-
React__default.default.createElement("span", null, ribbon.ribbonTexts[lang]))),
|
|
70
|
-
!ribbon.ribbonLink[lang] && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
71
|
-
React__default.default.createElement(Icon.default, { name: ribbon.ribbonIcon, size: "1rem" }),
|
|
72
|
-
React__default.default.createElement("span", null, ribbon.ribbonTexts[lang])))))))));
|
|
73
|
-
|
|
74
|
-
exports.default = Ribbon;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { RibbonDataProps } from './ChildComponents/Ribbon';
|
|
4
|
-
import type { GlobalNavItems } from './types/globalNavProps';
|
|
5
|
-
export interface MainNavigationProps {
|
|
6
|
-
/** Allows to pass a custom className */
|
|
7
|
-
className?: string;
|
|
8
|
-
items?: GlobalNavItems;
|
|
9
|
-
language?: string;
|
|
10
|
-
zIndex?: number;
|
|
11
|
-
search?: boolean;
|
|
12
|
-
searchText?: string;
|
|
13
|
-
searchComponent?: ReactNode | boolean;
|
|
14
|
-
minicart?: boolean;
|
|
15
|
-
minicartText?: string;
|
|
16
|
-
minicartAmount?: number;
|
|
17
|
-
minicartComponent?: ReactNode | boolean;
|
|
18
|
-
showMinicart?: boolean;
|
|
19
|
-
showLoginTooltip?: boolean;
|
|
20
|
-
login?: boolean;
|
|
21
|
-
loginText?: string;
|
|
22
|
-
loginComponent?: ReactNode | boolean;
|
|
23
|
-
isLoggedIn?: boolean;
|
|
24
|
-
collapseSize?: number;
|
|
25
|
-
languageSelector?: boolean;
|
|
26
|
-
nextJSLinkComponent: ReactNode | boolean;
|
|
27
|
-
ribbon?: boolean;
|
|
28
|
-
ribbonData?: RibbonDataProps[];
|
|
29
|
-
currentUrl?: string;
|
|
30
|
-
notificationText?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @visibleName Main Navigation
|
|
34
|
-
* @deprecated Use `MainHeaderNavigation` component
|
|
35
|
-
*/
|
|
36
|
-
declare const MainNavigation: ({ items, language, zIndex, languageSelector, search, searchText, searchComponent, minicart, minicartText, minicartComponent, minicartAmount, showMinicart, showLoginTooltip, login, loginText, loginComponent, isLoggedIn, collapseSize, nextJSLinkComponent, ribbon, ribbonData, className, currentUrl, notificationText, }: MainNavigationProps) => React.JSX.Element;
|
|
37
|
-
/** @component */
|
|
38
|
-
export default MainNavigation;
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var ramda = require('ramda');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var useScrollPosition = require('../../hooks/useScrollPosition.js');
|
|
8
|
-
var useWindowSize = require('../../hooks/useWindowSize.js');
|
|
9
|
-
var styledComponents = require('styled-components');
|
|
10
|
-
var theme = require('../../themes/theme.js');
|
|
11
|
-
var navigation = require('../../themes/themeComponents/navigation.js');
|
|
12
|
-
var styledUtils = require('../../utils/styledUtils.js');
|
|
13
|
-
var Notification = require('../Notification/Notification.js');
|
|
14
|
-
var HeaderNavigationElements = require('./ChildComponents/HeaderNavigationElements.js');
|
|
15
|
-
var MobileMenu = require('./ChildComponents/MobileMenu.js');
|
|
16
|
-
var Ribbon = require('./ChildComponents/Ribbon.js');
|
|
17
|
-
var NavContext = require('./context/NavContext.js');
|
|
18
|
-
|
|
19
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
20
|
-
|
|
21
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
22
|
-
|
|
23
|
-
const GlobalStyle = styledComponents.createGlobalStyle `
|
|
24
|
-
body.overflow-hidden {
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
// detect common touch screen devices
|
|
29
|
-
const isIosDevice = () => {
|
|
30
|
-
const validate = /iPad|iPhone|iPod|iPad Simulator|iPhone Simulator/i;
|
|
31
|
-
if (typeof navigator !== 'undefined' && typeof window !== 'undefined') {
|
|
32
|
-
return (validate.test(navigator.userAgent) &&
|
|
33
|
-
!window.MSStream);
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
const iosDevice = isIosDevice();
|
|
38
|
-
const fadeIn = styledComponents.keyframes `
|
|
39
|
-
0% {
|
|
40
|
-
opacity: 0;
|
|
41
|
-
transform: translateY(-5px);
|
|
42
|
-
}
|
|
43
|
-
5% {
|
|
44
|
-
opacity: 0;
|
|
45
|
-
transform: translateY(-5px);
|
|
46
|
-
}
|
|
47
|
-
100% {
|
|
48
|
-
opacity: 1;
|
|
49
|
-
transform: translateY(0px);
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
const preventBodyScroll = () => {
|
|
53
|
-
const { scrollY } = window;
|
|
54
|
-
document.body.style.position = 'fixed';
|
|
55
|
-
document.body.style.top = `-${scrollY}px`;
|
|
56
|
-
};
|
|
57
|
-
const resumeBodyScroll = () => {
|
|
58
|
-
const scrollY = document.body.style.top;
|
|
59
|
-
document.body.style.position = '';
|
|
60
|
-
document.body.style.top = '';
|
|
61
|
-
// if the call to close overlay is done multiple times, scroll only the first time
|
|
62
|
-
if (scrollY) {
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
window.scrollTo(0, parseInt(scrollY, 10) * -1);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const PageOverlay = styledComponents.styled.div `
|
|
69
|
-
position: fixed;
|
|
70
|
-
animation: ${fadeIn} 0.2s ease-in-out;
|
|
71
|
-
top: 0;
|
|
72
|
-
left: 0;
|
|
73
|
-
width: 100%;
|
|
74
|
-
height: 100%;
|
|
75
|
-
background: ${theme.default.color.background.plum.default + theme.default.color.transparency.T10};
|
|
76
|
-
z-index: ${({ $navZIndex }) => $navZIndex - 1};
|
|
77
|
-
`;
|
|
78
|
-
const scrollThreshold = 82;
|
|
79
|
-
const checkThreshold = (prevPos, currPos) => {
|
|
80
|
-
if (prevPos >= currPos) {
|
|
81
|
-
return prevPos - currPos > scrollThreshold;
|
|
82
|
-
}
|
|
83
|
-
return currPos - prevPos > scrollThreshold;
|
|
84
|
-
};
|
|
85
|
-
const GlobalNavigationContainer = styledComponents.styled.nav `
|
|
86
|
-
z-index: ${({ $navZIndex }) => $navZIndex};
|
|
87
|
-
position: relative;
|
|
88
|
-
position: sticky;
|
|
89
|
-
display: block;
|
|
90
|
-
top: 0;
|
|
91
|
-
left: 0;
|
|
92
|
-
width: 100%;
|
|
93
|
-
background-color: ${theme.default.color.background.white.default};
|
|
94
|
-
color: ${theme.default.color.text.black};
|
|
95
|
-
top: ${({ $menuLevel, $tooltipMenuActive }) => ($menuLevel === null || $menuLevel === void 0 ? void 0 : $menuLevel.hideOnScroll) && !($menuLevel === null || $menuLevel === void 0 ? void 0 : $menuLevel.level1) && !$tooltipMenuActive
|
|
96
|
-
? `calc(-${navigation.desktopNavMaxHeight} - ${navigation.ribbonHeight})`
|
|
97
|
-
: '0px'} !important;
|
|
98
|
-
transition: top 0.2s ease-in-out;
|
|
99
|
-
box-sizing: border-box;
|
|
100
|
-
`;
|
|
101
|
-
const NavigationWrapper = styledComponents.styled.div `
|
|
102
|
-
display: flex;
|
|
103
|
-
width: 100%;
|
|
104
|
-
max-width: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 256)};
|
|
105
|
-
margin: 0 auto;
|
|
106
|
-
height: ${navigation.mobileNavMaxHeight};
|
|
107
|
-
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
108
|
-
height: ${navigation.desktopNavMaxHeight};
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
let previousValue = false;
|
|
112
|
-
const isStickySupported = typeof CSS !== 'undefined' &&
|
|
113
|
-
typeof CSS.supports !== 'undefined' &&
|
|
114
|
-
(CSS.supports('position', 'sticky') || CSS.supports('position', '-webkit-sticky'));
|
|
115
|
-
const initiateScrollToHeader = (componentRef) => {
|
|
116
|
-
if ((componentRef === null || componentRef === void 0 ? void 0 : componentRef.current) && isStickySupported && typeof window !== 'undefined') {
|
|
117
|
-
window.scrollTo({ top: componentRef.current.offsetTop, left: 0 });
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* @visibleName Main Navigation
|
|
122
|
-
* @deprecated Use `MainHeaderNavigation` component
|
|
123
|
-
*/
|
|
124
|
-
const MainNavigation = ({ items = {}, language = 'fi', zIndex = 1030, languageSelector = false, search = true, searchText = 'Haku', searchComponent = false, minicart = true, minicartText = 'Ostoskori', minicartComponent = false, minicartAmount = 0, showMinicart = false, showLoginTooltip = false, login = true, loginText = 'Kirjaudu', loginComponent, isLoggedIn = false, collapseSize = 767, nextJSLinkComponent = false, ribbon = true, ribbonData, className, currentUrl = '', notificationText = '', }) => {
|
|
125
|
-
const { isMobile } = useWindowSize.default(collapseSize);
|
|
126
|
-
const props = {
|
|
127
|
-
items,
|
|
128
|
-
language,
|
|
129
|
-
zIndex,
|
|
130
|
-
search,
|
|
131
|
-
searchText,
|
|
132
|
-
minicart,
|
|
133
|
-
minicartText,
|
|
134
|
-
minicartComponent,
|
|
135
|
-
minicartAmount,
|
|
136
|
-
showMinicart,
|
|
137
|
-
showLoginTooltip,
|
|
138
|
-
login,
|
|
139
|
-
loginText,
|
|
140
|
-
loginComponent,
|
|
141
|
-
isLoggedIn,
|
|
142
|
-
searchComponent,
|
|
143
|
-
collapseSize,
|
|
144
|
-
languageSelector,
|
|
145
|
-
nextJSLinkComponent,
|
|
146
|
-
ribbonData,
|
|
147
|
-
notificationText,
|
|
148
|
-
};
|
|
149
|
-
const navigationEl = React.useRef(null);
|
|
150
|
-
const key = ramda.prop('id');
|
|
151
|
-
// Index & memoize menu levels
|
|
152
|
-
const level1 = React.useMemo(() => { var _a, _b; return (_b = (_a = items.mainNavigation) === null || _a === void 0 ? void 0 : _a.pages) !== null && _b !== void 0 ? _b : []; }, [items.mainNavigation]);
|
|
153
|
-
const level1Items = React.useMemo(() => ramda.indexBy(key, level1), [level1, key]);
|
|
154
|
-
const level2 = React.useMemo(() => level1.map(item => ramda.indexBy(key, item.pages)), [level1, key]);
|
|
155
|
-
const level2Items = Object.assign({}, ...level2);
|
|
156
|
-
// All states to for handling menus
|
|
157
|
-
const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false);
|
|
158
|
-
const [menuLevel, setMenuLevel] = React.useState({
|
|
159
|
-
level1: null,
|
|
160
|
-
animate1: true,
|
|
161
|
-
level2: null,
|
|
162
|
-
animate2: true,
|
|
163
|
-
level1Mobile: null,
|
|
164
|
-
level2Mobile: null,
|
|
165
|
-
scrollPosition: 0,
|
|
166
|
-
hideOnScroll: false,
|
|
167
|
-
});
|
|
168
|
-
const [lang] = React.useState(language);
|
|
169
|
-
// As scroll position cannot be always retained, close mobile menu when orientation changes
|
|
170
|
-
const initRotation = () => {
|
|
171
|
-
setIsMobileMenuOpen(false);
|
|
172
|
-
};
|
|
173
|
-
React.useEffect(() => {
|
|
174
|
-
if (iosDevice && isMobileMenuOpen) {
|
|
175
|
-
window.addEventListener('orientationchange', initRotation, false);
|
|
176
|
-
preventBodyScroll();
|
|
177
|
-
}
|
|
178
|
-
if (iosDevice && !isMobileMenuOpen) {
|
|
179
|
-
window.removeEventListener('orientationchange', initRotation, false);
|
|
180
|
-
resumeBodyScroll();
|
|
181
|
-
}
|
|
182
|
-
return () => {
|
|
183
|
-
window.removeEventListener('orientationchange', initRotation, false);
|
|
184
|
-
resumeBodyScroll();
|
|
185
|
-
};
|
|
186
|
-
}, [isMobileMenuOpen]);
|
|
187
|
-
const [tooltipItems, setTooltipItems] = React.useState(React.useMemo(() => ({
|
|
188
|
-
minicart: false,
|
|
189
|
-
login: false,
|
|
190
|
-
search: false,
|
|
191
|
-
}), []));
|
|
192
|
-
const tooltipMenuActive = tooltipItems.minicart || tooltipItems.login || tooltipItems.search;
|
|
193
|
-
const freezeOverflow = isMobileMenuOpen || (tooltipMenuActive && isMobile);
|
|
194
|
-
const isPageOverlay = tooltipMenuActive || menuLevel.level1 || menuLevel.level2;
|
|
195
|
-
React.useEffect(() => {
|
|
196
|
-
const bodyClasses = ['overflow-shown', 'overflow-hidden'];
|
|
197
|
-
document.body.classList.remove(...bodyClasses);
|
|
198
|
-
document.body.classList.add(bodyClasses[Number(Boolean(freezeOverflow))]);
|
|
199
|
-
}, [freezeOverflow]);
|
|
200
|
-
const navigationContext = React.useMemo(() => {
|
|
201
|
-
const handleNavMenuClick = (newValue, updatedLevel) => {
|
|
202
|
-
let clickedItself = false;
|
|
203
|
-
switch (updatedLevel) {
|
|
204
|
-
case 'level1':
|
|
205
|
-
clickedItself = newValue === menuLevel.level1;
|
|
206
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level1: !clickedItself ? newValue : null, animate1: !clickedItself, level2: null, animate2: true }));
|
|
207
|
-
break;
|
|
208
|
-
case 'level2':
|
|
209
|
-
clickedItself = newValue === menuLevel.level2;
|
|
210
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level2: newValue !== menuLevel.level2 ? newValue : null, animate1: false, animate2: !clickedItself }));
|
|
211
|
-
break;
|
|
212
|
-
case 'level1Mobile':
|
|
213
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level1Mobile: newValue || menuLevel.level1Mobile, scrollPosition: newValue ? 1 : 0 }));
|
|
214
|
-
break;
|
|
215
|
-
case 'level2Mobile':
|
|
216
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { level2Mobile: newValue || menuLevel.level2Mobile, scrollPosition: newValue ? 2 : 1 }));
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const resetMenuEvents = () => {
|
|
221
|
-
setMenuLevel({
|
|
222
|
-
level2: null,
|
|
223
|
-
animate2: true,
|
|
224
|
-
level1: null,
|
|
225
|
-
animate1: true,
|
|
226
|
-
level1Mobile: null,
|
|
227
|
-
level2Mobile: null,
|
|
228
|
-
scrollPosition: 0,
|
|
229
|
-
hideOnScroll: false,
|
|
230
|
-
});
|
|
231
|
-
if (isMobileMenuOpen) {
|
|
232
|
-
setIsMobileMenuOpen(false);
|
|
233
|
-
}
|
|
234
|
-
setTooltipItems({
|
|
235
|
-
minicart: false,
|
|
236
|
-
login: false,
|
|
237
|
-
search: false,
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
const handleToggleClick = () => {
|
|
241
|
-
resetMenuEvents();
|
|
242
|
-
initiateScrollToHeader(navigationEl);
|
|
243
|
-
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
244
|
-
};
|
|
245
|
-
const getBackLink = (menuElements, i) => {
|
|
246
|
-
const idValue = menuLevel[`level${i}Mobile`];
|
|
247
|
-
return menuElements[idValue];
|
|
248
|
-
};
|
|
249
|
-
// Resets menu states when menu content alters between mobile and desktop
|
|
250
|
-
const menuChanged = previousValue !== isMobile;
|
|
251
|
-
if (menuChanged) {
|
|
252
|
-
resetMenuEvents();
|
|
253
|
-
previousValue = isMobile;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
lang,
|
|
257
|
-
navZIndex: zIndex,
|
|
258
|
-
menuLevel,
|
|
259
|
-
handleNavMenuClick,
|
|
260
|
-
getBackLink,
|
|
261
|
-
isMobileMenu: isMobile,
|
|
262
|
-
items,
|
|
263
|
-
level1Items,
|
|
264
|
-
level2Items,
|
|
265
|
-
resetMenuEvents,
|
|
266
|
-
handleToggleClick,
|
|
267
|
-
isMobileMenuOpen,
|
|
268
|
-
nextJSLinkComponent,
|
|
269
|
-
loginComponent,
|
|
270
|
-
isLoggedIn,
|
|
271
|
-
collapseSize,
|
|
272
|
-
tooltipItems,
|
|
273
|
-
setTooltipItems,
|
|
274
|
-
minicartComponent,
|
|
275
|
-
showMinicart,
|
|
276
|
-
showLoginTooltip,
|
|
277
|
-
searchComponent,
|
|
278
|
-
currentUrl,
|
|
279
|
-
};
|
|
280
|
-
}, [
|
|
281
|
-
isMobile,
|
|
282
|
-
lang,
|
|
283
|
-
zIndex,
|
|
284
|
-
menuLevel,
|
|
285
|
-
items,
|
|
286
|
-
level1Items,
|
|
287
|
-
level2Items,
|
|
288
|
-
isMobileMenuOpen,
|
|
289
|
-
nextJSLinkComponent,
|
|
290
|
-
loginComponent,
|
|
291
|
-
isLoggedIn,
|
|
292
|
-
collapseSize,
|
|
293
|
-
tooltipItems,
|
|
294
|
-
minicartComponent,
|
|
295
|
-
showMinicart,
|
|
296
|
-
showLoginTooltip,
|
|
297
|
-
searchComponent,
|
|
298
|
-
currentUrl,
|
|
299
|
-
]);
|
|
300
|
-
useScrollPosition.default(({ prevPos, currPos }) => {
|
|
301
|
-
const overThreshold = checkThreshold(prevPos.y, currPos.y);
|
|
302
|
-
const isShow = currPos.y < prevPos.y;
|
|
303
|
-
if (isShow !== menuLevel.hideOnScroll && overThreshold && !menuLevel.level1) {
|
|
304
|
-
setMenuLevel(Object.assign(Object.assign({}, menuLevel), { animate1: false, animate2: false, hideOnScroll: isShow }));
|
|
305
|
-
}
|
|
306
|
-
}, undefined, false, 200);
|
|
307
|
-
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
308
|
-
isPageOverlay && React__default.default.createElement(PageOverlay, { "data-testid": "navigation-overlay", "$navZIndex": zIndex }),
|
|
309
|
-
React__default.default.createElement(GlobalNavigationContainer, { className: className, ref: navigationEl, "$collapseSize": collapseSize, "$menuLevel": menuLevel, "$navZIndex": zIndex, "$tooltipMenuActive": tooltipMenuActive, "data-testid": "main-navigation" },
|
|
310
|
-
React__default.default.createElement(NavContext.default.Provider, { value: navigationContext },
|
|
311
|
-
React__default.default.createElement(GlobalStyle, null),
|
|
312
|
-
!items.mainNavigation && notificationText && (React__default.default.createElement(Notification.default, { type: "info" }, notificationText)),
|
|
313
|
-
ribbon && ribbonData && React__default.default.createElement(Ribbon.default, { ribbonData: ribbonData, lang: language }),
|
|
314
|
-
React__default.default.createElement(NavigationWrapper, { "$collapseSize": collapseSize },
|
|
315
|
-
React__default.default.createElement(HeaderNavigationElements.default, { navElementProps: props }),
|
|
316
|
-
isMobile && React__default.default.createElement(MobileMenu.default, null))))));
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
exports.default = MainNavigation;
|