@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
2
|
import { OvalChevronUp, OvalChevronDown, Check, ChevronUp, ChevronDown } from '@dnanpm/icons';
|
|
3
|
-
import React__default, { useRef, useState, Children, useReducer, isValidElement, useEffect } from 'react';
|
|
3
|
+
import React__default, { useRef, useId, useState, Children, useReducer, isValidElement, useEffect, useLayoutEffect, useCallback, cloneElement } from 'react';
|
|
4
4
|
import useDebounce from '../../hooks/useDebounce.js';
|
|
5
5
|
import useOutsideClick from '../../hooks/useOutsideClick.js';
|
|
6
6
|
import useResizeObserver from '../../hooks/useResizeObserver.js';
|
|
@@ -16,13 +16,15 @@ import PriorityNavigationItem from '../PriorityNavigationItem/PriorityNavigation
|
|
|
16
16
|
const Container = styled.div `
|
|
17
17
|
width: 100%;
|
|
18
18
|
|
|
19
|
-
${media.md `
|
|
20
|
-
border-bottom: 1px solid ${theme.color.line.L03};
|
|
21
|
-
`}
|
|
19
|
+
${media.md ` border-bottom: 1px solid ${theme.color.line.L03}; `}
|
|
22
20
|
`;
|
|
23
|
-
const Category = styled.
|
|
21
|
+
const Category = styled.span `
|
|
24
22
|
margin: 0;
|
|
25
23
|
color: ${theme.color.text.black};
|
|
24
|
+
font-size: ${theme.fontSize.h4};
|
|
25
|
+
font-weight: ${theme.fontWeight.bold};
|
|
26
|
+
line-height: ${theme.lineHeight.h4};
|
|
27
|
+
display: block;
|
|
26
28
|
|
|
27
29
|
${media.md `
|
|
28
30
|
padding: 1.25rem 0.25rem 0;
|
|
@@ -127,6 +129,18 @@ const DropdownList = styled(CoreULStyles) `
|
|
|
127
129
|
|
|
128
130
|
${getElevationShadow({ elevation: 'low' })}
|
|
129
131
|
`;
|
|
132
|
+
const VisuallyHidden = styled.span `
|
|
133
|
+
position: absolute;
|
|
134
|
+
width: 1px;
|
|
135
|
+
height: 1px;
|
|
136
|
+
padding: 0;
|
|
137
|
+
margin: -1px;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
clip: rect(0 0 0 0);
|
|
140
|
+
clip-path: inset(50%);
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
border: 0;
|
|
143
|
+
`;
|
|
130
144
|
const reducer = (state, action) => {
|
|
131
145
|
var _a, _b;
|
|
132
146
|
switch (action.type) {
|
|
@@ -185,10 +199,11 @@ const getReactNodeText = (reactNode) => {
|
|
|
185
199
|
* @visibleName Priority Navigation
|
|
186
200
|
*/
|
|
187
201
|
const PriorityNavigation = (_a) => {
|
|
188
|
-
var { dropdownButtonLabel = 'Lisää', 'data-testid': dataTestId } = _a, props = __rest(_a, ["dropdownButtonLabel", 'data-testid']);
|
|
202
|
+
var { dropdownButtonLabel = 'Lisää', 'data-testid': dataTestId, mobileDropdownAriaLabel, currentPageAriaLabel, openMoreSubpagesAriaLabel } = _a, props = __rest(_a, ["dropdownButtonLabel", 'data-testid', "mobileDropdownAriaLabel", "currentPageAriaLabel", "openMoreSubpagesAriaLabel"]);
|
|
189
203
|
const listsContainerRef = useRef(null);
|
|
190
204
|
const navigationListRef = useRef(null);
|
|
191
205
|
const dropdownButtonRef = useRef(null);
|
|
206
|
+
const categoryId = useId();
|
|
192
207
|
const { isMobile } = useWindowSize(theme.breakpoints.md);
|
|
193
208
|
const { width: wrapperContainerWidth } = useResizeObserver(listsContainerRef);
|
|
194
209
|
const [isMobileNavigationOpen, setIsMobileNavigationOpen] = useState(false);
|
|
@@ -250,42 +265,66 @@ const PriorityNavigation = (_a) => {
|
|
|
250
265
|
});
|
|
251
266
|
useEffect(() => {
|
|
252
267
|
if (!isMobile) {
|
|
253
|
-
|
|
268
|
+
dispatch({
|
|
269
|
+
type: 'resetNavigationState',
|
|
270
|
+
payload: {
|
|
271
|
+
navigationItems: props.children,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
setIsMobileNavigationOpen(false);
|
|
276
|
+
}, [isMobile, props.children]);
|
|
277
|
+
useLayoutEffect(() => {
|
|
278
|
+
if (!isMobile) {
|
|
279
|
+
requestAnimationFrame(() => {
|
|
280
|
+
checkHorizontalOverflow();
|
|
281
|
+
});
|
|
254
282
|
}
|
|
255
283
|
}, [
|
|
256
|
-
|
|
257
|
-
state.dropdownItems,
|
|
284
|
+
isMobile,
|
|
258
285
|
wrapperContainerWidth,
|
|
286
|
+
state.navigationItems.length,
|
|
287
|
+
state.dropdownItems.length,
|
|
259
288
|
checkHorizontalOverflow,
|
|
260
|
-
isMobile,
|
|
261
289
|
]);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
290
|
+
const handleNavigationListKeyDown = useCallback((e) => {
|
|
291
|
+
var _a;
|
|
292
|
+
if (isMobile && isMobileNavigationOpen && e.key === 'Tab') {
|
|
293
|
+
const focusableElements = (_a = navigationListRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a, button, input, [tabindex]:not([tabindex="-1"])');
|
|
294
|
+
const lastElement = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements[focusableElements.length - 1];
|
|
295
|
+
if (document.activeElement === lastElement) {
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
setIsMobileNavigationOpen(false);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}, [isMobile, isMobileNavigationOpen]);
|
|
271
301
|
return (React__default.createElement(Container, { id: props.id, className: props.className, "data-testid": dataTestId },
|
|
272
|
-
!isMobile && props.categoryLabel && React__default.createElement(Category,
|
|
273
|
-
React__default.createElement("nav", { "aria-
|
|
302
|
+
!isMobile && props.categoryLabel && (React__default.createElement(Category, { id: categoryId }, props.categoryLabel)),
|
|
303
|
+
React__default.createElement("nav", { "aria-labelledby": categoryId },
|
|
274
304
|
React__default.createElement(ListsContainer, { ref: listsContainerRef },
|
|
275
|
-
isMobile && selectedItem && (React__default.createElement(MobileDropdown, { onClick: toggleMobileNavigation, "aria-label":
|
|
276
|
-
(props.dropdownButtonAriaLabel &&
|
|
277
|
-
`${props.dropdownButtonAriaLabel}: ${selectedItem}`), "aria-expanded": isMobileNavigationOpen, isCategoryLabel: Boolean(props.categoryLabel) },
|
|
305
|
+
isMobile && selectedItem && (React__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) },
|
|
278
306
|
React__default.createElement(MobileDropdownContent, null,
|
|
279
307
|
props.categoryLabel && React__default.createElement(Category, null, props.categoryLabel),
|
|
280
308
|
selectedItem),
|
|
281
309
|
React__default.createElement(Icon, { icon: isMobileNavigationOpen ? OvalChevronUp : OvalChevronDown, size: "2.5rem" }))),
|
|
282
|
-
React__default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen }, Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) =>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
310
|
+
React__default.createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen, onKeyDown: handleNavigationListKeyDown }, Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) => {
|
|
311
|
+
if (isValidElement(navigationItem) &&
|
|
312
|
+
navigationItem.type === PriorityNavigationItem) {
|
|
313
|
+
return (React__default.createElement(PriorityNavigationItem, { 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) },
|
|
314
|
+
navigationItem.props.isActive
|
|
315
|
+
? cloneElement(navigationItem.props.children, {
|
|
316
|
+
'aria-current': 'page',
|
|
317
|
+
})
|
|
318
|
+
: navigationItem.props.children,
|
|
319
|
+
navigationItem.props.isActive && isMobile && (React__default.createElement(React__default.Fragment, null,
|
|
320
|
+
React__default.createElement(Icon, { icon: Check, "aria-hidden": true, color: theme.color.default.pink }),
|
|
321
|
+
React__default.createElement(VisuallyHidden, null, currentPageAriaLabel)))));
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
})),
|
|
286
325
|
!isMobile && Boolean(state.dropdownItems.length) && (React__default.createElement(React__default.Fragment, null,
|
|
287
326
|
React__default.createElement("div", { ref: dropdownButtonRef },
|
|
288
|
-
React__default.createElement(ButtonIcon, { onClick: toggleDropdown, icon: isDropdownListOpen ? ChevronUp : ChevronDown, isReversed: true }, dropdownButtonLabel)),
|
|
327
|
+
React__default.createElement(ButtonIcon, { ariaLabel: openMoreSubpagesAriaLabel, ariaExpanded: isDropdownListOpen, onClick: toggleDropdown, icon: isDropdownListOpen ? ChevronUp : ChevronDown, isReversed: true, "data-testid": "dropdown-button" }, dropdownButtonLabel)),
|
|
289
328
|
React__default.createElement(DropdownList, { isDropdownListOpen: isDropdownListOpen }, state.dropdownItems.map(dropdownItem => isValidElement(dropdownItem) &&
|
|
290
329
|
dropdownItem.type === PriorityNavigationItem && (React__default.createElement(PriorityNavigationItem, { 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))))))))));
|
|
291
330
|
};
|
|
@@ -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;
|
|
@@ -13,10 +13,7 @@ const Element = styled.li `
|
|
|
13
13
|
padding: 0.75rem 1.25rem;
|
|
14
14
|
flex-shrink: 0;
|
|
15
15
|
|
|
16
|
-
${({ onClick }) => onClick &&
|
|
17
|
-
`
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
`};
|
|
16
|
+
${({ onClick }) => onClick && `cursor: pointer;`}
|
|
20
17
|
|
|
21
18
|
&:focus-within {
|
|
22
19
|
& > *:not(a, span.dnasg-icon) {
|
|
@@ -37,6 +34,7 @@ const Element = styled.li `
|
|
|
37
34
|
|
|
38
35
|
& > a {
|
|
39
36
|
text-decoration: none;
|
|
37
|
+
|
|
40
38
|
&:focus-visible {
|
|
41
39
|
border-radius: ${theme.radius.s};
|
|
42
40
|
border: 2px solid ${theme.color.focus.light};
|
|
@@ -48,7 +46,7 @@ const Element = styled.li `
|
|
|
48
46
|
& > * {
|
|
49
47
|
display: block;
|
|
50
48
|
color: ${({ isActive }) => (isActive ? theme.color.text.pink : theme.color.text.black)};
|
|
51
|
-
${({ isActive }) => isActive && `font-weight: ${theme.fontWeight.bold}
|
|
49
|
+
${({ isActive }) => isActive && `font-weight: ${theme.fontWeight.bold};`}
|
|
52
50
|
border: 2px solid transparent;
|
|
53
51
|
|
|
54
52
|
&:hover {
|
|
@@ -60,9 +58,10 @@ const Element = styled.li `
|
|
|
60
58
|
/**
|
|
61
59
|
* @visibleName Priority NavigationItem
|
|
62
60
|
*/
|
|
63
|
-
const PriorityNavigationItem = (_a) => {
|
|
61
|
+
const PriorityNavigationItem = React__default.forwardRef((_a, ref) => {
|
|
64
62
|
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
65
|
-
return (React__default.createElement(Element, { id: props.id, ref:
|
|
66
|
-
};
|
|
63
|
+
return (React__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));
|
|
64
|
+
});
|
|
65
|
+
PriorityNavigationItem.displayName = 'PriorityNavigationItem';
|
|
67
66
|
|
|
68
67
|
export { PriorityNavigationItem as default };
|
|
@@ -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;
|
|
@@ -45,17 +45,16 @@ const ButtonCloseStyled = styled__default(ButtonClose) `
|
|
|
45
45
|
top: auto;
|
|
46
46
|
`;
|
|
47
47
|
const Toaster = (_a) => {
|
|
48
|
-
var { type = 'info', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
|
|
49
|
-
if (props.dismissed)
|
|
48
|
+
var { type = 'info', 'data-testid': dataTestId, closeLabel } = _a, props = __rest(_a, ["type", 'data-testid', "closeLabel"]);
|
|
49
|
+
if (props.dismissed)
|
|
50
50
|
return null;
|
|
51
|
-
}
|
|
52
|
-
return (React__default.createElement(ToasterWrapper, { role: "alert", "aria-live": "assertive", "aria-atomic": "true", className: props.className, "data-testid": dataTestId },
|
|
51
|
+
return (React__default.createElement(ToasterWrapper, { className: props.className, "data-testid": dataTestId, role: "alert", "aria-live": "assertive", "aria-atomic": "true" },
|
|
53
52
|
React__default.createElement(StyledBox, { type: type, padding: getMultipliedSize(theme.base.baseWidth, 1), elevation: "extraHigh" },
|
|
54
53
|
React__default.createElement(IconWrapper, null,
|
|
55
|
-
React__default.createElement(Icon, { icon: iconsMap[type], size: "2rem", color: theme.color.notification[type] })),
|
|
54
|
+
React__default.createElement(Icon, { icon: iconsMap[type], size: "2rem", color: theme.color.notification[type], "aria-hidden": true, "data-testid": "toaster-icon" })),
|
|
56
55
|
React__default.createElement(ContentWrapper, null, props.children),
|
|
57
|
-
React__default.createElement(ButtonCloseStyled, { "aria-label":
|
|
58
|
-
React__default.createElement(Icon, { icon: Close, color: theme.color.text.black })))));
|
|
56
|
+
React__default.createElement(ButtonCloseStyled, { "aria-label": closeLabel, onClick: props.onClickCloseButton },
|
|
57
|
+
React__default.createElement(Icon, { icon: Close, color: theme.color.text.black, "aria-hidden": true })))));
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
export { Toaster as default };
|
|
@@ -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;
|
|
@@ -8,9 +8,28 @@ import getElevationShadow from '../../utils/common.js';
|
|
|
8
8
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
9
9
|
import Icon from '../Icon/Icon.js';
|
|
10
10
|
|
|
11
|
-
const Helper = styled.
|
|
12
|
-
display: inline;
|
|
11
|
+
const Helper = styled.button `
|
|
12
|
+
display: inline-block;
|
|
13
13
|
vertical-align: middle;
|
|
14
|
+
background: transparent;
|
|
15
|
+
border: none;
|
|
16
|
+
padding: 0;
|
|
17
|
+
margin: 0;
|
|
18
|
+
color: inherit;
|
|
19
|
+
font: inherit;
|
|
20
|
+
text-align: inherit;
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
outline: inherit;
|
|
23
|
+
pointer-events: auto;
|
|
24
|
+
height: 1rem;
|
|
25
|
+
|
|
26
|
+
&:focus-visible {
|
|
27
|
+
outline: none;
|
|
28
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
29
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
30
|
+
border-radius: 100%;
|
|
31
|
+
}
|
|
32
|
+
|
|
14
33
|
${({ isClickable }) => isClickable && `cursor: pointer`};
|
|
15
34
|
`;
|
|
16
35
|
const getArrowOverrides = () => {
|
|
@@ -57,11 +76,32 @@ const StyledReactTooltip = styled(Tooltip$1) `
|
|
|
57
76
|
${getArrowOverrides()}
|
|
58
77
|
`;
|
|
59
78
|
const Tooltip = (_a) => {
|
|
60
|
-
var { 'data-testid': dataTestId, closeWithEsc = true } = _a, props = __rest(_a, ['data-testid', "closeWithEsc"]);
|
|
79
|
+
var { 'data-testid': dataTestId, closeWithEsc = true, isClickable = false, isHoverable = false } = _a, props = __rest(_a, ['data-testid', "closeWithEsc", "isClickable", "isHoverable"]);
|
|
80
|
+
const handleReactTooltipOpenEvents = {
|
|
81
|
+
mouseover: !isClickable,
|
|
82
|
+
focus: !isClickable,
|
|
83
|
+
mouseenter: !isClickable,
|
|
84
|
+
mousedown: !isClickable && !isHoverable,
|
|
85
|
+
click: isClickable,
|
|
86
|
+
dblclick: isClickable,
|
|
87
|
+
};
|
|
88
|
+
const handleReactTooltipCloseEvents = {
|
|
89
|
+
mouseout: !isClickable && !isHoverable,
|
|
90
|
+
blur: !isClickable && !isHoverable,
|
|
91
|
+
mouseleave: !isClickable,
|
|
92
|
+
mouseup: !isClickable,
|
|
93
|
+
click: isClickable,
|
|
94
|
+
dblclick: isClickable,
|
|
95
|
+
};
|
|
96
|
+
const handleReactTooltipGlobalCloseEvents = {
|
|
97
|
+
escape: closeWithEsc,
|
|
98
|
+
clickOutsideAnchor: true,
|
|
99
|
+
scroll: true,
|
|
100
|
+
};
|
|
61
101
|
return (React__default.createElement(React__default.Fragment, null,
|
|
62
|
-
!props.hideTriggerElement && (React__default.createElement(Helper, { "data-tooltip-id": props.id, isClickable:
|
|
63
|
-
React__default.createElement(Icon, { icon: Info, size: "1rem", position: props.position }))),
|
|
64
|
-
React__default.createElement(StyledReactTooltip, { id: props.id, place: props.placement,
|
|
102
|
+
!props.hideTriggerElement && (React__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 },
|
|
103
|
+
React__default.createElement(Icon, { icon: Info, size: "1rem", position: props.position, "aria-hidden": true }))),
|
|
104
|
+
React__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)));
|
|
65
105
|
};
|
|
66
106
|
|
|
67
107
|
export { Tooltip as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnanpm/styleguide",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "v3.9.
|
|
4
|
+
"version": "v3.9.11",
|
|
5
5
|
"main": "build/cjs/index.js",
|
|
6
6
|
"module": "build/es/index.js",
|
|
7
7
|
"jsnext:main": "build/es/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"styleguide": "styleguidist server",
|
|
32
32
|
"styleguide:build": "styleguidist build",
|
|
33
33
|
"tar": "npm run clean && npm ci && npm run build && npm pack && mv dnanpm-styleguide*.tgz dnanpm-styleguide-snapshot.tgz",
|
|
34
|
-
"test": "cross-env jest --coverage",
|
|
34
|
+
"test": "cross-env jest --maxWorkers=2 --coverage",
|
|
35
35
|
"test:coverage": "rm -rf coverage && cross-env jest --coverage --runInBand --no-cache"
|
|
36
36
|
},
|
|
37
37
|
"browserslist": [
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"@babel/core": "^7.26.10",
|
|
45
45
|
"@babel/preset-env": "^7.26.0",
|
|
46
46
|
"@babel/preset-react": "^7.26.3",
|
|
47
|
-
"@babel/preset-typescript": "^7.27.
|
|
47
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
48
48
|
"@dnanpm/icons": "2.0.7",
|
|
49
49
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
50
50
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
51
51
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
52
52
|
"@testing-library/jest-dom": "^6.6.3",
|
|
53
|
-
"@testing-library/react": "^
|
|
53
|
+
"@testing-library/react": "^16.3.0",
|
|
54
54
|
"@testing-library/user-event": "^14.5.2",
|
|
55
55
|
"@types/jest": "^29.5.14",
|
|
56
56
|
"@types/node": "^14.18.63",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"jest": "^29.7.0",
|
|
80
80
|
"jest-environment-jsdom": "^29.7.0",
|
|
81
81
|
"jest-styled-components": "^7.2.0",
|
|
82
|
-
"mini-css-extract-plugin": "^2.9.
|
|
82
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
83
83
|
"prettier": "^2.8.8",
|
|
84
84
|
"react": "^18.3.1",
|
|
85
85
|
"react-docgen": "^5.4.3",
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
"rollup-plugin-import-css": "^3.5.8",
|
|
91
91
|
"style-loader": "^3.3.3",
|
|
92
92
|
"styled-components": "^5.3.11",
|
|
93
|
-
"ts-jest": "^29.2
|
|
93
|
+
"ts-jest": "^29.3.2",
|
|
94
94
|
"ts-node": "^10.9.2",
|
|
95
95
|
"tslib": "^2.8.1",
|
|
96
96
|
"typescript": "^5.1.6",
|
|
97
|
-
"webpack": "^5.99.
|
|
97
|
+
"webpack": "^5.99.8"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"ramda": "^0.27.1",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"react-modal": "^3.16.1",
|
|
103
103
|
"react-select": "^5.8.1",
|
|
104
104
|
"react-spring": "^8.0.27",
|
|
105
|
-
"react-tooltip": "^5.28.
|
|
105
|
+
"react-tooltip": "^5.28.1"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"@dnanpm/icons": "^2.x",
|