@dnanpm/styleguide 3.9.8 → 3.9.10
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/Carousel/Carousel.d.ts +188 -0
- package/build/cjs/components/Carousel/Carousel.js +23 -10
- package/build/cjs/components/Divider/Divider.d.ts +4 -0
- package/build/cjs/components/Divider/Divider.js +2 -1
- package/build/cjs/components/InfoDialog/InfoDialog.d.ts +4 -0
- package/build/cjs/components/InfoDialog/InfoDialog.js +1 -1
- package/build/cjs/components/Input/Input.js +1 -2
- package/build/cjs/components/LabelText/LabelText.d.ts +5 -3
- package/build/cjs/components/LabelText/LabelText.js +1 -1
- package/build/cjs/components/Notification/Notification.d.ts +18 -4
- package/build/cjs/components/Notification/Notification.js +25 -10
- package/build/cjs/components/Pill/Pill.d.ts +4 -0
- package/build/cjs/components/Pill/Pill.js +52 -16
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/cjs/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/build/cjs/components/ProgressIndicator/ProgressIndicator.js +13 -6
- package/build/cjs/components/ReadMore/ReadMore.d.ts +4 -0
- package/build/cjs/components/ReadMore/ReadMore.js +30 -3
- package/build/cjs/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/cjs/components/Tooltip/Tooltip.js +46 -6
- package/build/es/components/Carousel/Carousel.d.ts +188 -0
- package/build/es/components/Carousel/Carousel.js +23 -11
- package/build/es/components/Divider/Divider.d.ts +4 -0
- package/build/es/components/Divider/Divider.js +2 -1
- package/build/es/components/InfoDialog/InfoDialog.d.ts +4 -0
- package/build/es/components/InfoDialog/InfoDialog.js +1 -1
- package/build/es/components/Input/Input.js +1 -2
- package/build/es/components/LabelText/LabelText.d.ts +5 -3
- package/build/es/components/LabelText/LabelText.js +1 -1
- package/build/es/components/Notification/Notification.d.ts +18 -4
- package/build/es/components/Notification/Notification.js +26 -11
- package/build/es/components/Pill/Pill.d.ts +4 -0
- package/build/es/components/Pill/Pill.js +52 -16
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +1 -1
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +7 -8
- package/build/es/components/ProgressIndicator/ProgressIndicator.d.ts +2 -2
- package/build/es/components/ProgressIndicator/ProgressIndicator.js +13 -6
- package/build/es/components/ReadMore/ReadMore.d.ts +4 -0
- package/build/es/components/ReadMore/ReadMore.js +31 -4
- package/build/es/components/Tooltip/Tooltip.d.ts +5 -1
- package/build/es/components/Tooltip/Tooltip.js +46 -6
- package/package.json +10 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
1
|
import { Close, Info, Check, Warning, Error } from '@dnanpm/icons';
|
|
3
2
|
import React__default from 'react';
|
|
4
|
-
import styled__default from 'styled-components';
|
|
3
|
+
import styled__default, { css } from 'styled-components';
|
|
5
4
|
import theme from '../../themes/theme.js';
|
|
6
5
|
import ButtonClose from '../ButtonClose/ButtonClose.js';
|
|
7
6
|
import Icon from '../Icon/Icon.js';
|
|
@@ -12,7 +11,7 @@ const iconsMap = {
|
|
|
12
11
|
warning: Warning,
|
|
13
12
|
error: Error,
|
|
14
13
|
};
|
|
15
|
-
const
|
|
14
|
+
const sharedStyles = css `
|
|
16
15
|
display: flex;
|
|
17
16
|
gap: 1rem;
|
|
18
17
|
line-height: ${theme.lineHeight.default};
|
|
@@ -21,6 +20,14 @@ const NotificationWrapper = styled__default.div `
|
|
|
21
20
|
border-radius: ${theme.radius.s};
|
|
22
21
|
border: 2px solid ${({ $type }) => theme.color.notification[$type]};
|
|
23
22
|
`;
|
|
23
|
+
const NotificationWrapper = styled__default.div `
|
|
24
|
+
${sharedStyles}
|
|
25
|
+
border-color: ${({ $type }) => theme.color.notification[$type]};
|
|
26
|
+
`;
|
|
27
|
+
const StaticWrapper = styled__default.section `
|
|
28
|
+
${sharedStyles}
|
|
29
|
+
border-color: ${({ $type }) => theme.color.notification[$type]};
|
|
30
|
+
`;
|
|
24
31
|
const IconWrapper = styled__default.div `
|
|
25
32
|
display: flex;
|
|
26
33
|
align-items: center;
|
|
@@ -35,16 +42,24 @@ const ContentWrapper = styled__default.span `
|
|
|
35
42
|
const ButtonCloseStyled = styled__default(ButtonClose) `
|
|
36
43
|
position: static;
|
|
37
44
|
margin: auto 0.5rem;
|
|
45
|
+
|
|
46
|
+
&:focus-visible {
|
|
47
|
+
outline: none;
|
|
48
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
49
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
50
|
+
}
|
|
38
51
|
`;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
const Notification = ({ type = 'info', 'data-testid': dataTestId, isStatic = false, className, children, closeButton = false, closeButtonLabel, onClickCloseButton, dismissed = false, ariaLabel, }) => {
|
|
53
|
+
if (dismissed)
|
|
54
|
+
return null;
|
|
55
|
+
const IconToUse = iconsMap[type];
|
|
56
|
+
const renderContent = () => (React__default.createElement(React__default.Fragment, null,
|
|
43
57
|
React__default.createElement(IconWrapper, { "$type": type },
|
|
44
|
-
React__default.createElement(Icon, { icon:
|
|
45
|
-
React__default.createElement(ContentWrapper, null,
|
|
46
|
-
|
|
47
|
-
React__default.createElement(Icon, { icon: Close, color: "currentColor" })))))
|
|
58
|
+
React__default.createElement(Icon, { icon: IconToUse, size: "2rem", color: theme.color.default.white, "aria-hidden": true })),
|
|
59
|
+
React__default.createElement(ContentWrapper, null, children),
|
|
60
|
+
closeButton && (React__default.createElement(ButtonCloseStyled, { onClick: onClickCloseButton, "aria-label": closeButtonLabel },
|
|
61
|
+
React__default.createElement(Icon, { icon: Close, color: "currentColor", "aria-hidden": true })))));
|
|
62
|
+
return isStatic ? (React__default.createElement(StaticWrapper, { "$type": type, className: className, "data-testid": dataTestId, "aria-label": ariaLabel }, renderContent())) : (React__default.createElement(NotificationWrapper, { "$type": type, className: className, "data-testid": dataTestId, role: "alert" }, renderContent()));
|
|
48
63
|
};
|
|
49
64
|
|
|
50
65
|
export { Notification as default };
|
|
@@ -72,6 +72,10 @@ interface Props {
|
|
|
72
72
|
* Allows to pass a custom className
|
|
73
73
|
*/
|
|
74
74
|
className?: string;
|
|
75
|
+
/**
|
|
76
|
+
* A styled version that is designed to look like the default Button component
|
|
77
|
+
*/
|
|
78
|
+
isDefaultButtonStyle?: boolean;
|
|
75
79
|
}
|
|
76
80
|
declare const Pill: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
77
81
|
/** @component */
|
|
@@ -3,36 +3,72 @@ import React__default from 'react';
|
|
|
3
3
|
import styled__default from 'styled-components';
|
|
4
4
|
import theme from '../../themes/theme.js';
|
|
5
5
|
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
|
+
import { shade } from '../Button/Button.js';
|
|
6
7
|
|
|
7
8
|
const getCursor = ({ isDisabled, as }) => as !== 'div' && `cursor: ${isDisabled ? 'not-allowed' : 'pointer'};`;
|
|
8
|
-
const
|
|
9
|
+
const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
|
|
9
10
|
const alphaValue = isDisabled ? theme.color.transparency.T30 : theme.color.transparency.T100;
|
|
10
|
-
const
|
|
11
|
+
const bgColor = isChecked
|
|
11
12
|
? theme.color.background.plum.default
|
|
12
13
|
: theme.color.background.orange.E02;
|
|
13
|
-
// Only Pill component specific colors to be used on user interaction styles
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const hoverBgColor = isChecked ? '#441632' : '#FFB557'; // Only Pill component specific colors to be used on user interaction styles
|
|
15
|
+
const textColor = isChecked ? theme.color.default.white : theme.color.default.black;
|
|
16
|
+
const disabledTextColor = isDisabled ? theme.color.text.gray : textColor;
|
|
17
|
+
return `
|
|
18
|
+
font-size: ${theme.fontSize.s};
|
|
19
|
+
font-weight: ${theme.fontWeight.medium};
|
|
20
|
+
padding: 2px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
21
|
+
background-color: ${bgColor}${alphaValue};
|
|
22
|
+
color: ${disabledTextColor};
|
|
23
|
+
border: 2px solid transparent;
|
|
24
|
+
${!isDisabled ? `&:hover { background-color: ${hoverBgColor}; }` : ''}
|
|
25
|
+
`;
|
|
26
|
+
};
|
|
27
|
+
const getDefaultButtonStyles = ({ isChecked, isDisabled, }) => {
|
|
28
|
+
const alphaValue = isDisabled ? theme.color.transparency.T30 : theme.color.transparency.T100;
|
|
29
|
+
const hoverColor = '#441632'; // Only Pill component specific colors to be used on user interaction styles
|
|
30
|
+
const disabledBgColor = isDisabled ? theme.color.default.plum : shade.plum.lighter;
|
|
31
|
+
const bgColor = isChecked ? disabledBgColor : 'transparent';
|
|
32
|
+
const textColor = isChecked ? theme.color.default.white : theme.color.default.plum;
|
|
33
|
+
const disabledTextColor = isDisabled ? theme.color.text.gray : textColor;
|
|
34
|
+
const disabledBorderColor = isDisabled ? 'transparent' : shade.plum.lighter;
|
|
35
|
+
const borderColor = isChecked
|
|
36
|
+
? disabledBorderColor
|
|
37
|
+
: `${theme.color.default.plum}${alphaValue}`;
|
|
38
|
+
return `
|
|
39
|
+
font-size: ${theme.fontSize.default};
|
|
40
|
+
font-weight: ${theme.fontWeight.bold};
|
|
41
|
+
padding: 6px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
42
|
+
background-color: ${bgColor}${alphaValue};
|
|
43
|
+
color: ${disabledTextColor};
|
|
44
|
+
border: 2px solid ${borderColor};
|
|
45
|
+
${!isDisabled
|
|
46
|
+
? `
|
|
47
|
+
&:hover {
|
|
48
|
+
border: 2px solid ${hoverColor};
|
|
49
|
+
color: ${theme.color.default.white};
|
|
50
|
+
background-color: ${hoverColor};
|
|
51
|
+
}`
|
|
52
|
+
: ''}
|
|
53
|
+
`;
|
|
18
54
|
};
|
|
19
55
|
const Label = styled__default.label `
|
|
20
56
|
display: inline-block;
|
|
21
57
|
border-radius: ${theme.radius.pill};
|
|
22
|
-
font-size: ${theme.fontSize.s};
|
|
23
58
|
line-height: ${theme.lineHeight.default};
|
|
24
|
-
font-weight: ${theme.fontWeight.medium};
|
|
25
|
-
color: ${({ isChecked }) => isChecked ? theme.color.default.white : theme.color.default.black};
|
|
26
|
-
border: 2px solid transparent;
|
|
27
|
-
padding: 2px ${getMultipliedSize(theme.base.baseHeight, 2.5)};
|
|
28
59
|
text-align: center;
|
|
60
|
+
transition: all 0.2s ease-in-out;
|
|
61
|
+
|
|
62
|
+
${({ isChecked, isDisabled, isDefaultButtonStyle }) => isDefaultButtonStyle
|
|
63
|
+
? getDefaultButtonStyles({ isChecked, isDisabled })
|
|
64
|
+
: getStandardPillStyles({ isChecked, isDisabled })}
|
|
29
65
|
|
|
30
66
|
${({ isDisabled, as }) => getCursor({ isDisabled, as })}
|
|
31
|
-
${({ isChecked, isDisabled }) => getBackgroundColor({ isChecked, isDisabled })}
|
|
32
67
|
|
|
33
68
|
&:focus-within, *:focus > & {
|
|
34
|
-
|
|
35
|
-
|
|
69
|
+
outline: none;
|
|
70
|
+
box-shadow: 0px 0px 0px 2px ${theme.color.focus.light},
|
|
71
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
36
72
|
}
|
|
37
73
|
|
|
38
74
|
${({ position }) => (position === 'right' || position === 'middle') &&
|
|
@@ -72,7 +108,7 @@ const Input = styled__default.input `
|
|
|
72
108
|
`;
|
|
73
109
|
const Pill = (_a) => {
|
|
74
110
|
var { type = 'none', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
|
|
75
|
-
return (React__default.createElement(Label, { as: type === 'none' ? 'div' : undefined, position: props.position, isChecked: props.isChecked || props.isDefaultChecked, isDisabled: props.isDisabled, className: props.className, "data-testid": dataTestId },
|
|
111
|
+
return (React__default.createElement(Label, { as: type === 'none' ? 'div' : undefined, position: props.position, isChecked: props.isChecked || props.isDefaultChecked, isDisabled: props.isDisabled, className: props.className, "data-testid": dataTestId, isDefaultButtonStyle: props.isDefaultButtonStyle },
|
|
76
112
|
props.children,
|
|
77
113
|
type !== 'none' && (React__default.createElement(Input, { id: props.id, name: props.name, type: type, role: type, defaultChecked: props.isDefaultChecked, checked: props.isChecked, "aria-checked": props.isChecked || props.isDefaultChecked, value: props.value, onChange: props.onChange, disabled: props.isDisabled, readOnly: !props.onChange }))));
|
|
78
114
|
};
|
|
@@ -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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MouseEvent } from 'react';
|
|
1
|
+
import type { MouseEvent, KeyboardEvent } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type ProgressIndicatorStatus = 'error';
|
|
4
4
|
interface Props {
|
|
@@ -15,7 +15,7 @@ interface Props {
|
|
|
15
15
|
* On Progress Indicator Item label or number click callback
|
|
16
16
|
* Use `e.currentTarget.parentElement` to get Progress Indicator Item element
|
|
17
17
|
*/
|
|
18
|
-
onStepClick?: (stepIndex: number, e: MouseEvent<HTMLElement>) => void;
|
|
18
|
+
onStepClick?: (stepIndex: number, e: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>) => void;
|
|
19
19
|
/**
|
|
20
20
|
* Allows to change version of component to small
|
|
21
21
|
*/
|
|
@@ -118,14 +118,21 @@ const ProgressIndicator = (_a) => {
|
|
|
118
118
|
props.onStepClick(index, e);
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
|
-
|
|
121
|
+
const handleKeyDown = (e) => {
|
|
122
|
+
if ((e.key === 'Enter' || e.key === ' ') && props.onStepClick) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
props.onStepClick(index, e);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const isClickable = isCompleted && Boolean(props.onStepClick);
|
|
128
|
+
return (React__default.createElement(ProgressIndicatorItem, { key: id, small: props.small },
|
|
122
129
|
index > 0 && (React__default.createElement(ProgressIndicatorItemConnector, { small: props.small, isActive: isActive, isCompleted: isCompleted })),
|
|
123
|
-
React__default.createElement(ProgressIndicatorItemNumber, { small: props.small, onClick: handleClick, isActive: isActive, isCompleted: isCompleted, isError: isError, isClickable:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
label && (React__default.createElement(ProgressIndicatorItemLabel, { small: props.small, onClick: handleClick, isActive: isActive, className: "visually-hidden" }, label))));
|
|
130
|
+
React__default.createElement(ProgressIndicatorItemNumber, { small: props.small, onClick: handleClick, isActive: isActive, isCompleted: isCompleted, isError: isError, onKeyDown: handleKeyDown, tabIndex: isClickable || isActive ? 0 : -1, isClickable: isClickable, role: "tab", "aria-current": isActive ? 'step' : 'false', "aria-label": isCompleted && props.completedStepLabel
|
|
131
|
+
? `${label}, ${props.completedStepLabel}`
|
|
132
|
+
: label }, isCompleted || isError ? (React__default.createElement(Icon, { icon: isError ? Warning : Check, color: isError ? theme.color.text.white : theme.color.text.pink, size: "1rem", "aria-hidden": true })) : (stepNumber)),
|
|
133
|
+
label && (React__default.createElement(ProgressIndicatorItemLabel, { "aria-hidden": true, small: props.small, onClick: handleClick, isActive: isActive, className: "visually-hidden" }, label))));
|
|
127
134
|
});
|
|
128
|
-
return (React__default.createElement(ProgressIndicatorWrapper, { className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "
|
|
135
|
+
return (React__default.createElement(ProgressIndicatorWrapper, { className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "tablist" }, progressIndicatorItems));
|
|
129
136
|
};
|
|
130
137
|
|
|
131
138
|
export { ProgressIndicator as default };
|
|
@@ -68,6 +68,10 @@ interface Props {
|
|
|
68
68
|
* Allows to pass testid string for testing purposes
|
|
69
69
|
*/
|
|
70
70
|
'data-testid'?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Allows to pass an accessible label for the component, enhancing screen reader support.
|
|
73
|
+
*/
|
|
74
|
+
ariaLabel?: string;
|
|
71
75
|
}
|
|
72
76
|
/** @visibleName Read More */
|
|
73
77
|
declare const ReadMore: ({ collapsedSize, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
2
|
import { ChevronUp, ChevronDown } from '@dnanpm/icons';
|
|
3
|
-
import React__default, { useState, useEffect } from 'react';
|
|
3
|
+
import React__default, { useState, useRef, useEffect, Children, isValidElement, cloneElement } from 'react';
|
|
4
4
|
import styled from '../../themes/styled.js';
|
|
5
5
|
import theme from '../../themes/theme.js';
|
|
6
6
|
import ButtonIcon from '../ButtonIcon/ButtonIcon.js';
|
|
@@ -37,6 +37,9 @@ const StyledButtonIcon = styled(ButtonIcon) `
|
|
|
37
37
|
const ReadMore = (_a) => {
|
|
38
38
|
var { collapsedSize = '10rem', 'data-testid': dataTestId } = _a, props = __rest(_a, ["collapsedSize", 'data-testid']);
|
|
39
39
|
const [expanded, setExpanded] = useState(props.seoInitExpanded === true || false);
|
|
40
|
+
const contentRef = useRef(null);
|
|
41
|
+
const buttonRef = useRef(null);
|
|
42
|
+
const userInteractedRef = useRef(false);
|
|
40
43
|
// TODO: Remove once https://jira.dna.fi/browse/STYLE-662 is done
|
|
41
44
|
const temporaryIsStatelessFlag = typeof props.isExpanded !== 'undefined';
|
|
42
45
|
const temporaryStateManagement = temporaryIsStatelessFlag ? props.isExpanded : expanded;
|
|
@@ -48,16 +51,40 @@ const ReadMore = (_a) => {
|
|
|
48
51
|
if (!temporaryIsStatelessFlag) {
|
|
49
52
|
setExpanded(!expanded);
|
|
50
53
|
}
|
|
54
|
+
userInteractedRef.current = true;
|
|
51
55
|
};
|
|
52
56
|
useEffect(() => {
|
|
53
57
|
if (props.seoInitExpanded) {
|
|
54
58
|
setExpanded(false);
|
|
55
59
|
}
|
|
56
60
|
}, [props.seoInitExpanded]);
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
if (userInteractedRef.current) {
|
|
64
|
+
if (temporaryStateManagement) {
|
|
65
|
+
(_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
(_b = buttonRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, [temporaryStateManagement]);
|
|
72
|
+
// Function to apply tabIndex to all links elements of children (since we don't control what is passed as children)
|
|
73
|
+
const forceTabIndexOnTextLinks = (child) => {
|
|
74
|
+
if (!isValidElement(child)) {
|
|
75
|
+
return child;
|
|
76
|
+
}
|
|
77
|
+
if (child.type === 'a') {
|
|
78
|
+
return cloneElement(child, {
|
|
79
|
+
tabIndex: temporaryStateManagement ? 0 : -1,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return child;
|
|
83
|
+
};
|
|
84
|
+
return (React__default.createElement(Container, { id: props.id, className: props.className, "data-testid": dataTestId, "aria-label": props.ariaLabel, role: "region" },
|
|
85
|
+
React__default.createElement(Content, { ref: contentRef, isExpanded: temporaryStateManagement, collapsedSize: collapsedSize, "data-testid": dataTestId && `${dataTestId}-content`, "aria-hidden": temporaryStateManagement ? 'false' : 'true', tabIndex: temporaryStateManagement ? 0 : -1 }, Children.map(props.children, forceTabIndexOnTextLinks)),
|
|
59
86
|
React__default.createElement(ButtonWrapper, { buttonPosition: props.buttonPosition },
|
|
60
|
-
React__default.createElement(StyledButtonIcon, { icon: temporaryStateManagement ? ChevronUp : ChevronDown, onClick: handleOnClick }, temporaryButtonLabel || props.buttonLabel))));
|
|
87
|
+
React__default.createElement(StyledButtonIcon, { ref: buttonRef, icon: temporaryStateManagement ? ChevronUp : ChevronDown, onClick: handleOnClick, ariaHidden: true, "aria-expanded": temporaryStateManagement }, temporaryButtonLabel || props.buttonLabel))));
|
|
61
88
|
};
|
|
62
89
|
|
|
63
90
|
export { ReadMore 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.10",
|
|
5
5
|
"main": "build/cjs/index.js",
|
|
6
6
|
"module": "build/es/index.js",
|
|
7
7
|
"jsnext:main": "build/es/index.js",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"not op_mini all"
|
|
42
42
|
],
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.26.
|
|
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
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
49
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
50
50
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
51
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
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.
|
|
97
|
+
"webpack": "^5.99.6"
|
|
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",
|