@dnanpm/styleguide 3.9.9 → 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.
@@ -16,13 +16,17 @@ interface Props {
16
16
  /**
17
17
  * Content of the component
18
18
  */
19
- children?: ReactNode;
19
+ children: ReactNode;
20
20
  /**
21
21
  * Allows to show and hide close button
22
22
  *
23
23
  * @default false
24
24
  */
25
25
  closeButton?: boolean;
26
+ /**
27
+ * Label for the close button
28
+ */
29
+ closeButtonLabel?: string;
26
30
  /**
27
31
  * On close button click callback
28
32
  */
@@ -41,8 +45,18 @@ interface Props {
41
45
  * Allows to pass testid string for testing purposes
42
46
  */
43
47
  'data-testid'?: string;
48
+ /**
49
+ * If true, the component is treated as static (non-interactive),
50
+ * and uses `aria-label` instead of `role="alert"`.
51
+ *
52
+ * @default false
53
+ */
54
+ isStatic?: boolean;
55
+ /**
56
+ * Accessible label for the notification. Required when `isStatic` is true
57
+ * and no type-based default label is desired.
58
+ */
59
+ ariaLabel?: string;
44
60
  }
45
- /** @visibleName Notification */
46
- declare const Notification: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
47
- /** @component */
61
+ declare const Notification: ({ type, "data-testid": dataTestId, isStatic, className, children, closeButton, closeButtonLabel, onClickCloseButton, dismissed, ariaLabel, }: Props) => React.JSX.Element | null;
48
62
  export default Notification;
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var icons = require('@dnanpm/icons');
7
6
  var React = require('react');
8
7
  var styled = require('styled-components');
@@ -21,7 +20,7 @@ const iconsMap = {
21
20
  warning: icons.Warning,
22
21
  error: icons.Error,
23
22
  };
24
- const NotificationWrapper = styled__default.default.div `
23
+ const sharedStyles = styled.css `
25
24
  display: flex;
26
25
  gap: 1rem;
27
26
  line-height: ${theme.default.lineHeight.default};
@@ -30,6 +29,14 @@ const NotificationWrapper = styled__default.default.div `
30
29
  border-radius: ${theme.default.radius.s};
31
30
  border: 2px solid ${({ $type }) => theme.default.color.notification[$type]};
32
31
  `;
32
+ const NotificationWrapper = styled__default.default.div `
33
+ ${sharedStyles}
34
+ border-color: ${({ $type }) => theme.default.color.notification[$type]};
35
+ `;
36
+ const StaticWrapper = styled__default.default.section `
37
+ ${sharedStyles}
38
+ border-color: ${({ $type }) => theme.default.color.notification[$type]};
39
+ `;
33
40
  const IconWrapper = styled__default.default.div `
34
41
  display: flex;
35
42
  align-items: center;
@@ -44,16 +51,24 @@ const ContentWrapper = styled__default.default.span `
44
51
  const ButtonCloseStyled = styled__default.default(ButtonClose.default) `
45
52
  position: static;
46
53
  margin: auto 0.5rem;
54
+
55
+ &:focus-visible {
56
+ outline: none;
57
+ box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
58
+ 0px 0px 0px 4px ${theme.default.color.focus.dark};
59
+ }
47
60
  `;
48
- /** @visibleName Notification */
49
- const Notification = (_a) => {
50
- var { type = 'info', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
51
- return !props.dismissed ? (React__default.default.createElement(NotificationWrapper, { "$type": type, className: props.className, "data-testid": dataTestId },
61
+ const Notification = ({ type = 'info', 'data-testid': dataTestId, isStatic = false, className, children, closeButton = false, closeButtonLabel, onClickCloseButton, dismissed = false, ariaLabel, }) => {
62
+ if (dismissed)
63
+ return null;
64
+ const IconToUse = iconsMap[type];
65
+ const renderContent = () => (React__default.default.createElement(React__default.default.Fragment, null,
52
66
  React__default.default.createElement(IconWrapper, { "$type": type },
53
- React__default.default.createElement(Icon.default, { icon: iconsMap[type], size: "2rem", color: theme.default.color.default.white })),
54
- React__default.default.createElement(ContentWrapper, null, props.children),
55
- props.closeButton && (React__default.default.createElement(ButtonCloseStyled, { onClick: props.onClickCloseButton },
56
- React__default.default.createElement(Icon.default, { icon: icons.Close, color: "currentColor" }))))) : null;
67
+ React__default.default.createElement(Icon.default, { icon: IconToUse, size: "2rem", color: theme.default.color.default.white, "aria-hidden": true })),
68
+ React__default.default.createElement(ContentWrapper, null, children),
69
+ closeButton && (React__default.default.createElement(ButtonCloseStyled, { onClick: onClickCloseButton, "aria-label": closeButtonLabel },
70
+ React__default.default.createElement(Icon.default, { icon: icons.Close, color: "currentColor", "aria-hidden": true })))));
71
+ return isStatic ? (React__default.default.createElement(StaticWrapper, { "$type": type, className: className, "data-testid": dataTestId, "aria-label": ariaLabel }, renderContent())) : (React__default.default.createElement(NotificationWrapper, { "$type": type, className: className, "data-testid": dataTestId, role: "alert" }, renderContent()));
57
72
  };
58
73
 
59
74
  exports.default = Notification;
@@ -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 */
@@ -7,6 +7,7 @@ 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
 
@@ -14,34 +15,69 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
14
15
  var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
15
16
 
16
17
  const getCursor = ({ isDisabled, as }) => as !== 'div' && `cursor: ${isDisabled ? 'not-allowed' : 'pointer'};`;
17
- const getBackgroundColor = ({ isChecked, isDisabled }) => {
18
+ const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
18
19
  const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
19
- const colorValue = isChecked
20
+ const bgColor = isChecked
20
21
  ? theme.default.color.background.plum.default
21
22
  : theme.default.color.background.orange.E02;
22
- // Only Pill component specific colors to be used on user interaction styles
23
- const hoverValue = isChecked ? '#441632' : '#FFB557';
24
- const backgroundColor = `background-color: ${colorValue}${alphaValue};`;
25
- const hoverBackgroundColor = !isDisabled ? `&:hover { background-color: ${hoverValue}}` : '';
26
- return backgroundColor + hoverBackgroundColor;
23
+ const hoverBgColor = isChecked ? '#441632' : '#FFB557'; // Only Pill component specific colors to be used on user interaction styles
24
+ const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.black;
25
+ const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
26
+ return `
27
+ font-size: ${theme.default.fontSize.s};
28
+ font-weight: ${theme.default.fontWeight.medium};
29
+ padding: 2px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
30
+ background-color: ${bgColor}${alphaValue};
31
+ color: ${disabledTextColor};
32
+ border: 2px solid transparent;
33
+ ${!isDisabled ? `&:hover { background-color: ${hoverBgColor}; }` : ''}
34
+ `;
35
+ };
36
+ const getDefaultButtonStyles = ({ isChecked, isDisabled, }) => {
37
+ const alphaValue = isDisabled ? theme.default.color.transparency.T30 : theme.default.color.transparency.T100;
38
+ const hoverColor = '#441632'; // Only Pill component specific colors to be used on user interaction styles
39
+ const disabledBgColor = isDisabled ? theme.default.color.default.plum : Button.shade.plum.lighter;
40
+ const bgColor = isChecked ? disabledBgColor : 'transparent';
41
+ const textColor = isChecked ? theme.default.color.default.white : theme.default.color.default.plum;
42
+ const disabledTextColor = isDisabled ? theme.default.color.text.gray : textColor;
43
+ const disabledBorderColor = isDisabled ? 'transparent' : Button.shade.plum.lighter;
44
+ const borderColor = isChecked
45
+ ? disabledBorderColor
46
+ : `${theme.default.color.default.plum}${alphaValue}`;
47
+ return `
48
+ font-size: ${theme.default.fontSize.default};
49
+ font-weight: ${theme.default.fontWeight.bold};
50
+ padding: 6px ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2.5)};
51
+ background-color: ${bgColor}${alphaValue};
52
+ color: ${disabledTextColor};
53
+ border: 2px solid ${borderColor};
54
+ ${!isDisabled
55
+ ? `
56
+ &:hover {
57
+ border: 2px solid ${hoverColor};
58
+ color: ${theme.default.color.default.white};
59
+ background-color: ${hoverColor};
60
+ }`
61
+ : ''}
62
+ `;
27
63
  };
28
64
  const Label = styled__default.default.label `
29
65
  display: inline-block;
30
66
  border-radius: ${theme.default.radius.pill};
31
- font-size: ${theme.default.fontSize.s};
32
67
  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
68
  text-align: center;
69
+ transition: all 0.2s ease-in-out;
70
+
71
+ ${({ isChecked, isDisabled, isDefaultButtonStyle }) => isDefaultButtonStyle
72
+ ? getDefaultButtonStyles({ isChecked, isDisabled })
73
+ : getStandardPillStyles({ isChecked, isDisabled })}
38
74
 
39
75
  ${({ isDisabled, as }) => getCursor({ isDisabled, as })}
40
- ${({ isChecked, isDisabled }) => getBackgroundColor({ isChecked, isDisabled })}
41
76
 
42
77
  &:focus-within, *:focus > & {
43
- box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.dark};
44
- border: 2px solid ${theme.default.color.focus.light};
78
+ outline: none;
79
+ box-shadow: 0px 0px 0px 2px ${theme.default.color.focus.light},
80
+ 0px 0px 0px 4px ${theme.default.color.focus.dark};
45
81
  }
46
82
 
47
83
  ${({ position }) => (position === 'right' || position === 'middle') &&
@@ -81,7 +117,7 @@ const Input = styled__default.default.input `
81
117
  `;
82
118
  const Pill = (_a) => {
83
119
  var { type = 'none', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
84
- return (React__default.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 },
120
+ return (React__default.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 },
85
121
  props.children,
86
122
  type !== 'none' && (React__default.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 }))));
87
123
  };
@@ -37,6 +37,6 @@ export interface Props {
37
37
  /**
38
38
  * @visibleName Priority NavigationItem
39
39
  */
40
- declare const PriorityNavigationItem: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
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: props.innerRef, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
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;
@@ -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.div `
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: props.isClickable, className: props.className, "data-testid": dataTestId },
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, closeOnEsc: closeWithEsc, openOnClick: props.isClickable, clickable: props.isHoverable, isMultiline: props.isMultiline, disableStyleInjection: true, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
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;
@@ -16,13 +16,17 @@ interface Props {
16
16
  /**
17
17
  * Content of the component
18
18
  */
19
- children?: ReactNode;
19
+ children: ReactNode;
20
20
  /**
21
21
  * Allows to show and hide close button
22
22
  *
23
23
  * @default false
24
24
  */
25
25
  closeButton?: boolean;
26
+ /**
27
+ * Label for the close button
28
+ */
29
+ closeButtonLabel?: string;
26
30
  /**
27
31
  * On close button click callback
28
32
  */
@@ -41,8 +45,18 @@ interface Props {
41
45
  * Allows to pass testid string for testing purposes
42
46
  */
43
47
  'data-testid'?: string;
48
+ /**
49
+ * If true, the component is treated as static (non-interactive),
50
+ * and uses `aria-label` instead of `role="alert"`.
51
+ *
52
+ * @default false
53
+ */
54
+ isStatic?: boolean;
55
+ /**
56
+ * Accessible label for the notification. Required when `isStatic` is true
57
+ * and no type-based default label is desired.
58
+ */
59
+ ariaLabel?: string;
44
60
  }
45
- /** @visibleName Notification */
46
- declare const Notification: ({ type, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element | null;
47
- /** @component */
61
+ declare const Notification: ({ type, "data-testid": dataTestId, isStatic, className, children, closeButton, closeButtonLabel, onClickCloseButton, dismissed, ariaLabel, }: Props) => React.JSX.Element | null;
48
62
  export default Notification;
@@ -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 NotificationWrapper = styled__default.div `
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
- /** @visibleName Notification */
40
- const Notification = (_a) => {
41
- var { type = 'info', 'data-testid': dataTestId } = _a, props = __rest(_a, ["type", 'data-testid']);
42
- return !props.dismissed ? (React__default.createElement(NotificationWrapper, { "$type": type, className: props.className, "data-testid": dataTestId },
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: iconsMap[type], size: "2rem", color: theme.color.default.white })),
45
- React__default.createElement(ContentWrapper, null, props.children),
46
- props.closeButton && (React__default.createElement(ButtonCloseStyled, { onClick: props.onClickCloseButton },
47
- React__default.createElement(Icon, { icon: Close, color: "currentColor" }))))) : null;
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 getBackgroundColor = ({ isChecked, isDisabled }) => {
9
+ const getStandardPillStyles = ({ isChecked, isDisabled, }) => {
9
10
  const alphaValue = isDisabled ? theme.color.transparency.T30 : theme.color.transparency.T100;
10
- const colorValue = isChecked
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 hoverValue = isChecked ? '#441632' : '#FFB557';
15
- const backgroundColor = `background-color: ${colorValue}${alphaValue};`;
16
- const hoverBackgroundColor = !isDisabled ? `&:hover { background-color: ${hoverValue}}` : '';
17
- return backgroundColor + hoverBackgroundColor;
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
- box-shadow: 0px 0px 0px 2px ${theme.color.focus.dark};
35
- border: 2px solid ${theme.color.focus.light};
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: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
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: props.innerRef, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
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 };
@@ -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.div `
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: props.isClickable, className: props.className, "data-testid": dataTestId },
63
- React__default.createElement(Icon, { icon: Info, size: "1rem", position: props.position }))),
64
- React__default.createElement(StyledReactTooltip, { id: props.id, place: props.placement, closeOnEsc: closeWithEsc, openOnClick: props.isClickable, clickable: props.isHoverable, isMultiline: props.isMultiline, disableStyleInjection: true, "data-testid": dataTestId && `${dataTestId}-content` }, props.children)));
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.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",
@@ -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.0",
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": "^14.3.1",
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.1",
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,7 +90,7 @@
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.6",
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",
@@ -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.0"
105
+ "react-tooltip": "^5.28.1"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "@dnanpm/icons": "^2.x",