@dnanpm/styleguide 3.9.9 → 3.9.11
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/Chip/Chip.d.ts +18 -5
- package/build/cjs/components/Chip/Chip.js +32 -8
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.d.ts +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +7 -10
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/cjs/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +17 -26
- package/build/cjs/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +1 -1
- package/build/cjs/components/MainHeaderNavigation/globalNavStyles.js +4 -19
- package/build/cjs/components/Notification/Notification.d.ts +18 -4
- package/build/cjs/components/Notification/Notification.js +25 -10
- package/build/cjs/components/NotificationBadge/NotificationBadge.d.ts +5 -1
- package/build/cjs/components/NotificationBadge/NotificationBadge.js +16 -2
- package/build/cjs/components/Pill/Pill.d.ts +15 -2
- package/build/cjs/components/Pill/Pill.js +61 -20
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.d.ts +13 -1
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.js +67 -28
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/cjs/components/Toaster/Toaster.d.ts +1 -1
- package/build/cjs/components/Toaster/Toaster.js +6 -7
- package/build/cjs/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/cjs/components/Tooltip/Tooltip.js +46 -6
- package/build/es/components/Chip/Chip.d.ts +18 -5
- package/build/es/components/Chip/Chip.js +32 -8
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.d.ts +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/DesktopMenu.js +7 -10
- package/build/es/components/MainHeaderNavigation/ChildComponents/LinkModifier.js +2 -2
- package/build/es/components/MainHeaderNavigation/ChildComponents/MobileMenu.js +18 -27
- package/build/es/components/MainHeaderNavigation/context/MobileMenuContext.d.ts +1 -1
- package/build/es/components/MainHeaderNavigation/globalNavStyles.js +4 -19
- package/build/es/components/Notification/Notification.d.ts +18 -4
- package/build/es/components/Notification/Notification.js +26 -11
- package/build/es/components/NotificationBadge/NotificationBadge.d.ts +5 -1
- package/build/es/components/NotificationBadge/NotificationBadge.js +16 -2
- package/build/es/components/Pill/Pill.d.ts +15 -2
- package/build/es/components/Pill/Pill.js +61 -20
- package/build/es/components/PriorityNavigation/PriorityNavigation.d.ts +13 -1
- package/build/es/components/PriorityNavigation/PriorityNavigation.js +68 -29
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/es/components/Toaster/Toaster.d.ts +1 -1
- package/build/es/components/Toaster/Toaster.js +6 -7
- package/build/es/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/es/components/Tooltip/Tooltip.js +46 -6
- package/package.json +8 -8
|
@@ -7,41 +7,78 @@ var React = require('react');
|
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var theme = require('../../themes/theme.js');
|
|
9
9
|
var styledUtils = require('../../utils/styledUtils.js');
|
|
10
|
+
var Button = require('../Button/Button.js');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
13
|
|
|
13
14
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
15
|
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
const getBackgroundColor = ({ isChecked, isDisabled }) => {
|
|
17
|
+
const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
|
|
18
18
|
const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
|
|
19
|
-
const
|
|
19
|
+
const bgColor = isChecked
|
|
20
20
|
? theme.default.color.background.plum.default
|
|
21
21
|
: theme.default.color.background.orange.E02;
|
|
22
|
-
// Only Pill component specific colors to be used on user interaction styles
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const hoverBgColor = isChecked ? '#441632' : '#FFB557'; // Only Pill component specific colors to be used on user interaction styles
|
|
23
|
+
const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.black;
|
|
24
|
+
const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
|
|
25
|
+
return `
|
|
26
|
+
font-size: ${theme.default.fontSize.s};
|
|
27
|
+
font-weight: ${theme.default.fontWeight.medium};
|
|
28
|
+
padding: 2px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
|
|
29
|
+
background-color: ${bgColor}${alphaValue};
|
|
30
|
+
color: ${disabledTextColor};
|
|
31
|
+
border: 2px solid transparent;
|
|
32
|
+
${!isDisabled ? `&:hover { background-color: ${hoverBgColor}; }` : ''}
|
|
33
|
+
`;
|
|
34
|
+
};
|
|
35
|
+
const getDefaultButtonStyles = ({ isChecked, isDisabled, }) => {
|
|
36
|
+
const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
|
|
37
|
+
const hoverColor = '#441632'; // Only Pill component specific colors to be used on user interaction styles
|
|
38
|
+
const disabledBgColor = isDisabled ? theme.default.color.default.plum : Button.shade.plum.lighter;
|
|
39
|
+
const bgColor = isChecked ? disabledBgColor : 'transparent';
|
|
40
|
+
const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.plum;
|
|
41
|
+
const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
|
|
42
|
+
const disabledBorderColor = isDisabled ? 'transparent' : Button.shade.plum.lighter;
|
|
43
|
+
const borderColor = isChecked
|
|
44
|
+
? disabledBorderColor
|
|
45
|
+
: `${theme.default.color.default.plum}${alphaValue}`;
|
|
46
|
+
return `
|
|
47
|
+
font-size: ${theme.default.fontSize.default};
|
|
48
|
+
font-weight: ${theme.default.fontWeight.bold};
|
|
49
|
+
padding: 6px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
|
|
50
|
+
background-color: ${bgColor}${alphaValue};
|
|
51
|
+
color: ${disabledTextColor};
|
|
52
|
+
border: 2px solid ${borderColor};
|
|
53
|
+
${!isDisabled
|
|
54
|
+
? `
|
|
55
|
+
&:hover {
|
|
56
|
+
border: 2px solid ${hoverColor};
|
|
57
|
+
color: ${theme.default.color.default.white};
|
|
58
|
+
background-color: ${hoverColor};
|
|
59
|
+
}`
|
|
60
|
+
: ''}
|
|
61
|
+
`;
|
|
27
62
|
};
|
|
28
63
|
const Label = styled__default.default.label `
|
|
64
|
+
all: unset;
|
|
65
|
+
position: relative;
|
|
29
66
|
display: inline-block;
|
|
30
67
|
border-radius: ${theme.default.radius.pill};
|
|
31
|
-
font-size: ${theme.default.fontSize.s};
|
|
32
68
|
line-height: ${theme.default.lineHeight.default};
|
|
33
|
-
font-weight: ${theme.default.fontWeight.medium};
|
|
34
|
-
color: ${({ isChecked }) => isChecked ? theme.default.color.default.white : theme.default.color.default.black};
|
|
35
|
-
border: 2px solid transparent;
|
|
36
|
-
padding: 2px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
|
|
37
69
|
text-align: center;
|
|
70
|
+
transition: all 0.2s ease-in-out;
|
|
71
|
+
|
|
72
|
+
${({ isChecked, isDisabled, isDefaultButtonStyle }) => isDefaultButtonStyle
|
|
73
|
+
? getDefaultButtonStyles({ isChecked, isDisabled })
|
|
74
|
+
: getStandardPillStyles({ isChecked, isDisabled })}
|
|
38
75
|
|
|
39
|
-
${({ isDisabled
|
|
40
|
-
${({ isChecked, isDisabled }) => getBackgroundColor({ isChecked, isDisabled })}
|
|
76
|
+
${({ isDisabled }) => `cursor: ${isDisabled ? 'not-allowed' : 'pointer'};`}
|
|
41
77
|
|
|
42
78
|
&:focus-within, *:focus > & {
|
|
43
|
-
|
|
44
|
-
|
|
79
|
+
outline: none;
|
|
80
|
+
box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
|
|
81
|
+
0px 0px 0px 4px ${theme.default.color.focus.dark};
|
|
45
82
|
}
|
|
46
83
|
|
|
47
84
|
${({ position }) => (position === 'right' || position === 'middle') &&
|
|
@@ -73,7 +110,10 @@ const Input = styled__default.default.input `
|
|
|
73
110
|
border: 0 none;
|
|
74
111
|
margin: 0;
|
|
75
112
|
width: 0;
|
|
76
|
-
height:
|
|
113
|
+
height: 100%;
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 0;
|
|
116
|
+
left: 0;
|
|
77
117
|
|
|
78
118
|
&:focus-visible {
|
|
79
119
|
outline: 0 none;
|
|
@@ -81,9 +121,10 @@ const Input = styled__default.default.input `
|
|
|
81
121
|
`;
|
|
82
122
|
const Pill = (_a) => {
|
|
83
123
|
var { type = 'none', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
84
|
-
|
|
124
|
+
const isDefaultType = type === 'none';
|
|
125
|
+
return (React__default.default.createElement(Label, { as: isDefaultType ? 'button' : 'label', id: isDefaultType ? props.id : undefined, htmlFor: !isDefaultType ? props.id : undefined, type: isDefaultType ? 'button' : undefined, position: props.position, isChecked: props.isChecked || props.isDefaultChecked, isDisabled: props.isDisabled, className: props.className, "data-testid": dataTestId, isDefaultButtonStyle: props.isDefaultButtonStyle, "aria-label": props.ariaLabel, disabled: isDefaultType ? props.isDisabled : undefined },
|
|
85
126
|
props.children,
|
|
86
|
-
|
|
127
|
+
!isDefaultType && (React__default.default.createElement(Input, { id: props.id, name: props.name, type: type, defaultChecked: props.isDefaultChecked, checked: props.isChecked, value: props.value, onChange: props.onChange, disabled: props.isDisabled, readOnly: !props.onChange, "data-testid": dataTestId && `${dataTestId}-input` }))));
|
|
87
128
|
};
|
|
88
129
|
|
|
89
130
|
exports.default = Pill;
|
|
@@ -49,10 +49,22 @@ interface Props {
|
|
|
49
49
|
* Allows to pass testid string for testing purposes
|
|
50
50
|
*/
|
|
51
51
|
'data-testid'?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Allows to pass a custom aria-label for mobile dropdown button
|
|
54
|
+
*/
|
|
55
|
+
mobileDropdownAriaLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Allows to pass a custom aria-label for current page
|
|
58
|
+
*/
|
|
59
|
+
currentPageAriaLabel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Allows to pass a custom aria-label for open more subpages button
|
|
62
|
+
*/
|
|
63
|
+
openMoreSubpagesAriaLabel?: string;
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
54
66
|
* @visibleName Priority Navigation
|
|
55
67
|
*/
|
|
56
|
-
declare const PriorityNavigation: ({ dropdownButtonLabel, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
68
|
+
declare const PriorityNavigation: ({ dropdownButtonLabel, "data-testid": dataTestId, mobileDropdownAriaLabel, currentPageAriaLabel, openMoreSubpagesAriaLabel, ...props }: Props) => React.JSX.Element;
|
|
57
69
|
/** @component */
|
|
58
70
|
export default PriorityNavigation;
|
|
@@ -24,13 +24,15 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
24
24
|
const Container = styled.default.div `
|
|
25
25
|
width: 100%;
|
|
26
26
|
|
|
27
|
-
${styledUtils.media.md `
|
|
28
|
-
border-bottom: 1px solid ${theme.default.color.line.L03};
|
|
29
|
-
`}
|
|
27
|
+
${styledUtils.media.md ` border-bottom: 1px solid ${theme.default.color.line.L03}; `}
|
|
30
28
|
`;
|
|
31
|
-
const Category = styled.default.
|
|
29
|
+
const Category = styled.default.span `
|
|
32
30
|
margin: 0;
|
|
33
31
|
color: ${theme.default.color.text.black};
|
|
32
|
+
font-size: ${theme.default.fontSize.h4};
|
|
33
|
+
font-weight: ${theme.default.fontWeight.bold};
|
|
34
|
+
line-height: ${theme.default.lineHeight.h4};
|
|
35
|
+
display: block;
|
|
34
36
|
|
|
35
37
|
${styledUtils.media.md `
|
|
36
38
|
padding: 1.25rem 0.25rem 0;
|
|
@@ -135,6 +137,18 @@ const DropdownList = styled.default(CoreULStyles) `
|
|
|
135
137
|
|
|
136
138
|
${common.default({ elevation: 'low' })}
|
|
137
139
|
`;
|
|
140
|
+
const VisuallyHidden = styled.default.span `
|
|
141
|
+
position: absolute;
|
|
142
|
+
width: 1px;
|
|
143
|
+
height: 1px;
|
|
144
|
+
padding: 0;
|
|
145
|
+
margin: -1px;
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
clip: rect(0 0 0 0);
|
|
148
|
+
clip-path: inset(50%);
|
|
149
|
+
white-space: nowrap;
|
|
150
|
+
border: 0;
|
|
151
|
+
`;
|
|
138
152
|
const reducer = (state, action) => {
|
|
139
153
|
var _a, _b;
|
|
140
154
|
switch (action.type) {
|
|
@@ -193,10 +207,11 @@ const getReactNodeText = (reactNode) => {
|
|
|
193
207
|
* @visibleName Priority Navigation
|
|
194
208
|
*/
|
|
195
209
|
const PriorityNavigation = (_a) => {
|
|
196
|
-
var { dropdownButtonLabel = 'Lisää', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["dropdownButtonLabel", 'data-testid']);
|
|
210
|
+
var { dropdownButtonLabel = 'Lisää', 'data-testid': dataTestId, mobileDropdownAriaLabel, currentPageAriaLabel, openMoreSubpagesAriaLabel } = _a, props = tslib.__rest(_a, ["dropdownButtonLabel", 'data-testid', "mobileDropdownAriaLabel", "currentPageAriaLabel", "openMoreSubpagesAriaLabel"]);
|
|
197
211
|
const listsContainerRef = React.useRef(null);
|
|
198
212
|
const navigationListRef = React.useRef(null);
|
|
199
213
|
const dropdownButtonRef = React.useRef(null);
|
|
214
|
+
const categoryId = React.useId();
|
|
200
215
|
const { isMobile } = useWindowSize.default(theme.default.breakpoints.md);
|
|
201
216
|
const { width: wrapperContainerWidth } = useResizeObserver.default(listsContainerRef);
|
|
202
217
|
const [isMobileNavigationOpen, setIsMobileNavigationOpen] = React.useState(false);
|
|
@@ -258,42 +273,66 @@ const PriorityNavigation = (_a) => {
|
|
|
258
273
|
});
|
|
259
274
|
React.useEffect(() => {
|
|
260
275
|
if (!isMobile) {
|
|
261
|
-
|
|
276
|
+
dispatch({
|
|
277
|
+
type: 'resetNavigationState',
|
|
278
|
+
payload: {
|
|
279
|
+
navigationItems: props.children,
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
setIsMobileNavigationOpen(false);
|
|
284
|
+
}, [isMobile, props.children]);
|
|
285
|
+
React.useLayoutEffect(() => {
|
|
286
|
+
if (!isMobile) {
|
|
287
|
+
requestAnimationFrame(() => {
|
|
288
|
+
checkHorizontalOverflow();
|
|
289
|
+
});
|
|
262
290
|
}
|
|
263
291
|
}, [
|
|
264
|
-
|
|
265
|
-
state.dropdownItems,
|
|
292
|
+
isMobile,
|
|
266
293
|
wrapperContainerWidth,
|
|
294
|
+
state.navigationItems.length,
|
|
295
|
+
state.dropdownItems.length,
|
|
267
296
|
checkHorizontalOverflow,
|
|
268
|
-
isMobile,
|
|
269
297
|
]);
|
|
270
|
-
React.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
298
|
+
const handleNavigationListKeyDown = React.useCallback((e) => {
|
|
299
|
+
var _a;
|
|
300
|
+
if (isMobile && isMobileNavigationOpen && e.key === 'Tab') {
|
|
301
|
+
const focusableElements = (_a = navigationListRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a, button, input, [tabindex]:not([tabindex="-1"])');
|
|
302
|
+
const lastElement = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements[focusableElements.length - 1];
|
|
303
|
+
if (document.activeElement === lastElement) {
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
setIsMobileNavigationOpen(false);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}, [isMobile, isMobileNavigationOpen]);
|
|
279
309
|
return (React__default.default.createElement(Container, { id: props.id, className: props.className, "data-testid": dataTestId },
|
|
280
|
-
!isMobile && props.categoryLabel && React__default.default.createElement(Category,
|
|
281
|
-
React__default.default.createElement("nav", { "aria-
|
|
310
|
+
!isMobile && props.categoryLabel && (React__default.default.createElement(Category, { id: categoryId }, props.categoryLabel)),
|
|
311
|
+
React__default.default.createElement("nav", { "aria-labelledby": categoryId },
|
|
282
312
|
React__default.default.createElement(ListsContainer, { ref: listsContainerRef },
|
|
283
|
-
isMobile && selectedItem && (React__default.default.createElement(MobileDropdown, { onClick: toggleMobileNavigation, "aria-label":
|
|
284
|
-
(props.dropdownButtonAriaLabel &&
|
|
285
|
-
`${props.dropdownButtonAriaLabel}: ${selectedItem}`), "aria-expanded": isMobileNavigationOpen, isCategoryLabel: Boolean(props.categoryLabel) },
|
|
313
|
+
isMobile && selectedItem && (React__default.default.createElement(MobileDropdown, { onClick: toggleMobileNavigation, "aria-label": mobileDropdownAriaLabel !== null && mobileDropdownAriaLabel !== void 0 ? mobileDropdownAriaLabel : `${props.categoryLabel ? `${props.categoryLabel}, ` : ''}${selectedItem}.`, "aria-expanded": isMobileNavigationOpen, isCategoryLabel: Boolean(props.categoryLabel) },
|
|
286
314
|
React__default.default.createElement(MobileDropdownContent, null,
|
|
287
315
|
props.categoryLabel && React__default.default.createElement(Category, null, props.categoryLabel),
|
|
288
316
|
selectedItem),
|
|
289
317
|
React__default.default.createElement(Icon.default, { icon: isMobileNavigationOpen ? icons.OvalChevronUp : icons.OvalChevronDown, size: "2.5rem" }))),
|
|
290
|
-
React__default.default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen }, React.Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) =>
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
318
|
+
React__default.default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen, onKeyDown: handleNavigationListKeyDown }, React.Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) => {
|
|
319
|
+
if (React.isValidElement(navigationItem) &&
|
|
320
|
+
navigationItem.type === PriorityNavigationItem.default) {
|
|
321
|
+
return (React__default.default.createElement(PriorityNavigationItem.default, { id: navigationItem.props.id, key: navigationItem.key, onClick: navigationItem.props.onClick || props.onClick, onKeyDown: navigationItem.props.onKeyDown || props.onKeyDown, isActive: navigationItem.props.isActive, className: navigationItem.props.className, "data-testid": navigationItem.props['data-testid'], innerRef: instance => instance && navigationItems.set(index, instance) },
|
|
322
|
+
navigationItem.props.isActive
|
|
323
|
+
? React.cloneElement(navigationItem.props.children, {
|
|
324
|
+
'aria-current': 'page',
|
|
325
|
+
})
|
|
326
|
+
: navigationItem.props.children,
|
|
327
|
+
navigationItem.props.isActive && isMobile && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
328
|
+
React__default.default.createElement(Icon.default, { icon: icons.Check, "aria-hidden": true, color: theme.default.color.default.pink }),
|
|
329
|
+
React__default.default.createElement(VisuallyHidden, null, currentPageAriaLabel)))));
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
})),
|
|
294
333
|
!isMobile && Boolean(state.dropdownItems.length) && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
295
334
|
React__default.default.createElement("div", { ref: dropdownButtonRef },
|
|
296
|
-
React__default.default.createElement(ButtonIcon.default, { onClick: toggleDropdown, icon: isDropdownListOpen ? icons.ChevronUp : icons.ChevronDown, isReversed: true }, dropdownButtonLabel)),
|
|
335
|
+
React__default.default.createElement(ButtonIcon.default, { ariaLabel: openMoreSubpagesAriaLabel, ariaExpanded: isDropdownListOpen, onClick: toggleDropdown, icon: isDropdownListOpen ? icons.ChevronUp : icons.ChevronDown, isReversed: true, "data-testid": "dropdown-button" }, dropdownButtonLabel)),
|
|
297
336
|
React__default.default.createElement(DropdownList, { isDropdownListOpen: isDropdownListOpen }, state.dropdownItems.map(dropdownItem => React.isValidElement(dropdownItem) &&
|
|
298
337
|
dropdownItem.type === PriorityNavigationItem.default && (React__default.default.createElement(PriorityNavigationItem.default, { id: dropdownItem.props.id, key: dropdownItem.key, onClick: dropdownItem.props.onClick || props.onClick, onKeyDown: dropdownItem.props.onKeyDown || props.onKeyDown, isActive: dropdownItem.props.isActive, className: dropdownItem.props.className, "data-testid": dropdownItem.props['data-testid'] }, dropdownItem.props.children))))))))));
|
|
299
338
|
};
|
|
@@ -37,6 +37,6 @@ export interface Props {
|
|
|
37
37
|
/**
|
|
38
38
|
* @visibleName Priority NavigationItem
|
|
39
39
|
*/
|
|
40
|
-
declare const PriorityNavigationItem:
|
|
40
|
+
declare const PriorityNavigationItem: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLLIElement>>;
|
|
41
41
|
/** @component */
|
|
42
42
|
export default PriorityNavigationItem;
|
|
@@ -21,10 +21,7 @@ const Element = styled.default.li `
|
|
|
21
21
|
padding: 0.75rem 1.25rem;
|
|
22
22
|
flex-shrink: 0;
|
|
23
23
|
|
|
24
|
-
${({ onClick }) => onClick &&
|
|
25
|
-
`
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
`};
|
|
24
|
+
${({ onClick }) => onClick && `cursor: pointer;`}
|
|
28
25
|
|
|
29
26
|
&:focus-within {
|
|
30
27
|
& > *:not(a, span.dnasg-icon) {
|
|
@@ -45,6 +42,7 @@ const Element = styled.default.li `
|
|
|
45
42
|
|
|
46
43
|
& > a {
|
|
47
44
|
text-decoration: none;
|
|
45
|
+
|
|
48
46
|
&:focus-visible {
|
|
49
47
|
border-radius: ${theme.default.radius.s};
|
|
50
48
|
border: 2px solid ${theme.default.color.focus.light};
|
|
@@ -56,7 +54,7 @@ const Element = styled.default.li `
|
|
|
56
54
|
& > * {
|
|
57
55
|
display: block;
|
|
58
56
|
color: ${({ isActive }) => (isActive ? theme.default.color.text.pink : theme.default.color.text.black)};
|
|
59
|
-
${({ isActive }) => isActive && `font-weight: ${theme.default.fontWeight.bold}
|
|
57
|
+
${({ isActive }) => isActive && `font-weight: ${theme.default.fontWeight.bold};`}
|
|
60
58
|
border: 2px solid transparent;
|
|
61
59
|
|
|
62
60
|
&:hover {
|
|
@@ -68,9 +66,10 @@ const Element = styled.default.li `
|
|
|
68
66
|
/**
|
|
69
67
|
* @visibleName Priority NavigationItem
|
|
70
68
|
*/
|
|
71
|
-
const PriorityNavigationItem = (_a) => {
|
|
69
|
+
const PriorityNavigationItem = React__default.default.forwardRef((_a, ref) => {
|
|
72
70
|
var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
|
|
73
|
-
return (React__default.default.createElement(Element, { id: props.id, ref:
|
|
74
|
-
};
|
|
71
|
+
return (React__default.default.createElement(Element, { id: props.id, ref: ref, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
|
|
72
|
+
});
|
|
73
|
+
PriorityNavigationItem.displayName = 'PriorityNavigationItem';
|
|
75
74
|
|
|
76
75
|
exports.default = PriorityNavigationItem;
|
|
@@ -40,6 +40,6 @@ interface Props {
|
|
|
40
40
|
*/
|
|
41
41
|
onClickCloseButton?: (e: MouseEvent<HTMLElement>) => void;
|
|
42
42
|
}
|
|
43
|
-
declare const Toaster: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
|
|
43
|
+
declare const Toaster: ({ type, "data-testid": dataTestId, closeLabel, ...props }: Props) => React.JSX.Element | null;
|
|
44
44
|
/** @component */
|
|
45
45
|
export default Toaster;
|
|
@@ -54,17 +54,16 @@ const ButtonCloseStyled = styled__default.default(ButtonClose.default) `
|
|
|
54
54
|
top: auto;
|
|
55
55
|
`;
|
|
56
56
|
const Toaster = (_a) => {
|
|
57
|
-
var { type = 'info', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
58
|
-
if (props.dismissed)
|
|
57
|
+
var { type = 'info', 'data-testid': dataTestId, closeLabel } = _a, props = tslib.__rest(_a, ["type", 'data-testid', "closeLabel"]);
|
|
58
|
+
if (props.dismissed)
|
|
59
59
|
return null;
|
|
60
|
-
}
|
|
61
|
-
return (React__default.default.createElement(ToasterWrapper, { role: "alert", "aria-live": "assertive", "aria-atomic": "true", className: props.className, "data-testid": dataTestId },
|
|
60
|
+
return (React__default.default.createElement(ToasterWrapper, { className: props.className, "data-testid": dataTestId, role: "alert", "aria-live": "assertive", "aria-atomic": "true" },
|
|
62
61
|
React__default.default.createElement(StyledBox, { type: type, padding: styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1), elevation: "extraHigh" },
|
|
63
62
|
React__default.default.createElement(IconWrapper, null,
|
|
64
|
-
React__default.default.createElement(Icon.default, { icon: iconsMap[type], size: "2rem", color: theme.default.color.notification[type] })),
|
|
63
|
+
React__default.default.createElement(Icon.default, { icon: iconsMap[type], size: "2rem", color: theme.default.color.notification[type], "aria-hidden": true, "data-testid": "toaster-icon" })),
|
|
65
64
|
React__default.default.createElement(ContentWrapper, null, props.children),
|
|
66
|
-
React__default.default.createElement(ButtonCloseStyled, { "aria-label":
|
|
67
|
-
React__default.default.createElement(Icon.default, { icon: icons.Close, color: theme.default.color.text.black })))));
|
|
65
|
+
React__default.default.createElement(ButtonCloseStyled, { "aria-label": closeLabel, onClick: props.onClickCloseButton },
|
|
66
|
+
React__default.default.createElement(Icon.default, { icon: icons.Close, color: theme.default.color.text.black, "aria-hidden": true })))));
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
exports.default = Toaster;
|
|
@@ -46,10 +46,14 @@ interface Props {
|
|
|
46
46
|
closeWithEsc?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Allows to open Tooltip by clicking the trigger element instead of hovering it
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
49
51
|
*/
|
|
50
52
|
isClickable?: boolean;
|
|
51
53
|
/**
|
|
52
54
|
* Allows to keep Tooltip open when hovered. Useful when it contains interactive elements
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
53
57
|
*/
|
|
54
58
|
isHoverable?: boolean;
|
|
55
59
|
/**
|
|
@@ -66,6 +70,6 @@ interface Props {
|
|
|
66
70
|
*/
|
|
67
71
|
'data-testid'?: string;
|
|
68
72
|
}
|
|
69
|
-
declare const Tooltip: ({ "data-testid": dataTestId, closeWithEsc, ...props }: Props) => React.JSX.Element;
|
|
73
|
+
declare const Tooltip: ({ "data-testid": dataTestId, closeWithEsc, isClickable, isHoverable, ...props }: Props) => React.JSX.Element;
|
|
70
74
|
/** @component */
|
|
71
75
|
export default Tooltip;
|
|
@@ -16,9 +16,28 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
16
|
|
|
17
17
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
18
18
|
|
|
19
|
-
const Helper = styled.default.
|
|
20
|
-
display: inline;
|
|
19
|
+
const Helper = styled.default.button `
|
|
20
|
+
display: inline-block;
|
|
21
21
|
vertical-align: middle;
|
|
22
|
+
background: transparent;
|
|
23
|
+
border: none;
|
|
24
|
+
padding: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
color: inherit;
|
|
27
|
+
font: inherit;
|
|
28
|
+
text-align: inherit;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
outline: inherit;
|
|
31
|
+
pointer-events: auto;
|
|
32
|
+
height: 1rem;
|
|
33
|
+
|
|
34
|
+
&:focus-visible {
|
|
35
|
+
outline: none;
|
|
36
|
+
box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
|
|
37
|
+
0px 0px 0px 4px ${theme.default.color.focus.dark};
|
|
38
|
+
border-radius: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
22
41
|
${({ isClickable }) => isClickable && `cursor: pointer`};
|
|
23
42
|
`;
|
|
24
43
|
const getArrowOverrides = () => {
|
|
@@ -65,11 +84,32 @@ const StyledReactTooltip = styled.default(reactTooltip.Tooltip) `
|
|
|
65
84
|
${getArrowOverrides()}
|
|
66
85
|
`;
|
|
67
86
|
const Tooltip = (_a) => {
|
|
68
|
-
var { 'data-testid': dataTestId, closeWithEsc = true } = _a, props = tslib.__rest(_a, ['data-testid', "closeWithEsc"]);
|
|
87
|
+
var { 'data-testid': dataTestId, closeWithEsc = true, isClickable = false, isHoverable = false } = _a, props = tslib.__rest(_a, ['data-testid', "closeWithEsc", "isClickable", "isHoverable"]);
|
|
88
|
+
const handleReactTooltipOpenEvents = {
|
|
89
|
+
mouseover: !isClickable,
|
|
90
|
+
focus: !isClickable,
|
|
91
|
+
mouseenter: !isClickable,
|
|
92
|
+
mousedown: !isClickable && !isHoverable,
|
|
93
|
+
click: isClickable,
|
|
94
|
+
dblclick: isClickable,
|
|
95
|
+
};
|
|
96
|
+
const handleReactTooltipCloseEvents = {
|
|
97
|
+
mouseout: !isClickable && !isHoverable,
|
|
98
|
+
blur: !isClickable && !isHoverable,
|
|
99
|
+
mouseleave: !isClickable,
|
|
100
|
+
mouseup: !isClickable,
|
|
101
|
+
click: isClickable,
|
|
102
|
+
dblclick: isClickable,
|
|
103
|
+
};
|
|
104
|
+
const handleReactTooltipGlobalCloseEvents = {
|
|
105
|
+
escape: closeWithEsc,
|
|
106
|
+
clickOutsideAnchor: true,
|
|
107
|
+
scroll: true,
|
|
108
|
+
};
|
|
69
109
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
70
|
-
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, isClickable:
|
|
71
|
-
React__default.default.createElement(Icon.default, { icon: icons.Info, size: "1rem", position: props.position }))),
|
|
72
|
-
React__default.default.createElement(StyledReactTooltip, { id: props.id, place: props.placement,
|
|
110
|
+
!props.hideTriggerElement && (React__default.default.createElement(Helper, { "data-tooltip-id": props.id, isClickable: isClickable, className: props.className, "data-testid": dataTestId, type: "button", "data-tooltip-delay-hide": 500, "aria-describedby": props.id },
|
|
111
|
+
React__default.default.createElement(Icon.default, { icon: icons.Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
112
|
+
React__default.default.createElement(StyledReactTooltip, { id: props.id, place: props.placement, openOnClick: isClickable, clickable: isHoverable, isMultiline: props.isMultiline, disableStyleInjection: true, role: isHoverable ? 'dialog' : 'tooltip', openEvents: handleReactTooltipOpenEvents, globalCloseEvents: handleReactTooltipGlobalCloseEvents, closeEvents: handleReactTooltipCloseEvents, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
|
|
73
113
|
};
|
|
74
114
|
|
|
75
115
|
exports.default = Tooltip;
|
|
@@ -10,20 +10,24 @@ interface Props {
|
|
|
10
10
|
/**
|
|
11
11
|
* Allows to change the color styling of component, depending on the passed type
|
|
12
12
|
*
|
|
13
|
-
* @param {ChipType} default Uses `theme.color.line.L01`
|
|
14
|
-
* @param {ChipType} info
|
|
13
|
+
* @param {ChipType} default Uses default color: `theme.color.line.L01`
|
|
14
|
+
* @param {ChipType} info Changes color to default color (this type will be deprecated in the future)
|
|
15
15
|
* @param {ChipType} success Uses `theme.color.notification.success` color for styling
|
|
16
|
-
* @param {ChipType} warning
|
|
16
|
+
* @param {ChipType} warning Changes color to default color (this type will be deprecated in the future)
|
|
17
17
|
* @param {ChipType} error Uses `theme.color.notification.error` color for styling
|
|
18
18
|
*
|
|
19
|
+
* @deprecated The 'info' and 'warning' types will be deprecated and removed in the next major release.
|
|
20
|
+
*
|
|
19
21
|
* @default 'default'
|
|
20
22
|
*/
|
|
21
23
|
type?: ChipType;
|
|
22
24
|
/**
|
|
23
25
|
* Allows to change the appearance styling of component, depending on passed variant
|
|
24
26
|
*
|
|
25
|
-
* @param {ChipVariant} outlined
|
|
26
|
-
* @param {ChipVariant} filled
|
|
27
|
+
* @param {ChipVariant} outlined
|
|
28
|
+
* @param {ChipVariant} filled
|
|
29
|
+
*
|
|
30
|
+
* @deprecated The styles are now encapsulated within the component. The 'variant' prop will be removed in the next major release.
|
|
27
31
|
*
|
|
28
32
|
* @default 'outlined'
|
|
29
33
|
*/
|
|
@@ -44,6 +48,15 @@ interface Props {
|
|
|
44
48
|
* Allows to pass testid string for testing purposes
|
|
45
49
|
*/
|
|
46
50
|
'data-testid'?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Allows to pass an accessible label for the component.
|
|
53
|
+
*/
|
|
54
|
+
ariaLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Provides additional information about the Chip not included in the aria-label.
|
|
57
|
+
* This attribute should reference the ID of a related text element for context.
|
|
58
|
+
*/
|
|
59
|
+
ariaDescribedBy?: string;
|
|
47
60
|
}
|
|
48
61
|
declare const Chip: ({ type, variant, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
49
62
|
/** @component */
|
|
@@ -4,14 +4,31 @@ import styled__default from 'styled-components';
|
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
5
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
6
|
|
|
7
|
-
const getStyling = ({ $type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const getStyling = ({ $type }) => {
|
|
8
|
+
switch ($type) {
|
|
9
|
+
case 'success':
|
|
10
|
+
return `
|
|
11
|
+
color: ${theme.color.text.white};
|
|
12
|
+
border: 2px solid ${theme.color.notification.success};
|
|
13
|
+
background-color: ${theme.color.notification.success};
|
|
14
|
+
`;
|
|
15
|
+
case 'error':
|
|
16
|
+
return `
|
|
17
|
+
color: ${theme.color.text.black};
|
|
18
|
+
border: 2px solid ${theme.color.notification.error};
|
|
19
|
+
background-color: ${theme.color.background.white.default};
|
|
20
|
+
`;
|
|
21
|
+
case 'default':
|
|
22
|
+
default:
|
|
23
|
+
return `
|
|
24
|
+
color: ${theme.color.text.black};
|
|
25
|
+
border: 2px solid ${theme.color.line.L01};
|
|
26
|
+
background-color: ${theme.color.background.white.default};
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
13
29
|
};
|
|
14
30
|
const Element = styled__default.div `
|
|
31
|
+
all: unset;
|
|
15
32
|
display: inline-block;
|
|
16
33
|
border-radius: ${theme.radius.pill};
|
|
17
34
|
padding: 1px ${getMultipliedSize(theme.base.baseHeight, 1)};
|
|
@@ -21,11 +38,18 @@ const Element = styled__default.div `
|
|
|
21
38
|
text-align: center;
|
|
22
39
|
${({ onClick }) => onClick && `cursor: pointer`};
|
|
23
40
|
|
|
24
|
-
${({ $type
|
|
41
|
+
${({ $type }) => getStyling({ $type })}
|
|
42
|
+
|
|
43
|
+
&:focus-visible {
|
|
44
|
+
outline: none;
|
|
45
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
46
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
47
|
+
}
|
|
25
48
|
`;
|
|
26
49
|
const Chip = (_a) => {
|
|
27
50
|
var { type = 'default', variant = 'outlined', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", "variant", 'data-testid']);
|
|
28
|
-
|
|
51
|
+
const label = props.ariaLabel || (typeof props.children === 'string' ? props.children : undefined);
|
|
52
|
+
return (React__default.createElement(Element, { as: props.onClick ? 'button' : 'div', id: props.id, "$type": type, "$variant": variant, onClick: props.onClick, className: props.className, "data-testid": dataTestId, "aria-label": label, "aria-describedby": props.ariaDescribedBy, tabIndex: 0 }, props.children));
|
|
29
53
|
};
|
|
30
54
|
|
|
31
55
|
export { Chip as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const DesktopMenu:
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const DesktopMenu: () => React.JSX.Element | null;
|
|
3
3
|
export default DesktopMenu;
|
|
@@ -5,7 +5,6 @@ import styled, { keyframes, css } from '../../../themes/styled.js';
|
|
|
5
5
|
import theme from '../../../themes/theme.js';
|
|
6
6
|
import { navMaxHeight, headerMaxHeight } from '../../../themes/themeComponents/navigation.js';
|
|
7
7
|
import { getMultipliedSize, media } from '../../../utils/styledUtils.js';
|
|
8
|
-
import Icon from '../../Icon/Icon.js';
|
|
9
8
|
import NavContext from '../context/NavContext.js';
|
|
10
9
|
import { MenuList, MenuItem, MenuLinkWithChildren, FeaturedBlock } from '../globalNavStyles.js';
|
|
11
10
|
import LinkModifier, { isSelected } from './LinkModifier.js';
|
|
@@ -69,7 +68,6 @@ const SubMenuItem = styled.li `
|
|
|
69
68
|
> a {
|
|
70
69
|
color: ${p => (p.isHighlighted ? theme.color.text.pink : theme.color.text.black)};
|
|
71
70
|
font-weight: ${p => (p.isHighlighted ? theme.fontWeight.bold : theme.fontWeight.book)};
|
|
72
|
-
}
|
|
73
71
|
}
|
|
74
72
|
`;
|
|
75
73
|
const DesktopMenuList = styled(MenuList) `
|
|
@@ -165,16 +163,16 @@ const MenuItemWithChildren = ({ menuItem, currentLevel }) => {
|
|
|
165
163
|
const menuClickMain = (element) => () => {
|
|
166
164
|
handleNavMenuClick(element.id, 'level1');
|
|
167
165
|
};
|
|
168
|
-
return (React__default.createElement(DesktopMenuItem, { isActive: isSelected(currentUrl, menuItem.urls[lang]), "data-testid": `desktop-nav-item-level-1-${currentLevel + 1}
|
|
169
|
-
React__default.createElement(MenuLinkWithChildren, { isOpen: menuLevel.level1 === menuItem.id, onClick: menuClickMain(menuItem),
|
|
166
|
+
return (React__default.createElement(DesktopMenuItem, { isActive: isSelected(currentUrl, menuItem.urls[lang]), "data-testid": `desktop-nav-item-level-1-${currentLevel + 1}` },
|
|
167
|
+
React__default.createElement(MenuLinkWithChildren, { isOpen: menuLevel.level1 === menuItem.id, onClick: menuClickMain(menuItem), "data-testid": "menu-button-with-children" },
|
|
170
168
|
React__default.createElement("span", null, menuItem.titles[lang]),
|
|
171
|
-
React__default.createElement(
|
|
169
|
+
React__default.createElement(ChevronRight, { size: "1rem" })),
|
|
172
170
|
React__default.createElement(SubMenuLevel1, { menuItem: menuItem })));
|
|
173
171
|
};
|
|
174
172
|
const DesktopMenu = () => {
|
|
175
173
|
var _a;
|
|
176
174
|
const { items, lang, resetMenuEvents, menuLevel, currentUrl, collapseSize } = useContext(NavContext);
|
|
177
|
-
const mainNavigation = ((_a = items
|
|
175
|
+
const mainNavigation = ((_a = items.mainNavigation) === null || _a === void 0 ? void 0 : _a.pages) || [];
|
|
178
176
|
const ref = useRef(null);
|
|
179
177
|
useOutsideClick(ref, () => {
|
|
180
178
|
if (menuLevel.level1 || menuLevel.level2) {
|
|
@@ -184,13 +182,12 @@ const DesktopMenu = () => {
|
|
|
184
182
|
if (!mainNavigation.length) {
|
|
185
183
|
return null;
|
|
186
184
|
}
|
|
187
|
-
return (React__default.createElement(DesktopMenuList, {
|
|
188
|
-
|
|
189
|
-
const displaySubMenu = !navElement.pageIsLinkInDesktopNavigation && !!((_a = navElement.pages) === null || _a === void 0 ? void 0 : _a.length);
|
|
185
|
+
return (React__default.createElement(DesktopMenuList, { "aria-hidden": false, ref: ref, "data-testid": "desktop-nav-menu-ul", collapseSize: collapseSize }, mainNavigation.map((navElement, index) => {
|
|
186
|
+
const displaySubMenu = !navElement.pageIsLinkInDesktopNavigation && !!navElement.pages.length;
|
|
190
187
|
if (displaySubMenu) {
|
|
191
188
|
return (React__default.createElement(MenuItemWithChildren, { menuItem: navElement, key: navElement.id, currentLevel: index }));
|
|
192
189
|
}
|
|
193
|
-
return (React__default.createElement(DesktopMenuItem, { key: navElement.id,
|
|
190
|
+
return (React__default.createElement(DesktopMenuItem, { key: navElement.id, "data-testid": `desktop-nav-item-level-1-${index + 1}`, isActive: isSelected(currentUrl, navElement.urls[lang]) },
|
|
194
191
|
React__default.createElement(LinkModifier, { menuItem: navElement, tabIndex: false })));
|
|
195
192
|
})));
|
|
196
193
|
};
|