@dnanpm/styleguide 3.11.0 → 3.11.1
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/DateTimePicker/DateTimePicker.d.ts +16 -0
- package/build/cjs/components/DateTimePicker/DateTimePicker.js +52 -12
- package/build/cjs/components/Footer/Components/FooterComponents.js +7 -21
- package/build/cjs/components/Input/Input.d.ts +1 -1
- package/build/cjs/components/Input/Input.js +13 -14
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +13 -13
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +12 -12
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +3 -3
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +5 -5
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.d.ts +4 -0
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +44 -41
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +3 -1
- package/build/cjs/components/MainHeaderNavigation/MainHeaderNavigation.js +14 -10
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.d.ts +2 -0
- package/build/cjs/components/MainHeaderNavigation/context/NavContext.js +4 -2
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.d.ts +8 -8
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.js +25 -22
- package/build/cjs/components/RadioButton/RadioButton.js +2 -2
- package/build/cjs/components/Switch/Switch.js +1 -2
- package/build/es/components/DateTimePicker/DateTimePicker.d.ts +16 -0
- package/build/es/components/DateTimePicker/DateTimePicker.js +52 -12
- package/build/es/components/Footer/Components/FooterComponents.js +7 -21
- package/build/es/components/Input/Input.d.ts +1 -1
- package/build/es/components/Input/Input.js +14 -15
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +13 -13
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.d.ts +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenu.js +12 -12
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.d.ts +3 -3
- package/build/es/components/MainHeaderNavigation/ChildComponents/MainNavTooltipMenuExportedStyles.js +5 -5
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.d.ts +4 -0
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +45 -43
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.d.ts +3 -1
- package/build/es/components/MainHeaderNavigation/MainHeaderNavigation.js +14 -10
- package/build/es/components/MainHeaderNavigation/context/NavContext.d.ts +2 -0
- package/build/es/components/MainHeaderNavigation/context/NavContext.js +4 -2
- package/build/es/components/MainHeaderNavigation/globalNavStyles.d.ts +8 -8
- package/build/es/components/MainHeaderNavigation/globalNavStyles.js +25 -22
- package/build/es/components/RadioButton/RadioButton.js +2 -2
- package/build/es/components/Switch/Switch.js +1 -2
- package/package.json +4 -4
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.js +0 -11
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +0 -6
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.js +0 -7
|
@@ -107,6 +107,22 @@ interface Props {
|
|
|
107
107
|
* Allows to pass a custom className
|
|
108
108
|
*/
|
|
109
109
|
className?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Descriptive label for screen readers for the input element.
|
|
112
|
+
*/
|
|
113
|
+
ariaLabelInput?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Accessible label for "Previous month" button
|
|
116
|
+
*/
|
|
117
|
+
ariaLabelPreviousMonth?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Accessible label for "Next month" button
|
|
120
|
+
*/
|
|
121
|
+
ariaLabelNextMonth?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Accessible text for announcing date changes (e.g., for screen readers)
|
|
124
|
+
*/
|
|
125
|
+
ariaLiveAnnouncement?: string;
|
|
110
126
|
}
|
|
111
127
|
/** @visibleName DateTime Picker */
|
|
112
128
|
declare const DateTimePicker: ({ date: startDate, locale, isDatePicker, isTimePicker, timeInterval, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
@@ -246,16 +246,20 @@ const StyledInput = styledComponents.styled(Input.default) `
|
|
|
246
246
|
}
|
|
247
247
|
`}
|
|
248
248
|
`;
|
|
249
|
-
const
|
|
250
|
-
|
|
249
|
+
const VisuallyHiddenStatus = styledComponents.styled.div `
|
|
250
|
+
position: absolute;
|
|
251
|
+
left: -9999px;
|
|
252
|
+
`;
|
|
253
|
+
const DateTimePickerCustomHeader = ({ date, decreaseMonth, increaseMonth, locale, ariaLabelPreviousMonth, ariaLabelNextMonth, }) => (React__default.default.createElement(MonthSelector, null,
|
|
254
|
+
React__default.default.createElement(ButtonIcon.default, { icon: icons.ChevronLeft, onClick: decreaseMonth, ariaLabel: ariaLabelPreviousMonth }),
|
|
251
255
|
React__default.default.createElement(CurrentMonth, null, sentenceCase(date.toLocaleString(locale, {
|
|
252
256
|
month: 'long',
|
|
253
257
|
year: 'numeric',
|
|
254
258
|
}))),
|
|
255
|
-
React__default.default.createElement(ButtonIcon.default, { icon: icons.ChevronRight, onClick: increaseMonth })));
|
|
259
|
+
React__default.default.createElement(ButtonIcon.default, { icon: icons.ChevronRight, onClick: increaseMonth, ariaLabel: ariaLabelNextMonth })));
|
|
256
260
|
/** @visibleName DateTime Picker */
|
|
257
261
|
const DateTimePicker = (_a) => {
|
|
258
|
-
var _b;
|
|
262
|
+
var _b, _c;
|
|
259
263
|
var { date: startDate, locale = 'fi-FI', isDatePicker = true, isTimePicker = false, timeInterval = 30, 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["date", "locale", "isDatePicker", "isTimePicker", "timeInterval", 'data-testid']);
|
|
260
264
|
const [showReactDatePicker, setShowReactDatePicker] = React.useState(false);
|
|
261
265
|
const handleOnInputFocus = () => {
|
|
@@ -267,17 +271,42 @@ const DateTimePicker = (_a) => {
|
|
|
267
271
|
}
|
|
268
272
|
};
|
|
269
273
|
const handleOnKeyDown = (e) => {
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
const isNavigationKey = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key);
|
|
275
|
+
if (isNavigationKey && showReactDatePicker) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (e.key === 'Escape') {
|
|
279
|
+
setShowReactDatePicker(false);
|
|
280
|
+
}
|
|
281
|
+
if (e.key === 'Enter' && showReactDatePicker) {
|
|
282
|
+
setShowReactDatePicker(false);
|
|
283
|
+
}
|
|
284
|
+
if (!props.isEditable && ['Backspace', 'Delete', 'Clear'].includes(e.key)) {
|
|
272
285
|
props.onChange(null, e);
|
|
273
286
|
}
|
|
274
287
|
};
|
|
275
288
|
const handleClearable = (e) => {
|
|
276
289
|
props.onChange(null, e);
|
|
277
290
|
};
|
|
278
|
-
const handleOnReactDatePickerChange = (date,
|
|
279
|
-
|
|
280
|
-
props.
|
|
291
|
+
const handleOnReactDatePickerChange = (date, event) => {
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const isSelectingRange = props.endDate !== undefined;
|
|
294
|
+
let shouldKeepOpen = false;
|
|
295
|
+
if (isSelectingRange) {
|
|
296
|
+
const [start, end] = Array.isArray(date) && date.length === 2 ? date : [null, null];
|
|
297
|
+
shouldKeepOpen = !(start && end);
|
|
298
|
+
}
|
|
299
|
+
else if (isDatePicker &&
|
|
300
|
+
isTimePicker &&
|
|
301
|
+
date instanceof Date &&
|
|
302
|
+
((_a = date.getHours) === null || _a === void 0 ? void 0 : _a.call(date)) === 0 &&
|
|
303
|
+
((_b = date.getMinutes) === null || _b === void 0 ? void 0 : _b.call(date)) === 0) {
|
|
304
|
+
shouldKeepOpen = true;
|
|
305
|
+
}
|
|
306
|
+
if (!shouldKeepOpen) {
|
|
307
|
+
setShowReactDatePicker(false);
|
|
308
|
+
}
|
|
309
|
+
props.onChange(date, event);
|
|
281
310
|
};
|
|
282
311
|
const handleOnReactDatePickerClickOutside = () => {
|
|
283
312
|
setShowReactDatePicker(false);
|
|
@@ -291,10 +320,21 @@ const DateTimePicker = (_a) => {
|
|
|
291
320
|
timeStyle: 'short',
|
|
292
321
|
}))))
|
|
293
322
|
.join(' - ');
|
|
294
|
-
const getDateTimePickerCustomHeader = (args) => DateTimePickerCustomHeader(Object.assign(Object.assign({}, args), { locale }));
|
|
323
|
+
const getDateTimePickerCustomHeader = (args) => DateTimePickerCustomHeader(Object.assign(Object.assign({}, args), { locale, ariaLabelPreviousMonth: props.ariaLabelPreviousMonth, ariaLabelNextMonth: props.ariaLabelNextMonth }));
|
|
295
324
|
return (React__default.default.createElement(Wrapper, { id: props.id, className: props.className, "data-testid": dataTestId },
|
|
296
|
-
React__default.default.createElement(StyledInput, { id: `datetimepicker-input-${props.id}`, name: `datetimepicker-input-${props.id}`, label: props.label, placeholder: props.placeholder, value: formatInputValue, onFocus: handleOnInputFocus, onChange: handleOnInputChange, onKeyDown: handleOnKeyDown, onClearableButtonClick: props.isClearable ? handleClearable : undefined, className: "react-datepicker-ignore-onclickoutside", "data-testid": dataTestId && `${dataTestId}-datetimepicker-input`, disabled: props.isDisabled, required: props.isRequired, readonly: !props.isEditable, status: props.isInError ? 'error' : undefined, errorMessage: props.errorMessage
|
|
297
|
-
|
|
325
|
+
React__default.default.createElement(StyledInput, { id: `datetimepicker-input-${props.id}`, name: `datetimepicker-input-${props.id}`, label: props.label, placeholder: props.placeholder, value: formatInputValue, onFocus: handleOnInputFocus, onChange: handleOnInputChange, onKeyDown: handleOnKeyDown, onClearableButtonClick: props.isClearable ? handleClearable : undefined, className: "react-datepicker-ignore-onclickoutside", "data-testid": dataTestId && `${dataTestId}-datetimepicker-input`, disabled: props.isDisabled, required: props.isRequired, readonly: !props.isEditable, status: props.isInError ? 'error' : undefined, errorMessage: props.errorMessage, ariaLabel: props.ariaLabelInput, onBlur: (_val, e) => {
|
|
326
|
+
if (props.isEditable && e.target.value) {
|
|
327
|
+
const parsedDate = new Date(e.target.value);
|
|
328
|
+
const time = parsedDate.getTime();
|
|
329
|
+
if (!Number.isNaN(time)) {
|
|
330
|
+
props.onChange(parsedDate, e);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
} }),
|
|
334
|
+
React__default.default.createElement(VisuallyHiddenStatus, { role: "status", "aria-live": "polite" }, startDate instanceof Date && !Number.isNaN(startDate.getTime())
|
|
335
|
+
? (_b = props.ariaLiveAnnouncement) === null || _b === void 0 ? void 0 : _b.replace('{{date}}', startDate.toLocaleDateString(locale))
|
|
336
|
+
: ''),
|
|
337
|
+
showReactDatePicker && (React__default.default.createElement(ReactDatePicker__default.default, { inline: true, selected: startDate, startDate: startDate, maxDate: props.maxDate, minDate: props.minDate, endDate: props.endDate, onChange: handleOnReactDatePickerChange, selectsRange: props.endDate !== undefined, showTimeSelect: props.endDate === undefined && isTimePicker, showTimeSelectOnly: props.endDate === undefined && !isDatePicker && isTimePicker, timeCaption: (_c = localeData[locale]) === null || _c === void 0 ? void 0 : _c.localize.timeCaption, timeIntervals: timeInterval, onClickOutside: handleOnReactDatePickerClickOutside, locale: localeData[locale],
|
|
298
338
|
// Used to format the date/time in internal ReactDatePicker input
|
|
299
339
|
// Currently ignored as date/time is shown in Styleguide Input instead, and formatted by using Intl.DateTimeFormat
|
|
300
340
|
dateFormat: [isDatePicker && 'P', isTimePicker && 'p'].filter(Boolean).join(''), renderCustomHeader: getDateTimePickerCustomHeader }))));
|
|
@@ -314,30 +314,16 @@ const SocialMediaLinks = ({ socialMedia }) => {
|
|
|
314
314
|
return (React__default.default.createElement("a", { href: url, key: `social-media-link-${socialMediaKey}`, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : socialMediaName }, SocialIcon && React__default.default.createElement(SocialIcon, null)));
|
|
315
315
|
})));
|
|
316
316
|
};
|
|
317
|
-
const isNewApplicationLinks = (links) => 'appStore' in links && typeof links.appStore === 'object';
|
|
318
317
|
const ApplicationLinks = ({ applicationLinks, language, }) => {
|
|
319
|
-
var _a, _b, _c, _d, _e, _f
|
|
320
|
-
|
|
321
|
-
const { appStore, googlePlay, title } = applicationLinks;
|
|
322
|
-
return (React__default.default.createElement(AppSection, null,
|
|
323
|
-
React__default.default.createElement("p", null, title[language]),
|
|
324
|
-
React__default.default.createElement(AppList, null,
|
|
325
|
-
((_a = appStore.urls) === null || _a === void 0 ? void 0 : _a[language]) && (React__default.default.createElement("a", { "aria-label": (_b = appStore.ariaLabels) === null || _b === void 0 ? void 0 : _b[language], href: appStore.urls[language], target: "_blank", rel: "noopener noreferrer" },
|
|
326
|
-
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/App_Store_Badge.png", alt: (_c = appStore.alts) === null || _c === void 0 ? void 0 : _c[language] }))),
|
|
327
|
-
((_d = googlePlay.urls) === null || _d === void 0 ? void 0 : _d[language]) && (React__default.default.createElement("a", { "aria-label": (_e = googlePlay.ariaLabels) === null || _e === void 0 ? void 0 : _e[language], href: googlePlay.urls[language], target: "_blank", rel: "noopener noreferrer" },
|
|
328
|
-
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/Google_Play_Badge.png", alt: (_f = googlePlay.alts) === null || _f === void 0 ? void 0 : _f[language] }))))));
|
|
329
|
-
}
|
|
318
|
+
var _a, _b, _c, _d, _e, _f;
|
|
319
|
+
const { appStore, googlePlay, title } = applicationLinks;
|
|
330
320
|
return (React__default.default.createElement(AppSection, null,
|
|
331
|
-
React__default.default.createElement("p", null,
|
|
321
|
+
React__default.default.createElement("p", null, title[language]),
|
|
332
322
|
React__default.default.createElement(AppList, null,
|
|
333
|
-
((
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/
|
|
337
|
-
((_h = applicationLinks.googlePlayURL) === null || _h === void 0 ? void 0 : _h[language]) && (React__default.default.createElement("a", { "aria-label": language === 'fi'
|
|
338
|
-
? 'Lataa sovellus Google Playstä'
|
|
339
|
-
: 'Download from Google Play', href: applicationLinks.googlePlayURL[language], target: "_blank", rel: "noopener noreferrer" },
|
|
340
|
-
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/Google_Play_Badge.png", alt: "" }))))));
|
|
323
|
+
((_a = appStore.urls) === null || _a === void 0 ? void 0 : _a[language]) && (React__default.default.createElement("a", { "aria-label": (_b = appStore.ariaLabels) === null || _b === void 0 ? void 0 : _b[language], href: appStore.urls[language], target: "_blank", rel: "noopener noreferrer" },
|
|
324
|
+
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/App_Store_Badge.png", alt: (_c = appStore.alts) === null || _c === void 0 ? void 0 : _c[language] }))),
|
|
325
|
+
((_d = googlePlay.urls) === null || _d === void 0 ? void 0 : _d[language]) && (React__default.default.createElement("a", { "aria-label": (_e = googlePlay.ariaLabels) === null || _e === void 0 ? void 0 : _e[language], href: googlePlay.urls[language], target: "_blank", rel: "noopener noreferrer" },
|
|
326
|
+
React__default.default.createElement("img", { src: "https://res.cloudinary.com/dnaoyj/image/upload/dpr_2,f_auto,q_auto,w_142/v1/Assets/Icons%20and%20logos/Other%20icons/Google_Play_Badge.png", alt: (_f = googlePlay.alts) === null || _f === void 0 ? void 0 : _f[language] }))))));
|
|
341
327
|
};
|
|
342
328
|
const BottomSection = ({ items }) => {
|
|
343
329
|
const { applicationLinks, businessSelector, customLinks, generalInformation, languageSelector, socialMedia, } = items.footerNavigation;
|
|
@@ -148,6 +148,6 @@ interface Props {
|
|
|
148
148
|
*/
|
|
149
149
|
'data-testid'?: string;
|
|
150
150
|
}
|
|
151
|
-
declare const Input:
|
|
151
|
+
declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
|
|
152
152
|
/** @component */
|
|
153
153
|
export default Input;
|
|
@@ -129,16 +129,10 @@ const ErrorMessage = styledComponents.styled(Message) `
|
|
|
129
129
|
font-weight: ${theme.default.fontWeight.medium};
|
|
130
130
|
color: ${theme.default.color.notification.error};
|
|
131
131
|
`;
|
|
132
|
-
const Input = (_a) => {
|
|
132
|
+
const Input = React.forwardRef((_a, ref) => {
|
|
133
133
|
var _b;
|
|
134
134
|
var { type = 'text', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
135
|
-
const inputRef = React.useRef(null);
|
|
136
135
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
137
|
-
React.useEffect(() => {
|
|
138
|
-
if (props.showPasswordToggle && inputRef && inputRef.current) {
|
|
139
|
-
inputRef.current.type = showPassword ? 'text' : 'password';
|
|
140
|
-
}
|
|
141
|
-
}, [showPassword, props.showPasswordToggle]);
|
|
142
136
|
const togglePasswordVisibility = () => {
|
|
143
137
|
if (props.showPasswordToggle && !props.disabled) {
|
|
144
138
|
setShowPassword(!showPassword);
|
|
@@ -156,9 +150,7 @@ const Input = (_a) => {
|
|
|
156
150
|
};
|
|
157
151
|
const onClick = (e) => {
|
|
158
152
|
e.preventDefault();
|
|
159
|
-
|
|
160
|
-
inputRef.current.focus();
|
|
161
|
-
}
|
|
153
|
+
e.currentTarget.focus();
|
|
162
154
|
};
|
|
163
155
|
const getDescribedBy = () => {
|
|
164
156
|
if (props.status === 'error' && props.errorMessage) {
|
|
@@ -169,10 +161,17 @@ const Input = (_a) => {
|
|
|
169
161
|
}
|
|
170
162
|
return undefined;
|
|
171
163
|
};
|
|
172
|
-
|
|
164
|
+
const getInputType = () => {
|
|
165
|
+
if (props.showPasswordToggle) {
|
|
166
|
+
return showPassword ? 'text' : 'password';
|
|
167
|
+
}
|
|
168
|
+
return type;
|
|
169
|
+
};
|
|
170
|
+
const inputType = getInputType();
|
|
171
|
+
return (React__default.default.createElement(FieldContainer, { className: props.className, "data-testid": dataTestId && `${dataTestId}-container` },
|
|
173
172
|
props.label && (React__default.default.createElement(LabelText.default, { htmlFor: props.id, "data-testid": dataTestId && `${dataTestId}-label`, status: props.status === 'error' ? props.status : undefined, isMandatory: props.required }, props.label)),
|
|
174
|
-
React__default.default.createElement(FieldWrapper, { "$status": props.status, "$type":
|
|
175
|
-
React__default.default.createElement(StyledInput, { id: props.id, name: props.name, type:
|
|
173
|
+
React__default.default.createElement(FieldWrapper, { "$status": props.status, "$type": inputType, "$disabled": props.disabled, "$readonly": props.readonly },
|
|
174
|
+
React__default.default.createElement(StyledInput, { id: props.id, name: props.name, type: inputType, value: props.value, placeholder: props.placeholder, onChange: handleChange, onBlur: handleOnBlur, onFocus: props.onFocus, onClick: onClick, onKeyDown: props.onKeyDown, onKeyPress: props.onKeyPress, required: props.required, disabled: props.disabled, autoComplete: props.autocomplete, "aria-disabled": props.disabled, "aria-readonly": props.readonly || undefined, "aria-label": !props.label ? (_b = props.ariaLabel) !== null && _b !== void 0 ? _b : props.id : undefined, ref: ref, tabIndex: props.tabIndex, "aria-describedby": getDescribedBy(), "data-testid": dataTestId, readOnly: props.readonly }),
|
|
176
175
|
((props.status && props.status !== 'comment') ||
|
|
177
176
|
props.showPasswordToggle ||
|
|
178
177
|
props.disabled ||
|
|
@@ -187,6 +186,6 @@ const Input = (_a) => {
|
|
|
187
186
|
!props.readonly && (React__default.default.createElement(ButtonIcon.default, { icon: icons.Close, onClick: props.onClearableButtonClick, ariaLabel: props.clearButtonLabel }))))),
|
|
188
187
|
props.status === 'error' && props.errorMessage && (React__default.default.createElement(ErrorMessage, { id: `${props.id}-error`, "data-testid": dataTestId && `${dataTestId}-error` }, props.errorMessage)),
|
|
189
188
|
props.status === 'comment' && props.commentMessage && (React__default.default.createElement(Message, { id: `${props.id}-comment`, "data-testid": dataTestId && `${dataTestId}-comment` }, props.commentMessage))));
|
|
190
|
-
};
|
|
189
|
+
});
|
|
191
190
|
|
|
192
191
|
exports.default = Input;
|
|
@@ -73,8 +73,8 @@ const CategoryCollectionBlock = styledComponents.styled(CategoryBlock) `
|
|
|
73
73
|
`;
|
|
74
74
|
const SubMenuItem = styledComponents.styled.li `
|
|
75
75
|
> a {
|
|
76
|
-
color: ${p => (p
|
|
77
|
-
font-weight: ${p => (p
|
|
76
|
+
color: ${p => (p.$isHighlighted ? theme.default.color.text.pink : theme.default.color.text.black)};
|
|
77
|
+
font-weight: ${p => (p.$isHighlighted ? theme.default.fontWeight.bold : theme.default.fontWeight.book)};
|
|
78
78
|
}
|
|
79
79
|
`;
|
|
80
80
|
const DesktopMenuItem = styledComponents.styled(globalNavStyles.MenuItem) `
|
|
@@ -97,7 +97,7 @@ const DesktopMenuItem = styledComponents.styled(globalNavStyles.MenuItem) `
|
|
|
97
97
|
bottom: -22px;
|
|
98
98
|
left: 0;
|
|
99
99
|
border-bottom: 2px solid
|
|
100
|
-
${p => (p
|
|
100
|
+
${p => (p.$isActive ? theme.default.color.default.pink : 'transparent')};
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -108,9 +108,9 @@ const SubMenuList = styledComponents.styled.div `
|
|
|
108
108
|
top: ${navigation.navMaxHeight};
|
|
109
109
|
left: 0;
|
|
110
110
|
right: 0;
|
|
111
|
-
display: ${({ menuStates, navItemId }) => (menuStates === null || menuStates === void 0 ? void 0 : menuStates.level1) === navItemId ? 'block' : 'none'};
|
|
112
|
-
z-index: ${({ navZIndex }) => navZIndex + 1};
|
|
113
|
-
${({ menuStates }) => menuStates.level1 && menuStates.animate2 &&
|
|
111
|
+
display: ${({ $menuStates, $navItemId }) => ($menuStates === null || $menuStates === void 0 ? void 0 : $menuStates.level1) === $navItemId ? 'block' : 'none'};
|
|
112
|
+
z-index: ${({ $navZIndex }) => $navZIndex + 1};
|
|
113
|
+
${({ $menuStates }) => $menuStates.level1 && $menuStates.animate2 && !$menuStates.level2
|
|
114
114
|
? fadeInAnimation
|
|
115
115
|
: noAnimation};
|
|
116
116
|
background-color: ${theme.default.color.background.white.default};
|
|
@@ -123,16 +123,16 @@ const SubMenuList = styledComponents.styled.div `
|
|
|
123
123
|
}
|
|
124
124
|
`;
|
|
125
125
|
const SubMenuLevel1 = ({ menuItem }) => {
|
|
126
|
-
const { categoryCollectionText, collapseSize, currentUrl, lang, menuLevel, navZIndex } = React.useContext(NavContext.default);
|
|
126
|
+
const { categoryCollectionText, collapseSize, currentUrl, featuredItemsAriaLabel, lang, menuLevel, navZIndex, } = React.useContext(NavContext.default);
|
|
127
127
|
const level1HasElements = !!menuItem.pages.length;
|
|
128
128
|
const pagesWithSubItems = menuItem.pages.filter(element => element.pages.length > 0);
|
|
129
129
|
// Helper function to render a sub menu item
|
|
130
|
-
const renderSubMenuItem = (element, index, currUrl) => (React__default.default.createElement(SubMenuItem, { key: element.id, isHighlighted: LinkModifier.isSelected(currUrl, element.urls[lang], true), "data-testid": `desktop-nav-item-level-2-${index + 1}` },
|
|
130
|
+
const renderSubMenuItem = (element, index, currUrl) => (React__default.default.createElement(SubMenuItem, { key: element.id, "$isHighlighted": LinkModifier.isSelected(currUrl, element.urls[lang], true), "data-testid": `desktop-nav-item-level-2-${index + 1}` },
|
|
131
131
|
React__default.default.createElement(LinkModifier.default, { menuItem: element, disabledTabIndex: false })));
|
|
132
132
|
if (!level1HasElements) {
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
|
-
return (React__default.default.createElement(SubMenuList, { "aria-hidden": false, menuStates: menuLevel, navItemId: menuItem.id, navZIndex: navZIndex },
|
|
135
|
+
return (React__default.default.createElement(SubMenuList, { "aria-hidden": false, "$menuStates": menuLevel, "$navItemId": menuItem.id, "$navZIndex": navZIndex },
|
|
136
136
|
React__default.default.createElement(MegaMenuContent, { "aria-labelledby": `menu-id-${menuItem.id}` },
|
|
137
137
|
pagesWithSubItems.slice(0, 5).map(element => (React__default.default.createElement(CategoryBlock, { key: element.id },
|
|
138
138
|
React__default.default.createElement(CategoryTitle, { id: `menu-id-${element.id}` }, element.titles[lang]),
|
|
@@ -142,7 +142,7 @@ const SubMenuLevel1 = ({ menuItem }) => {
|
|
|
142
142
|
React__default.default.createElement("ul", { "aria-labelledby": "misc-categories", "data-testid": "desktop-nav-menu-ul-level-2" }, pagesWithSubItems
|
|
143
143
|
.slice(5)
|
|
144
144
|
.map((element, index) => renderSubMenuItem(element, index, currentUrl))))),
|
|
145
|
-
React__default.default.createElement(globalNavStyles.FeaturedBlock, { collapseSize: collapseSize, "data-testid": "desktop-nav-menu-level-2-featured" }, menuItem.pages.map(element => element.pages.length ? null : (React__default.default.createElement(LinkModifier.default, { key: element.id, showIcon: true, menuItem: element, disabledTabIndex: false })))))));
|
|
145
|
+
React__default.default.createElement(globalNavStyles.FeaturedBlock, { "$collapseSize": collapseSize, "data-testid": "desktop-nav-menu-level-2-featured" }, menuItem.pages.some(element => !element.pages.length) && (React__default.default.createElement("section", { "aria-label": featuredItemsAriaLabel }, menuItem.pages.map(element => element.pages.length ? null : (React__default.default.createElement(LinkModifier.default, { key: element.id, showIcon: true, menuItem: element, disabledTabIndex: false })))))))));
|
|
146
146
|
};
|
|
147
147
|
const MenuItemWithChildren = ({ menuItem, currentLevel }) => {
|
|
148
148
|
const { lang, handleNavMenuClick, currentUrl, menuLevel } = React.useContext(NavContext.default);
|
|
@@ -151,8 +151,8 @@ const MenuItemWithChildren = ({ menuItem, currentLevel }) => {
|
|
|
151
151
|
e.preventDefault();
|
|
152
152
|
handleNavMenuClick(element.id, 'level1');
|
|
153
153
|
};
|
|
154
|
-
return (React__default.default.createElement(DesktopMenuItem, { isActive: LinkModifier.isSelected(currentUrl, linkUrl), "data-testid": `desktop-nav-item-level-1-${currentLevel + 1}` },
|
|
155
|
-
React__default.default.createElement(globalNavStyles.MenuLinkWithChildren, { isOpen: menuLevel.level1 === menuItem.id, onClick: menuClickMain(menuItem), "data-testid": "menu-button-with-children", "aria-current": LinkModifier.isSelected(currentUrl, linkUrl) ? 'true' : undefined, "aria-expanded": menuLevel.level1 === menuItem.id, href: linkUrl },
|
|
154
|
+
return (React__default.default.createElement(DesktopMenuItem, { "$isActive": LinkModifier.isSelected(currentUrl, linkUrl), "data-testid": `desktop-nav-item-level-1-${currentLevel + 1}` },
|
|
155
|
+
React__default.default.createElement(globalNavStyles.MenuLinkWithChildren, { "$isOpen": menuLevel.level1 === menuItem.id, onClick: menuClickMain(menuItem), "data-testid": "menu-button-with-children", "aria-current": LinkModifier.isSelected(currentUrl, linkUrl) ? 'true' : undefined, "aria-expanded": menuLevel.level1 === menuItem.id, href: linkUrl },
|
|
156
156
|
React__default.default.createElement("span", { id: `menu-id-${menuItem.id}` }, menuItem.titles[lang]),
|
|
157
157
|
React__default.default.createElement(icons.ChevronRight, { size: "1rem" })),
|
|
158
158
|
React__default.default.createElement(SubMenuLevel1, { menuItem: menuItem })));
|
|
@@ -175,7 +175,7 @@ const DesktopMenu = () => {
|
|
|
175
175
|
if (displaySubMenu) {
|
|
176
176
|
return (React__default.default.createElement(MenuItemWithChildren, { currentLevel: index, key: navElement.id, menuItem: navElement }));
|
|
177
177
|
}
|
|
178
|
-
return (React__default.default.createElement(DesktopMenuItem, { "data-testid": `desktop-nav-item-level-1-${index + 1}`, isActive: LinkModifier.isSelected(currentUrl, navElement.urls[lang]), key: navElement.id },
|
|
178
|
+
return (React__default.default.createElement(DesktopMenuItem, { "data-testid": `desktop-nav-item-level-1-${index + 1}`, "$isActive": LinkModifier.isSelected(currentUrl, navElement.urls[lang]), key: navElement.id },
|
|
179
179
|
React__default.default.createElement(LinkModifier.default, { menuItem: navElement, disabledTabIndex: false })));
|
|
180
180
|
})));
|
|
181
181
|
};
|
|
@@ -24,8 +24,8 @@ interface MainNavTooltipMenuProps<ContentProps extends object = object> extends
|
|
|
24
24
|
fullWidthBreakpoint?: number;
|
|
25
25
|
}
|
|
26
26
|
export declare const IconContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
27
|
-
isActive?: boolean;
|
|
28
|
-
collapseSize: number;
|
|
27
|
+
$isActive?: boolean;
|
|
28
|
+
$collapseSize: number;
|
|
29
29
|
}>> & string;
|
|
30
30
|
declare const MainNavTooltipMenu: <ContentProps extends object = object>({ ariaLabel, children, closeWhenTagClicked, contentComponent, contentWidth, fullWidthBreakpoint, fullWidthDesktop, globalStateString, tooltipRight, zIndex, ...props }: MainNavTooltipMenuProps<ContentProps>) => React.JSX.Element;
|
|
31
31
|
export default MainNavTooltipMenu;
|
|
@@ -35,10 +35,10 @@ const IconContainer = styledComponents.styled.div `
|
|
|
35
35
|
}
|
|
36
36
|
> svg,
|
|
37
37
|
+ span {
|
|
38
|
-
color: ${p => (p
|
|
38
|
+
color: ${p => (p.$isActive ? theme.default.color.text.pink : 'inherit')};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
@media (min-width: ${p => p
|
|
41
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
42
42
|
min-width: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 6)};
|
|
43
43
|
+ span {
|
|
44
44
|
display: block;
|
|
@@ -53,13 +53,13 @@ const Tooltip = styledComponents.styled.div `
|
|
|
53
53
|
position: absolute;
|
|
54
54
|
right: 0;
|
|
55
55
|
top: ${navigation.navMaxHeight};
|
|
56
|
-
z-index: ${p => p
|
|
56
|
+
z-index: ${p => p.$zIndex};
|
|
57
57
|
display: flex;
|
|
58
58
|
flex-direction: row;
|
|
59
59
|
|
|
60
|
-
@media (min-width: ${p => p
|
|
61
|
-
width: ${p => p
|
|
62
|
-
right: ${p => (p
|
|
60
|
+
@media (min-width: ${p => p.$fullWidthBreakpoint}px) {
|
|
61
|
+
width: ${p => p.$contentWidth};
|
|
62
|
+
right: ${p => (p.$fullWidthDesktop ? 0 : p.$tooltipRight)};
|
|
63
63
|
}
|
|
64
64
|
`;
|
|
65
65
|
const TooltipBox = styledComponents.styled(Box.default) `
|
|
@@ -70,7 +70,7 @@ const TooltipBox = styledComponents.styled(Box.default) `
|
|
|
70
70
|
`;
|
|
71
71
|
const Caret = styledComponents.styled.div `
|
|
72
72
|
position: absolute;
|
|
73
|
-
z-index: ${p => p
|
|
73
|
+
z-index: ${p => p.$zIndex + 1};
|
|
74
74
|
top: ${navigation.navMaxHeight};
|
|
75
75
|
transform: translate3d(50%, -50%, 0) rotate(-45deg);
|
|
76
76
|
width: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.2)};
|
|
@@ -80,7 +80,7 @@ const Caret = styledComponents.styled.div `
|
|
|
80
80
|
border-width: 1px 1px 0 0;
|
|
81
81
|
margin-left: -${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1)};
|
|
82
82
|
|
|
83
|
-
@media (min-width: ${p => p
|
|
83
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
84
84
|
max-height: calc(var(--vh100, 100vh) - ${navigation.navMaxHeight});
|
|
85
85
|
}
|
|
86
86
|
`;
|
|
@@ -110,11 +110,11 @@ const MainNavTooltipMenu = (_a) => {
|
|
|
110
110
|
setTooltipItems(prevItems => (Object.assign(Object.assign({}, prevItems), { [globalStateKey]: false })));
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
return (React__default.default.createElement(IconContainer, { "data-testid": `header-${globalStateKey}-container`, collapseSize: collapseSize, ref: ref },
|
|
114
|
-
globalStateKey === 'login' && !isLoggedIn ? (React__default.default.createElement(ButtonPrimary.default, { onClick: ContentComponent ? toggleState : undefined, small: true }, children)) : (React__default.default.createElement(MainNavTooltipMenuExportedStyles.default, { "aria-label": ariaLabel, "aria-expanded": tooltipItems[globalStateKey], isLoggedIn: isLoginItemAndLoggedIn, collapseSize: collapseSize, isHighlighted: tooltipItems[globalStateKey] || isLoginItemAndLoggedIn, onClick: props.onCartButtonClick || (ContentComponent ? toggleState : undefined) }, children)),
|
|
113
|
+
return (React__default.default.createElement(IconContainer, { "data-testid": `header-${globalStateKey}-container`, "$collapseSize": collapseSize, ref: ref },
|
|
114
|
+
globalStateKey === 'login' && !isLoggedIn ? (React__default.default.createElement(ButtonPrimary.default, { onClick: ContentComponent ? toggleState : undefined, small: true }, children)) : (React__default.default.createElement(MainNavTooltipMenuExportedStyles.default, { "aria-label": ariaLabel, "aria-expanded": tooltipItems[globalStateKey], "$isLoggedIn": isLoginItemAndLoggedIn, "$collapseSize": collapseSize, "$isHighlighted": tooltipItems[globalStateKey] || isLoginItemAndLoggedIn, onClick: props.onCartButtonClick || (ContentComponent ? toggleState : undefined) }, children)),
|
|
115
115
|
tooltipItems[globalStateKey] && ContentComponent && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
116
|
-
React__default.default.createElement(Caret, { zIndex: zIndex, collapseSize: collapseSize }),
|
|
117
|
-
React__default.default.createElement(Tooltip, { zIndex: zIndex, tooltipRight: tooltipRight, contentWidth: contentWidth, collapseSize: collapseSize, fullWidthDesktop: fullWidthDesktop, fullWidthBreakpoint: fullWidthBreakpoint },
|
|
116
|
+
React__default.default.createElement(Caret, { "$zIndex": zIndex, "$collapseSize": collapseSize }),
|
|
117
|
+
React__default.default.createElement(Tooltip, { "$zIndex": zIndex, "$tooltipRight": tooltipRight, "$contentWidth": contentWidth, "$collapseSize": collapseSize, "$fullWidthDesktop": fullWidthDesktop, "$fullWidthBreakpoint": fullWidthBreakpoint },
|
|
118
118
|
React__default.default.createElement(TooltipBox, { elevation: "high", padding: "0", width: "100%" },
|
|
119
119
|
React__default.default.createElement(ContentComponent, { mobileView: isMobileMenu })))))));
|
|
120
120
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const TooltipWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
2
|
-
collapseSize: number;
|
|
3
|
-
isHighlighted?: boolean;
|
|
4
|
-
isLoggedIn?: boolean;
|
|
2
|
+
$collapseSize: number;
|
|
3
|
+
$isHighlighted?: boolean;
|
|
4
|
+
$isLoggedIn?: boolean;
|
|
5
5
|
}>> & string;
|
|
6
6
|
export default TooltipWrapper;
|
|
7
7
|
export { TooltipWrapper };
|
|
@@ -13,15 +13,15 @@ const TooltipWrapper = styledComponents.styled.button `
|
|
|
13
13
|
padding: 0;
|
|
14
14
|
overflow: visible;
|
|
15
15
|
background: transparent;
|
|
16
|
-
color: ${p => (p
|
|
16
|
+
color: ${p => (p.$isHighlighted ? theme.default.color.text.pink : 'inherit')};
|
|
17
17
|
font: inherit;
|
|
18
18
|
line-height: normal;
|
|
19
19
|
-webkit-font-smoothing: inherit;
|
|
20
20
|
-moz-osx-font-smoothing: inherit;
|
|
21
21
|
-webkit-appearance: none;
|
|
22
22
|
cursor: pointer;
|
|
23
|
-
width: ${p => (p
|
|
24
|
-
border-left: ${p => (p
|
|
23
|
+
width: ${p => (p.$isLoggedIn ? '6.25rem' : '100%')};
|
|
24
|
+
border-left: ${p => (p.$isLoggedIn ? `2px solid ${theme.default.color.line.L03}` : 'none')};
|
|
25
25
|
&:active,
|
|
26
26
|
&:focus {
|
|
27
27
|
> svg,
|
|
@@ -43,14 +43,14 @@ const TooltipWrapper = styledComponents.styled.button `
|
|
|
43
43
|
align-content: center;
|
|
44
44
|
display: flex;
|
|
45
45
|
margin: 0 auto;
|
|
46
|
-
@media (min-width: ${p => p
|
|
46
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
47
47
|
height: 1.625em;
|
|
48
48
|
width: 1.625em;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
> span {
|
|
52
52
|
display: none;
|
|
53
|
-
@media (min-width: ${p => p
|
|
53
|
+
@media (min-width: ${p => p.$collapseSize + 1}px) {
|
|
54
54
|
font-size: ${theme.default.fontSize.xs};
|
|
55
55
|
font-weight: ${theme.default.fontWeight.medium};
|
|
56
56
|
width: 100%;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { MobileMenuBackLink } from '../types/globalNavProps';
|
|
3
|
+
export declare const MenuItemBackLink: ({ currentLevel, backRef, }: MobileMenuBackLink & {
|
|
4
|
+
backRef?: React.RefObject<HTMLButtonElement>;
|
|
5
|
+
}) => React.JSX.Element;
|
|
2
6
|
declare const RenderMobileMenu: () => React.JSX.Element | null;
|
|
3
7
|
export default RenderMobileMenu;
|
|
@@ -9,7 +9,6 @@ var styledComponents = require('styled-components');
|
|
|
9
9
|
var theme = require('../../../themes/theme.js');
|
|
10
10
|
var navigation = require('../../../themes/themeComponents/navigation.js');
|
|
11
11
|
var styledUtils = require('../../../utils/styledUtils.js');
|
|
12
|
-
var MobileMenuContext = require('../context/MobileMenuContext.js');
|
|
13
12
|
var NavContext = require('../context/NavContext.js');
|
|
14
13
|
var globalNavStyles = require('../globalNavStyles.js');
|
|
15
14
|
var LinkModifier = require('./LinkModifier.js');
|
|
@@ -28,7 +27,7 @@ const MobileMenuWrapper = styledComponents.styled(reactSpring.animated.div) `
|
|
|
28
27
|
`;
|
|
29
28
|
const mobileMenu = `calc(100vh - ${navigation.headerMaxHeight})`;
|
|
30
29
|
const MenuLinkBackLink = styledComponents.styled(globalNavStyles.MenuLink) ``;
|
|
31
|
-
const MobileMenuContainer = styledComponents.styled.
|
|
30
|
+
const MobileMenuContainer = styledComponents.styled.nav `
|
|
32
31
|
width: 100%;
|
|
33
32
|
position: absolute;
|
|
34
33
|
top: ${navigation.navMaxHeight};
|
|
@@ -83,7 +82,7 @@ const MobileMenuContainer = styledComponents.styled.div `
|
|
|
83
82
|
}
|
|
84
83
|
${globalNavStyles.FeaturedBlock} {
|
|
85
84
|
border-bottom: 1px solid ${theme.default.color.line.L04};
|
|
86
|
-
> a {
|
|
85
|
+
section > a {
|
|
87
86
|
font-size: ${theme.default.fontSize.s};
|
|
88
87
|
line-height: ${theme.default.lineHeight.s};
|
|
89
88
|
padding: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 1)};
|
|
@@ -91,31 +90,25 @@ const MobileMenuContainer = styledComponents.styled.div `
|
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
`;
|
|
94
|
-
const MenuItemBackLink = ({ currentLevel }) => {
|
|
95
|
-
const { handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = React.useContext(NavContext.default);
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
100
|
-
const menuElementLevel = `level${currentLevel - 1}Items`;
|
|
101
|
-
const menuElements = levels[menuElementLevel];
|
|
93
|
+
const MenuItemBackLink = ({ currentLevel, backRef, }) => {
|
|
94
|
+
const { backToPreviousCategoryLabel, handleNavMenuClick, lang, menuLevel: { scrollPosition }, level1Items, level2Items, getBackLink, } = React.useContext(NavContext.default);
|
|
95
|
+
const menuElements = currentLevel === 2 ? level1Items : level2Items;
|
|
96
|
+
const tabNavigationDisabled = scrollPosition !== currentLevel - 1;
|
|
97
|
+
const backLink = getBackLink(menuElements, currentLevel - 1);
|
|
102
98
|
const mobileMenuBackClick = () => {
|
|
103
99
|
handleNavMenuClick(null, `level${currentLevel - 1}Mobile`);
|
|
104
100
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return (React__default.default.createElement(globalNavStyles.MenuItem, { key: `back-${backLink.id}`, "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
108
|
-
React__default.default.createElement(MenuLinkBackLink, { as: "button", onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
101
|
+
return (React__default.default.createElement(globalNavStyles.MenuItem, { "data-testid": `mobile-nav-menu-backlink-level-${currentLevel}` },
|
|
102
|
+
React__default.default.createElement(MenuLinkBackLink, { as: "button", ref: backRef, onClick: mobileMenuBackClick, tabIndex: tabNavigationDisabled ? -1 : undefined, "aria-label": `${backToPreviousCategoryLabel} ${backLink.titles[lang]}` },
|
|
109
103
|
React__default.default.createElement(icons.ChevronLeft, { size: "1.5rem" }),
|
|
110
104
|
backLink.titles[lang])));
|
|
111
105
|
};
|
|
112
|
-
const
|
|
106
|
+
const SubMenuItem = ({ menuItem, currentLevel, itemIndex, mobileMenuRef, firstItemRef, }) => {
|
|
113
107
|
const { handleNavMenuClick, menuLevel, lang, currentUrl } = React.useContext(NavContext.default);
|
|
114
|
-
const
|
|
115
|
-
const hasChildren = menuItem.pages.length;
|
|
108
|
+
const hasChildren = !!menuItem.pages.length;
|
|
116
109
|
const indexLevel = currentLevel - 1;
|
|
117
110
|
const tabNavigationDisabled = menuLevel.scrollPosition !== indexLevel;
|
|
118
|
-
const menuUrl = menuItem.urls[lang]
|
|
111
|
+
const menuUrl = menuItem.urls[lang];
|
|
119
112
|
const mobileMenuClick = (element) => (e) => {
|
|
120
113
|
var _a, _b;
|
|
121
114
|
(_b = (_a = mobileMenuRef === null || mobileMenuRef === void 0 ? void 0 : mobileMenuRef.current) === null || _a === void 0 ? void 0 : _a.scroll) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
@@ -126,37 +119,50 @@ const CreateSubMenuItem = ({ menuItem, currentLevel, itemIndex }) => {
|
|
|
126
119
|
e.preventDefault();
|
|
127
120
|
handleNavMenuClick(element.id, `level${currentLevel}Mobile`);
|
|
128
121
|
};
|
|
129
|
-
const renderMenuItem = (children) => (React__default.default.createElement(globalNavStyles.MenuItem, { key: menuItem.id, "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, isActive: LinkModifier.isSelected(currentUrl, menuUrl, true) }, children));
|
|
122
|
+
const renderMenuItem = (children) => (React__default.default.createElement(globalNavStyles.MenuItem, { key: menuItem.id, "data-testid": `mobile-menu-level-${currentLevel}-link-${itemIndex + 1}`, "$isActive": LinkModifier.isSelected(currentUrl, menuUrl, true) }, children));
|
|
130
123
|
if (hasChildren && currentLevel < 3) {
|
|
131
|
-
return renderMenuItem(React__default.default.createElement(globalNavStyles.MenuLink, { as: "button", onClick: mobileMenuClick(menuItem), tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
124
|
+
return renderMenuItem(React__default.default.createElement(globalNavStyles.MenuLink, { as: "button", ref: firstItemRef, onClick: mobileMenuClick(menuItem), tabIndex: tabNavigationDisabled ? -1 : undefined },
|
|
132
125
|
menuItem.titles[lang],
|
|
133
126
|
React__default.default.createElement(icons.ChevronRight, { color: theme.default.color.default.pink })));
|
|
134
127
|
}
|
|
135
128
|
return renderMenuItem(React__default.default.createElement(LinkModifier.default, { menuItem: menuItem, disabledTabIndex: tabNavigationDisabled }));
|
|
136
129
|
};
|
|
137
|
-
const SubMenuMobile = ({ currentLevel, menuItem }) => {
|
|
138
|
-
const
|
|
130
|
+
const SubMenuMobile = ({ currentLevel, menuItem, mobileMenuRef }) => {
|
|
131
|
+
const { collapseSize, featuredItemsAriaLabel, menuLevel } = React.useContext(NavContext.default);
|
|
139
132
|
const indexLevel = currentLevel - 1;
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
133
|
+
const tabNavigationDisabled = menuLevel.scrollPosition !== indexLevel;
|
|
134
|
+
const backRef = React.useRef(null);
|
|
135
|
+
const firstItemRef = React.useRef(null);
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
// Delay focus to allow animation to finish
|
|
138
|
+
const timer = setTimeout(() => {
|
|
139
|
+
if (currentLevel === 1 && firstItemRef.current) {
|
|
140
|
+
firstItemRef.current.focus();
|
|
141
|
+
}
|
|
142
|
+
if (currentLevel > 1 && backRef.current) {
|
|
143
|
+
backRef.current.focus();
|
|
144
|
+
}
|
|
145
|
+
}, 300);
|
|
146
|
+
return () => clearTimeout(timer);
|
|
147
|
+
}, [menuItem, currentLevel]);
|
|
148
|
+
if (!(menuItem === null || menuItem === void 0 ? void 0 : menuItem.pages.length)) {
|
|
143
149
|
return null;
|
|
144
150
|
}
|
|
151
|
+
const featuredItems = currentLevel === 2 ? menuItem.pages.filter(subMenuItem => !subMenuItem.pages.length) : [];
|
|
152
|
+
const menuItems = menuItem.pages.filter(subMenuItem => !featuredItems.includes(subMenuItem));
|
|
145
153
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
146
|
-
currentLevel > 1 && React__default.default.createElement(MenuItemBackLink, { currentLevel: currentLevel }),
|
|
147
|
-
featuredItems.length > 0 && (React__default.default.createElement(globalNavStyles.FeaturedBlock, { collapseSize: collapseSize },
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.map((subMenuItem, index) => (React__default.default.createElement(CreateSubMenuItem, { currentLevel: currentLevel, itemIndex: index, key: subMenuItem.id, menuItem: subMenuItem })))));
|
|
154
|
+
currentLevel > 1 && React__default.default.createElement(MenuItemBackLink, { backRef: backRef, currentLevel: currentLevel }),
|
|
155
|
+
featuredItems.length > 0 && (React__default.default.createElement(globalNavStyles.FeaturedBlock, { "$collapseSize": collapseSize },
|
|
156
|
+
React__default.default.createElement("section", { "aria-label": featuredItemsAriaLabel }, featuredItems.map(subMenuItem => (React__default.default.createElement(LinkModifier.default, { key: subMenuItem.id, menuItem: subMenuItem, showIcon: true, disabledTabIndex: tabNavigationDisabled })))))),
|
|
157
|
+
menuItems.map((subMenuItem, index) => (React__default.default.createElement(SubMenuItem, { currentLevel: currentLevel, itemIndex: index, key: subMenuItem.id, menuItem: subMenuItem, mobileMenuRef: mobileMenuRef, firstItemRef: index === 0 ? firstItemRef : undefined })))));
|
|
151
158
|
};
|
|
152
|
-
const NavigationMenuMobile = () => {
|
|
159
|
+
const NavigationMenuMobile = ({ mobileMenuRef }) => {
|
|
153
160
|
const { items, menuLevel, level1Items, level2Items } = React.useContext(NavContext.default);
|
|
154
161
|
const { mainNavigation } = items;
|
|
155
162
|
if (!(mainNavigation === null || mainNavigation === void 0 ? void 0 : mainNavigation.pages.length)) {
|
|
156
163
|
return null;
|
|
157
164
|
}
|
|
158
|
-
const renderMenuList = (scrollPosition, level, menuItem) => (React__default.default.createElement(globalNavStyles.MenuList, { "aria-hidden": menuLevel.scrollPosition !== scrollPosition, "aria-disabled": menuLevel.scrollPosition !== scrollPosition, "data-testid": `mobile-nav-menu-level-${level}`, isInView: menuLevel.scrollPosition === scrollPosition },
|
|
159
|
-
React__default.default.createElement(SubMenuMobile, { currentLevel: level, menuItem: menuItem })));
|
|
165
|
+
const renderMenuList = (scrollPosition, level, menuItem) => (React__default.default.createElement(globalNavStyles.MenuList, { "aria-hidden": menuLevel.scrollPosition !== scrollPosition, "aria-disabled": menuLevel.scrollPosition !== scrollPosition, "data-testid": `mobile-nav-menu-level-${level}`, "$isInView": menuLevel.scrollPosition === scrollPosition }, menuLevel.scrollPosition === scrollPosition && (React__default.default.createElement(SubMenuMobile, { currentLevel: level, menuItem: menuItem, mobileMenuRef: mobileMenuRef }))));
|
|
160
166
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
161
167
|
renderMenuList(0, 1, mainNavigation),
|
|
162
168
|
menuLevel.level1Mobile !== null &&
|
|
@@ -170,16 +176,13 @@ const RenderMobileMenu = () => {
|
|
|
170
176
|
const slidingMenuAnimation = reactSpring.useSpring({
|
|
171
177
|
transform: `translateX(${(menuLevel.scrollPosition / navigation.menuLevelsAmount) * -100}%)`,
|
|
172
178
|
});
|
|
173
|
-
const mobileMenuContext = React.useMemo(() => ({
|
|
174
|
-
mobileMenuRef,
|
|
175
|
-
}), [mobileMenuRef]);
|
|
176
179
|
if (!isMobileMenuOpen) {
|
|
177
180
|
return null;
|
|
178
181
|
}
|
|
179
|
-
return (React__default.default.createElement(MobileMenuContainer, { ref: mobileMenuRef },
|
|
180
|
-
React__default.default.createElement(
|
|
181
|
-
React__default.default.createElement(
|
|
182
|
-
React__default.default.createElement(NavigationMenuMobile, null)))));
|
|
182
|
+
return (React__default.default.createElement(MobileMenuContainer, { ref: mobileMenuRef, role: "dialog", "aria-modal": "true" },
|
|
183
|
+
React__default.default.createElement(MobileMenuWrapper, { style: slidingMenuAnimation },
|
|
184
|
+
React__default.default.createElement(NavigationMenuMobile, { mobileMenuRef: mobileMenuRef }))));
|
|
183
185
|
};
|
|
184
186
|
|
|
187
|
+
exports.MenuItemBackLink = MenuItemBackLink;
|
|
185
188
|
exports.default = RenderMobileMenu;
|