@spaced-out/ui-design-system 0.1.16 → 0.1.17

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.
Files changed (84) hide show
  1. package/.cspell/custom-words.txt +3 -0
  2. package/.flowconfig +1 -1
  3. package/CHANGELOG.md +7 -0
  4. package/CONTRIBUTING.md +52 -6
  5. package/README.md +144 -8
  6. package/gulpfile.js +1 -0
  7. package/lib/components/AvatarGroup/AvatarGroup.js +4 -3
  8. package/lib/components/AvatarGroup/AvatarGroup.js.flow +119 -110
  9. package/lib/components/Badge/Badge.js +4 -3
  10. package/lib/components/Badge/Badge.js.flow +21 -21
  11. package/lib/components/Badge/index.js +11 -7
  12. package/lib/components/Badge/index.js.flow +1 -2
  13. package/lib/components/Banner/Banner.js +3 -2
  14. package/lib/components/Banner/Banner.js.flow +42 -35
  15. package/lib/components/Button/Button.js +50 -10
  16. package/lib/components/Button/Button.js.flow +87 -23
  17. package/lib/components/Button/Button.module.css +14 -0
  18. package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +3 -2
  19. package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +48 -38
  20. package/lib/components/ButtonTabs/ButtonTabs.js +3 -2
  21. package/lib/components/ButtonTabs/ButtonTabs.js.flow +50 -41
  22. package/lib/components/Card/Card.js +16 -7
  23. package/lib/components/Card/Card.js.flow +73 -55
  24. package/lib/components/Chip/Chip.js +3 -2
  25. package/lib/components/Chip/Chip.js.flow +66 -59
  26. package/lib/components/CircularLoader/CircularLoader.js +9 -4
  27. package/lib/components/CircularLoader/CircularLoader.js.flow +38 -24
  28. package/lib/components/CollapsibleCard/CollapsibleCard.js +4 -3
  29. package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +68 -59
  30. package/lib/components/Dropdown/Dropdown.js +4 -3
  31. package/lib/components/Dropdown/Dropdown.js.flow +83 -74
  32. package/lib/components/EmptyState/EmptyState.js +4 -3
  33. package/lib/components/EmptyState/EmptyState.js.flow +53 -44
  34. package/lib/components/ErrorMessage/ErrorMessage.js +4 -3
  35. package/lib/components/ErrorMessage/ErrorMessage.js.flow +58 -49
  36. package/lib/components/InContextAlert/InContextAlert.js +4 -3
  37. package/lib/components/InContextAlert/InContextAlert.js.flow +79 -73
  38. package/lib/components/InlineDropdown/InlineDropdown.js +4 -3
  39. package/lib/components/InlineDropdown/InlineDropdown.js.flow +94 -85
  40. package/lib/components/LinearLoader/LinearLoader.js +4 -3
  41. package/lib/components/LinearLoader/LinearLoader.js.flow +20 -18
  42. package/lib/components/Link/Link.js +8 -1
  43. package/lib/components/Link/Link.js.flow +44 -36
  44. package/lib/components/Notification/Notification.js +8 -6
  45. package/lib/components/Notification/Notification.js.flow +96 -84
  46. package/lib/components/OptionButton/OptionButton.js +7 -4
  47. package/lib/components/OptionButton/OptionButton.js.flow +69 -59
  48. package/lib/components/PageTitle/PageTitle.js +4 -3
  49. package/lib/components/PageTitle/PageTitle.js.flow +46 -44
  50. package/lib/components/Pagination/PaginationItem.js +2 -2
  51. package/lib/components/Pagination/PaginationItem.js.flow +2 -2
  52. package/lib/components/SearchInput/SearchInput.js +3 -2
  53. package/lib/components/SearchInput/SearchInput.js.flow +59 -50
  54. package/lib/components/SideMenuLink/SideMenuLink.js +4 -3
  55. package/lib/components/SideMenuLink/SideMenuLink.js.flow +54 -45
  56. package/lib/components/StatusIndicator/StatusIndicator.js +3 -2
  57. package/lib/components/StatusIndicator/StatusIndicator.js.flow +32 -23
  58. package/lib/components/SubMenu/SubMenu.js +4 -3
  59. package/lib/components/SubMenu/SubMenu.js.flow +41 -38
  60. package/lib/components/Table/StaticTable.js +3 -0
  61. package/lib/components/Table/StaticTable.js.flow +3 -0
  62. package/lib/components/Table/Table.js +10 -0
  63. package/lib/components/Table/Table.js.flow +10 -0
  64. package/lib/components/Table/hooks.js +1 -0
  65. package/lib/components/Table/hooks.js.flow +1 -0
  66. package/lib/components/Tabs/TabList/TabList.js +3 -2
  67. package/lib/components/Tabs/TabList/TabList.js.flow +127 -117
  68. package/lib/components/Toggle/index.js +11 -7
  69. package/lib/components/Toggle/index.js.flow +1 -1
  70. package/lib/components/Tooltip/Tooltip.js.flow +2 -2
  71. package/lib/components/index.js +511 -0
  72. package/lib/components/index.js.flow +48 -0
  73. package/lib/index.js +60 -0
  74. package/lib/index.js.flow +7 -0
  75. package/lib/styles/index.css +15 -0
  76. package/lib/styles/index.js +104 -0
  77. package/lib/styles/index.js.flow +12 -0
  78. package/lib/styles/typography.module.css +0 -1
  79. package/lib/styles/utils.module.css +26 -0
  80. package/lib/types/index.js +38 -0
  81. package/lib/types/index.js.flow +5 -0
  82. package/lib/utils/index.js +93 -0
  83. package/lib/utils/index.js.flow +10 -0
  84. package/package.json +2 -1
@@ -120,77 +120,83 @@ const AlertIcon = ({
120
120
  }
121
121
  };
122
122
 
123
- export const InContextAlert = (props: InContextAlertProps): React.Node => {
124
- const {
125
- classNames,
126
- semantic = ALERT_SEMANTIC.neutral,
127
- dismissable,
128
- children,
129
- selfDismiss = false,
130
- leftIconName = '',
131
- onCloseClick,
132
- actionText = '',
133
- onAction,
134
- leftIconType,
135
- } = props;
136
- const [dismissed, setDismissed] = React.useState(false);
137
- const closeClickHandler = (e) => {
138
- onCloseClick && onCloseClick(e);
139
- selfDismiss && setDismissed(true);
140
- };
123
+ export const InContextAlert: React$AbstractComponent<
124
+ InContextAlertProps,
125
+ HTMLDivElement,
126
+ > = React.forwardRef<InContextAlertProps, HTMLDivElement>(
127
+ (props: InContextAlertProps, ref): React.Node => {
128
+ const {
129
+ classNames,
130
+ semantic = ALERT_SEMANTIC.neutral,
131
+ dismissable,
132
+ children,
133
+ selfDismiss = false,
134
+ leftIconName = '',
135
+ onCloseClick,
136
+ actionText = '',
137
+ onAction,
138
+ leftIconType,
139
+ } = props;
140
+ const [dismissed, setDismissed] = React.useState(false);
141
+ const closeClickHandler = (e) => {
142
+ onCloseClick && onCloseClick(e);
143
+ selfDismiss && setDismissed(true);
144
+ };
141
145
 
142
- return (
143
- <>
144
- {!dismissed && (
145
- <div
146
- className={classify(
147
- css.alertContainer,
148
- {
149
- [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
150
- [css.success]: semantic === ALERT_SEMANTIC.success,
151
- [css.information]: semantic === ALERT_SEMANTIC.information,
152
- [css.warning]: semantic === ALERT_SEMANTIC.warning,
153
- [css.danger]: semantic === ALERT_SEMANTIC.danger,
154
- },
155
- classNames?.wrapper,
156
- )}
157
- >
158
- <AlertIcon
159
- semantic={semantic}
160
- leftIconName={leftIconName}
161
- leftIconType={leftIconType}
162
- />
163
- {React.Children.count(children) > 0 && (
164
- <SubTitleExtraSmall className={classify(classNames?.alertText)}>
165
- <Truncate line={2}>{children}</Truncate>
166
- </SubTitleExtraSmall>
167
- )}
168
- {!!(actionText || dismissable) && (
169
- <div
170
- className={classify(
171
- css.actionContainer,
172
- classNames?.actionContainer,
173
- )}
174
- >
175
- {!!actionText && (
176
- <Link onClick={onAction} color="primary">
177
- {actionText}
178
- </Link>
179
- )}
180
- {!!dismissable && (
181
- <ClickableIcon
182
- color={TEXT_COLORS.primary}
183
- name="close"
184
- size="small"
185
- type="regular"
186
- onClick={closeClickHandler}
187
- className={css.closeIcon}
188
- />
189
- )}
190
- </div>
191
- )}
192
- </div>
193
- )}
194
- </>
195
- );
196
- };
146
+ return (
147
+ <>
148
+ {!dismissed && (
149
+ <div
150
+ className={classify(
151
+ css.alertContainer,
152
+ {
153
+ [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
154
+ [css.success]: semantic === ALERT_SEMANTIC.success,
155
+ [css.information]: semantic === ALERT_SEMANTIC.information,
156
+ [css.warning]: semantic === ALERT_SEMANTIC.warning,
157
+ [css.danger]: semantic === ALERT_SEMANTIC.danger,
158
+ },
159
+ classNames?.wrapper,
160
+ )}
161
+ ref={ref}
162
+ >
163
+ <AlertIcon
164
+ semantic={semantic}
165
+ leftIconName={leftIconName}
166
+ leftIconType={leftIconType}
167
+ />
168
+ {React.Children.count(children) > 0 && (
169
+ <SubTitleExtraSmall className={classify(classNames?.alertText)}>
170
+ <Truncate line={2}>{children}</Truncate>
171
+ </SubTitleExtraSmall>
172
+ )}
173
+ {!!(actionText || dismissable) && (
174
+ <div
175
+ className={classify(
176
+ css.actionContainer,
177
+ classNames?.actionContainer,
178
+ )}
179
+ >
180
+ {!!actionText && (
181
+ <Link onClick={onAction} color="primary">
182
+ {actionText}
183
+ </Link>
184
+ )}
185
+ {!!dismissable && (
186
+ <ClickableIcon
187
+ color={TEXT_COLORS.primary}
188
+ name="close"
189
+ size="small"
190
+ type="regular"
191
+ onClick={closeClickHandler}
192
+ className={css.closeIcon}
193
+ />
194
+ )}
195
+ </div>
196
+ )}
197
+ </div>
198
+ )}
199
+ </>
200
+ );
201
+ },
202
+ );
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
20
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
- const InlineDropdown = _ref => {
21
+ const InlineDropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
22
22
  let {
23
23
  anchorPosition = 'bottom-start',
24
24
  size = 'medium',
@@ -31,7 +31,8 @@ const InlineDropdown = _ref => {
31
31
  children,
32
32
  ...restButtonProps
33
33
  } = _ref;
34
- const menuBtnRef = React.useRef();
34
+ const menuBtnRef = React.useRef(null);
35
+ React.useImperativeHandle(ref, () => menuBtnRef.current);
35
36
  const {
36
37
  x,
37
38
  y,
@@ -96,5 +97,5 @@ const InlineDropdown = _ref => {
96
97
  size: menu.size || 'medium'
97
98
  }))));
98
99
  });
99
- };
100
+ });
100
101
  exports.InlineDropdown = InlineDropdown;
@@ -45,96 +45,105 @@ export type InlineDropdownProps = {
45
45
  ...
46
46
  };
47
47
 
48
- export const InlineDropdown = ({
49
- anchorPosition = 'bottom-start',
50
- size = 'medium',
51
- onOptionSelect,
52
- menu,
53
- classNames,
54
- disabled,
55
- onMenuOpen,
56
- onMenuClose,
57
- children,
58
- ...restButtonProps
59
- }: InlineDropdownProps): React.Node => {
60
- const menuBtnRef = React.useRef();
61
- const {x, y, reference, floating, strategy} = useFloating({
62
- strategy: 'absolute',
63
- placement: anchorPosition,
64
- whileElementsMounted: autoUpdate,
65
- middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
66
- });
48
+ export const InlineDropdown: React$AbstractComponent<
49
+ InlineDropdownProps,
50
+ HTMLDivElement,
51
+ > = React.forwardRef<InlineDropdownProps, HTMLDivElement>(
52
+ (
53
+ {
54
+ anchorPosition = 'bottom-start',
55
+ size = 'medium',
56
+ onOptionSelect,
57
+ menu,
58
+ classNames,
59
+ disabled,
60
+ onMenuOpen,
61
+ onMenuClose,
62
+ children,
63
+ ...restButtonProps
64
+ }: InlineDropdownProps,
65
+ ref,
66
+ ): React.Node => {
67
+ const menuBtnRef = React.useRef(null);
68
+ React.useImperativeHandle(ref, () => menuBtnRef.current);
69
+ const {x, y, reference, floating, strategy} = useFloating({
70
+ strategy: 'absolute',
71
+ placement: anchorPosition,
72
+ whileElementsMounted: autoUpdate,
73
+ middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
74
+ });
67
75
 
68
- const onMenuToggle = (isOpen: boolean) => {
69
- isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
70
- };
76
+ const onMenuToggle = (isOpen: boolean) => {
77
+ isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
78
+ };
71
79
 
72
- return (
73
- <ClickAway onChange={onMenuToggle}>
74
- {({isOpen, onOpen, cancelNext, clickAway}) => (
75
- <div
76
- data-testid="InlineDropdown"
77
- className={classify(
78
- css.inlineDropdownContainer,
79
- classNames?.dropdownContainer,
80
- )}
81
- ref={menuBtnRef}
82
- >
83
- <UnstyledButton
84
- {...restButtonProps}
85
- disabled={disabled}
86
- ref={reference}
87
- onClick={(e) => {
88
- e.stopPropagation();
89
- onOpen();
90
- }}
80
+ return (
81
+ <ClickAway onChange={onMenuToggle}>
82
+ {({isOpen, onOpen, cancelNext, clickAway}) => (
83
+ <div
84
+ data-testid="InlineDropdown"
91
85
  className={classify(
92
- css.inlineButton,
93
- {
94
- [css.disabled]: disabled,
95
- },
96
- css[size],
97
- classNames?.buttonWrapper,
86
+ css.inlineDropdownContainer,
87
+ classNames?.dropdownContainer,
98
88
  )}
89
+ ref={menuBtnRef}
99
90
  >
100
- <Truncate>{children}</Truncate>
101
- <Icon
102
- name={isOpen ? 'caret-up' : 'caret-down'}
103
- size="small"
104
- type="solid"
105
- className={classify({
106
- [css.disabled]: disabled,
107
- })}
108
- />
109
- </UnstyledButton>
110
- {isOpen && menu && (
111
- <div
112
- onClickCapture={cancelNext}
113
- ref={floating}
114
- style={{
115
- display: 'flex',
116
- position: strategy,
117
- top: y ?? spaceNone,
118
- left: x ?? spaceNone,
91
+ <UnstyledButton
92
+ {...restButtonProps}
93
+ disabled={disabled}
94
+ ref={reference}
95
+ onClick={(e) => {
96
+ e.stopPropagation();
97
+ onOpen();
119
98
  }}
99
+ className={classify(
100
+ css.inlineButton,
101
+ {
102
+ [css.disabled]: disabled,
103
+ },
104
+ css[size],
105
+ classNames?.buttonWrapper,
106
+ )}
120
107
  >
121
- <Menu
122
- {...menu}
123
- onSelect={(option) => {
124
- onOptionSelect && onOptionSelect(option);
125
- if (
126
- !menu.optionsVariant ||
127
- menu.optionsVariant === 'normal'
128
- ) {
129
- clickAway();
130
- }
131
- }}
132
- size={menu.size || 'medium'}
108
+ <Truncate>{children}</Truncate>
109
+ <Icon
110
+ name={isOpen ? 'caret-up' : 'caret-down'}
111
+ size="small"
112
+ type="solid"
113
+ className={classify({
114
+ [css.disabled]: disabled,
115
+ })}
133
116
  />
134
- </div>
135
- )}
136
- </div>
137
- )}
138
- </ClickAway>
139
- );
140
- };
117
+ </UnstyledButton>
118
+ {isOpen && menu && (
119
+ <div
120
+ onClickCapture={cancelNext}
121
+ ref={floating}
122
+ style={{
123
+ display: 'flex',
124
+ position: strategy,
125
+ top: y ?? spaceNone,
126
+ left: x ?? spaceNone,
127
+ }}
128
+ >
129
+ <Menu
130
+ {...menu}
131
+ onSelect={(option) => {
132
+ onOptionSelect && onOptionSelect(option);
133
+ if (
134
+ !menu.optionsVariant ||
135
+ menu.optionsVariant === 'normal'
136
+ ) {
137
+ clickAway();
138
+ }
139
+ }}
140
+ size={menu.size || 'medium'}
141
+ />
142
+ </div>
143
+ )}
144
+ </div>
145
+ )}
146
+ </ClickAway>
147
+ );
148
+ },
149
+ );
@@ -11,7 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
13
 
14
- const LinearLoader = _ref => {
14
+ const LinearLoader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
15
15
  let {
16
16
  value,
17
17
  size = 'medium',
@@ -22,12 +22,13 @@ const LinearLoader = _ref => {
22
22
  [_LinearLoaderModule.default.large]: size === 'large',
23
23
  [_LinearLoaderModule.default.medium]: size === 'medium',
24
24
  [_LinearLoaderModule.default.small]: size === 'small'
25
- }, className)
25
+ }, className),
26
+ ref: ref
26
27
  }, /*#__PURE__*/React.createElement("div", {
27
28
  className: _LinearLoaderModule.default.progressBar,
28
29
  style: {
29
30
  width: `${value + '%'}`
30
31
  }
31
32
  }));
32
- };
33
+ });
33
34
  exports.LinearLoader = LinearLoader;
@@ -13,22 +13,24 @@ export type LinearLoaderProps = {
13
13
  className?: string,
14
14
  };
15
15
 
16
- export const LinearLoader = ({
17
- value,
18
- size = 'medium',
19
- className,
20
- }: LinearLoaderProps): React.Node => (
21
- <div
22
- className={classify(
23
- css.lineContainer,
24
- {
25
- [css.large]: size === 'large',
26
- [css.medium]: size === 'medium',
27
- [css.small]: size === 'small',
28
- },
29
- className,
30
- )}
31
- >
32
- <div className={css.progressBar} style={{width: `${value + '%'}`}}></div>
33
- </div>
16
+ export const LinearLoader: React$AbstractComponent<
17
+ LinearLoaderProps,
18
+ HTMLDivElement,
19
+ > = React.forwardRef<LinearLoaderProps, HTMLDivElement>(
20
+ ({value, size = 'medium', className}: LinearLoaderProps, ref): React.Node => (
21
+ <div
22
+ className={classify(
23
+ css.lineContainer,
24
+ {
25
+ [css.large]: size === 'large',
26
+ [css.medium]: size === 'medium',
27
+ [css.small]: size === 'small',
28
+ },
29
+ className,
30
+ )}
31
+ ref={ref}
32
+ >
33
+ <div className={css.progressBar} style={{width: `${value + '%'}`}}></div>
34
+ </div>
35
+ ),
34
36
  );
@@ -65,9 +65,16 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
65
65
  disabled,
66
66
  ...props
67
67
  } = _ref;
68
+ const linkRef = React.useRef(null);
69
+ React.useImperativeHandle(ref, () => linkRef.current);
70
+ React.useEffect(() => {
71
+ if (disabled) {
72
+ linkRef.current?.blur();
73
+ }
74
+ }, [disabled]);
68
75
  return /*#__PURE__*/React.createElement("a", _extends({}, props, {
69
76
  tabIndex: disabled ? -1 : tabIndex,
70
- innerref: ref,
77
+ ref: linkRef,
71
78
  "data-testid": "Link",
72
79
  className: (0, _classify.default)(_typographyModule.default.link, _typographyModule.default[as], _typographyModule.default[color], {
73
80
  [_typographyModule.default.underline]: underline,
@@ -72,40 +72,48 @@ export type LinkProps = {
72
72
  ...
73
73
  };
74
74
 
75
- export const Link: React$AbstractComponent<
76
- LinkProps,
77
- React.Element<'a'>,
78
- > = React.forwardRef<LinkProps, React.Element<'a'>>(
79
- (
80
- {
81
- color = TEXT_COLORS.clickable,
82
- children,
83
- className,
84
- as = 'buttonTextExtraSmall',
85
- underline = true,
86
- tabIndex = 0,
87
- disabled,
88
- ...props
89
- }: LinkProps,
90
- ref,
91
- ) => (
92
- <a
93
- {...props}
94
- tabIndex={disabled ? -1 : tabIndex}
95
- innerref={ref}
96
- data-testid="Link"
97
- className={classify(
98
- css.link,
99
- css[as],
100
- css[color],
101
- {
102
- [css.underline]: underline,
103
- [css.disabled]: disabled,
104
- },
75
+ export const Link: React$AbstractComponent<LinkProps, HTMLAnchorElement> =
76
+ React.forwardRef<LinkProps, HTMLAnchorElement>(
77
+ (
78
+ {
79
+ color = TEXT_COLORS.clickable,
80
+ children,
105
81
  className,
106
- )}
107
- >
108
- {children}
109
- </a>
110
- ),
111
- );
82
+ as = 'buttonTextExtraSmall',
83
+ underline = true,
84
+ tabIndex = 0,
85
+ disabled,
86
+ ...props
87
+ }: LinkProps,
88
+ ref,
89
+ ) => {
90
+ const linkRef = React.useRef(null);
91
+ React.useImperativeHandle(ref, () => linkRef.current);
92
+ React.useEffect(() => {
93
+ if (disabled) {
94
+ linkRef.current?.blur();
95
+ }
96
+ }, [disabled]);
97
+
98
+ return (
99
+ <a
100
+ {...props}
101
+ tabIndex={disabled ? -1 : tabIndex}
102
+ ref={linkRef}
103
+ data-testid="Link"
104
+ className={classify(
105
+ css.link,
106
+ css[as],
107
+ css[color],
108
+ {
109
+ [css.underline]: underline,
110
+ [css.disabled]: disabled,
111
+ },
112
+ className,
113
+ )}
114
+ >
115
+ {children}
116
+ </a>
117
+ );
118
+ },
119
+ );
@@ -22,7 +22,7 @@ const NOTIFICATION_SEMANTIC = Object.freeze({
22
22
  exports.NOTIFICATION_SEMANTIC = NOTIFICATION_SEMANTIC;
23
23
  // Base Notification will not have any state.
24
24
 
25
- const BaseNotification = props => {
25
+ const BaseNotification = /*#__PURE__*/React.forwardRef((props, ref) => {
26
26
  const {
27
27
  classNames,
28
28
  semantic = NOTIFICATION_SEMANTIC.success,
@@ -38,7 +38,8 @@ const BaseNotification = props => {
38
38
  [_NotificationModule.default.information]: semantic === NOTIFICATION_SEMANTIC.information,
39
39
  [_NotificationModule.default.danger]: semantic === NOTIFICATION_SEMANTIC.danger,
40
40
  [_NotificationModule.default.dismissable]: dismissable
41
- }, classNames?.wrapper)
41
+ }, classNames?.wrapper),
42
+ ref: ref
42
43
  }, iconLeftName ? /*#__PURE__*/React.createElement(_Icon.Icon, {
43
44
  name: iconLeftName,
44
45
  color: _typography.TEXT_COLORS.inversePrimary,
@@ -55,8 +56,8 @@ const BaseNotification = props => {
55
56
  onClick: onCloseClick,
56
57
  className: _NotificationModule.default.closeIcon
57
58
  }));
58
- };
59
- const Notification = props => {
59
+ });
60
+ const Notification = /*#__PURE__*/React.forwardRef((props, ref) => {
60
61
  const {
61
62
  classNames,
62
63
  semantic = NOTIFICATION_SEMANTIC.success,
@@ -78,7 +79,8 @@ const Notification = props => {
78
79
  iconLeftType: iconLeftType,
79
80
  semantic: semantic,
80
81
  dismissable: dismissable,
81
- onCloseClick: closeClickHandler
82
+ onCloseClick: closeClickHandler,
83
+ ref: ref
82
84
  }, children));
83
- };
85
+ });
84
86
  exports.Notification = Notification;