@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
@@ -69,65 +69,74 @@ export const CollapsibleCardContent = ({
69
69
  <div className={classify(css.contentContainer, className)}>{children}</div>
70
70
  );
71
71
 
72
- export const CollapsibleCard = ({
73
- id,
74
- isOpen,
75
- onChange,
76
- classNames,
77
- title,
78
- children,
79
- semantic = 'neutral',
80
- headerIconName,
81
- headerIconType = 'solid',
82
- }: CollapsibleCardProps): React.Node => {
83
- const [collapsibleCardIsOpen, setCollapsibleCardIsOpen] = React.useState(
84
- Boolean(isOpen),
85
- );
86
-
87
- return (
88
- <div
89
- data-testid="CollapsibleCard"
90
- className={classify(css.wrapper, classNames?.wrapper)}
91
- >
92
- <UnstyledButton
93
- className={classify(
94
- css.header,
95
- {
96
- [css.isOpen]: collapsibleCardIsOpen,
97
- },
98
- classNames?.title,
99
- )}
100
- onClick={(e) => {
101
- onChange?.(e, !collapsibleCardIsOpen, id);
102
- setCollapsibleCardIsOpen(!collapsibleCardIsOpen);
103
- }}
72
+ export const CollapsibleCard: React$AbstractComponent<
73
+ CollapsibleCardProps,
74
+ HTMLDivElement,
75
+ > = React.forwardRef<CollapsibleCardProps, HTMLDivElement>(
76
+ (
77
+ {
78
+ id,
79
+ isOpen,
80
+ onChange,
81
+ classNames,
82
+ title,
83
+ children,
84
+ semantic = 'neutral',
85
+ headerIconName,
86
+ headerIconType = 'solid',
87
+ }: CollapsibleCardProps,
88
+ ref,
89
+ ): React.Node => {
90
+ const [collapsibleCardIsOpen, setCollapsibleCardIsOpen] = React.useState(
91
+ Boolean(isOpen),
92
+ );
93
+
94
+ return (
95
+ <div
96
+ data-testid="CollapsibleCard"
97
+ className={classify(css.wrapper, classNames?.wrapper)}
98
+ ref={ref}
104
99
  >
105
- <div className={css.headerContent}>
106
- {!!headerIconName && (
107
- <div className={classify(css.iconContainer, css[semantic])}>
108
- <Icon
109
- name={headerIconName}
110
- type={headerIconType}
111
- size="small"
112
- className={css[semantic]}
113
- />
114
- </div>
100
+ <UnstyledButton
101
+ className={classify(
102
+ css.header,
103
+ {
104
+ [css.isOpen]: collapsibleCardIsOpen,
105
+ },
106
+ classNames?.title,
115
107
  )}
116
-
117
- <Truncate>{title}</Truncate>
118
- </div>
119
-
120
- {collapsibleCardIsOpen ? (
121
- <Icon name="chevron-up" color="secondary" size="small" />
122
- ) : (
123
- <Icon name="chevron-down" color="secondary" size="small" />
108
+ onClick={(e) => {
109
+ onChange?.(e, !collapsibleCardIsOpen, id);
110
+ setCollapsibleCardIsOpen(!collapsibleCardIsOpen);
111
+ }}
112
+ >
113
+ <div className={css.headerContent}>
114
+ {!!headerIconName && (
115
+ <div className={classify(css.iconContainer, css[semantic])}>
116
+ <Icon
117
+ name={headerIconName}
118
+ type={headerIconType}
119
+ size="small"
120
+ className={css[semantic]}
121
+ />
122
+ </div>
123
+ )}
124
+
125
+ <Truncate>{title}</Truncate>
126
+ </div>
127
+
128
+ {collapsibleCardIsOpen ? (
129
+ <Icon name="chevron-up" color="secondary" size="small" />
130
+ ) : (
131
+ <Icon name="chevron-down" color="secondary" size="small" />
132
+ )}
133
+ </UnstyledButton>
134
+ {collapsibleCardIsOpen && (
135
+ <div className={classify(css.content, classNames?.content)}>
136
+ {children}
137
+ </div>
124
138
  )}
125
- </UnstyledButton>
126
- {collapsibleCardIsOpen && (
127
- <div className={classify(css.content, classNames?.content)}>
128
- {children}
129
- </div>
130
- )}
131
- </div>
132
- );
133
- };
139
+ </div>
140
+ );
141
+ },
142
+ );
@@ -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 Dropdown = _ref => {
21
+ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
22
22
  let {
23
23
  size = 'medium',
24
24
  classNames,
@@ -72,7 +72,8 @@ const Dropdown = _ref => {
72
72
  onContainerClick: e => {
73
73
  e.stopPropagation();
74
74
  onOpen();
75
- }
75
+ },
76
+ ref: ref
76
77
  })), isOpen && menu && /*#__PURE__*/React.createElement("div", {
77
78
  onClickCapture: cancelNext,
78
79
  ref: floating,
@@ -93,5 +94,5 @@ const Dropdown = _ref => {
93
94
  size: menu.size || size
94
95
  }))));
95
96
  });
96
- };
97
+ });
97
98
  exports.Dropdown = Dropdown;
@@ -38,81 +38,90 @@ export type DropdownProps = {
38
38
  ...
39
39
  };
40
40
 
41
- export const Dropdown = ({
42
- size = 'medium',
43
- classNames,
44
- placeholder = 'Select...',
45
- onChange,
46
- menu,
47
- onMenuOpen,
48
- onMenuClose,
49
- dropdownInputText = '',
50
- ...inputProps
51
- }: DropdownProps): React.Node => {
52
- const dropdownRef = React.useRef();
53
- const {x, y, reference, floating, strategy} = useFloating({
54
- strategy: 'absolute',
55
- placement: 'bottom-start',
56
- whileElementsMounted: autoUpdate,
57
- middleware: [flip(), offset(parseInt(spaceXXSmall))],
58
- });
41
+ export const Dropdown: React$AbstractComponent<
42
+ DropdownProps,
43
+ HTMLInputElement,
44
+ > = React.forwardRef<DropdownProps, HTMLInputElement>(
45
+ (
46
+ {
47
+ size = 'medium',
48
+ classNames,
49
+ placeholder = 'Select...',
50
+ onChange,
51
+ menu,
52
+ onMenuOpen,
53
+ onMenuClose,
54
+ dropdownInputText = '',
55
+ ...inputProps
56
+ }: DropdownProps,
57
+ ref,
58
+ ): React.Node => {
59
+ const dropdownRef = React.useRef();
60
+ const {x, y, reference, floating, strategy} = useFloating({
61
+ strategy: 'absolute',
62
+ placement: 'bottom-start',
63
+ whileElementsMounted: autoUpdate,
64
+ middleware: [flip(), offset(parseInt(spaceXXSmall))],
65
+ });
59
66
 
60
- const onMenuToggle = (isOpen: boolean) => {
61
- isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
62
- };
67
+ const onMenuToggle = (isOpen: boolean) => {
68
+ isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
69
+ };
63
70
 
64
- return (
65
- <ClickAway onChange={onMenuToggle}>
66
- {({isOpen, onOpen, cancelNext, clickAway}) => (
67
- <div
68
- data-testid="Dropdown"
69
- className={classify(css.dropdownContainer, classNames?.wrapper)}
70
- ref={dropdownRef}
71
- >
72
- <Input
73
- {...inputProps}
74
- boxRef={reference}
75
- size={size}
76
- placeholder={placeholder}
77
- value={dropdownInputText}
78
- classNames={{box: css.inputBox}}
79
- iconRightName={isOpen ? 'angle-up' : 'angle-down'}
80
- readOnly
81
- onContainerClick={(e) => {
82
- e.stopPropagation();
83
- onOpen();
84
- }}
85
- />
86
-
87
- {isOpen && menu && (
88
- <div
89
- onClickCapture={cancelNext}
90
- ref={floating}
91
- style={{
92
- position: strategy,
93
- top: y ?? spaceNone,
94
- left: x ?? spaceNone,
95
- width: sizeFluid,
96
- backgroundColor: colorBackgroundTertiary,
71
+ return (
72
+ <ClickAway onChange={onMenuToggle}>
73
+ {({isOpen, onOpen, cancelNext, clickAway}) => (
74
+ <div
75
+ data-testid="Dropdown"
76
+ className={classify(css.dropdownContainer, classNames?.wrapper)}
77
+ ref={dropdownRef}
78
+ >
79
+ <Input
80
+ {...inputProps}
81
+ boxRef={reference}
82
+ size={size}
83
+ placeholder={placeholder}
84
+ value={dropdownInputText}
85
+ classNames={{box: css.inputBox}}
86
+ iconRightName={isOpen ? 'angle-up' : 'angle-down'}
87
+ readOnly
88
+ onContainerClick={(e) => {
89
+ e.stopPropagation();
90
+ onOpen();
97
91
  }}
98
- >
99
- <Menu
100
- {...menu}
101
- onSelect={(option) => {
102
- onChange && onChange(option);
103
- if (
104
- !menu.optionsVariant ||
105
- menu.optionsVariant === 'normal'
106
- ) {
107
- clickAway();
108
- }
92
+ ref={ref}
93
+ />
94
+
95
+ {isOpen && menu && (
96
+ <div
97
+ onClickCapture={cancelNext}
98
+ ref={floating}
99
+ style={{
100
+ position: strategy,
101
+ top: y ?? spaceNone,
102
+ left: x ?? spaceNone,
103
+ width: sizeFluid,
104
+ backgroundColor: colorBackgroundTertiary,
109
105
  }}
110
- size={menu.size || size}
111
- />
112
- </div>
113
- )}
114
- </div>
115
- )}
116
- </ClickAway>
117
- );
118
- };
106
+ >
107
+ <Menu
108
+ {...menu}
109
+ onSelect={(option) => {
110
+ onChange && onChange(option);
111
+ if (
112
+ !menu.optionsVariant ||
113
+ menu.optionsVariant === 'normal'
114
+ ) {
115
+ clickAway();
116
+ }
117
+ }}
118
+ size={menu.size || size}
119
+ />
120
+ </div>
121
+ )}
122
+ </div>
123
+ )}
124
+ </ClickAway>
125
+ );
126
+ },
127
+ );
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  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); }
13
13
  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; }
14
14
  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); }
15
- const EmptyState = _ref => {
15
+ const EmptyState = /*#__PURE__*/React.forwardRef((_ref, ref) => {
16
16
  let {
17
17
  classNames,
18
18
  children,
@@ -24,7 +24,8 @@ const EmptyState = _ref => {
24
24
  } = _ref;
25
25
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
26
26
  "data-testid": "EmptyState",
27
- className: (0, _classify.default)(_EmptyStateModule.default.wrapper, classNames?.wrapper)
27
+ className: (0, _classify.default)(_EmptyStateModule.default.wrapper, classNames?.wrapper),
28
+ ref: ref
28
29
  }), !!imageVariant && !customImageUrl && /*#__PURE__*/React.createElement("div", {
29
30
  className: (0, _classify.default)(_EmptyStateModule.default.image, classNames?.image)
30
31
  }, imageVariant === 'calendar' && /*#__PURE__*/React.createElement(_EmptyImages.CalendarEmptyImage, null), imageVariant === 'data' && /*#__PURE__*/React.createElement(_EmptyImages.DataEmptyImage, null), imageVariant === 'file' && /*#__PURE__*/React.createElement(_EmptyImages.FileEmptyImage, null), imageVariant === 'message' && /*#__PURE__*/React.createElement(_EmptyImages.MessageEmptyImage, null), imageVariant === 'upload' && /*#__PURE__*/React.createElement(_EmptyImages.UploadEmptyImage, null)), customImageUrl && /*#__PURE__*/React.createElement("img", {
@@ -38,5 +39,5 @@ const EmptyState = _ref => {
38
39
  }, description), !!children && /*#__PURE__*/React.createElement("div", {
39
40
  className: (0, _classify.default)(_EmptyStateModule.default.childrenWrapper, classNames?.children)
40
41
  }, children));
41
- };
42
+ });
42
43
  exports.EmptyState = EmptyState;
@@ -33,48 +33,57 @@ export type EmptyStateProps = {
33
33
  ...
34
34
  };
35
35
 
36
- export const EmptyState = ({
37
- classNames,
38
- children,
39
- imageVariant,
40
- title,
41
- description,
42
- customImageUrl,
43
- ...props
44
- }: EmptyStateProps): React.Node => (
45
- <div
46
- {...props}
47
- data-testid="EmptyState"
48
- className={classify(css.wrapper, classNames?.wrapper)}
49
- >
50
- {!!imageVariant && !customImageUrl && (
51
- <div className={classify(css.image, classNames?.image)}>
52
- {imageVariant === 'calendar' && <CalendarEmptyImage />}
53
- {imageVariant === 'data' && <DataEmptyImage />}
54
- {imageVariant === 'file' && <FileEmptyImage />}
55
- {imageVariant === 'message' && <MessageEmptyImage />}
56
- {imageVariant === 'upload' && <UploadEmptyImage />}
57
- </div>
58
- )}
59
- {customImageUrl && (
60
- <img
61
- className={classify(css.image, classNames?.image)}
62
- src={customImageUrl}
63
- alt="Empty State"
64
- />
65
- )}
66
- {!!title && (
67
- <div className={classify(css.title, classNames?.title)}>{title}</div>
68
- )}
69
- {!!description && (
70
- <div className={classify(css.description, classNames?.description)}>
71
- {description}
72
- </div>
73
- )}
74
- {!!children && (
75
- <div className={classify(css.childrenWrapper, classNames?.children)}>
76
- {children}
77
- </div>
78
- )}
79
- </div>
36
+ export const EmptyState: React$AbstractComponent<
37
+ EmptyStateProps,
38
+ HTMLDivElement,
39
+ > = React.forwardRef<EmptyStateProps, HTMLDivElement>(
40
+ (
41
+ {
42
+ classNames,
43
+ children,
44
+ imageVariant,
45
+ title,
46
+ description,
47
+ customImageUrl,
48
+ ...props
49
+ }: EmptyStateProps,
50
+ ref,
51
+ ): React.Node => (
52
+ <div
53
+ {...props}
54
+ data-testid="EmptyState"
55
+ className={classify(css.wrapper, classNames?.wrapper)}
56
+ ref={ref}
57
+ >
58
+ {!!imageVariant && !customImageUrl && (
59
+ <div className={classify(css.image, classNames?.image)}>
60
+ {imageVariant === 'calendar' && <CalendarEmptyImage />}
61
+ {imageVariant === 'data' && <DataEmptyImage />}
62
+ {imageVariant === 'file' && <FileEmptyImage />}
63
+ {imageVariant === 'message' && <MessageEmptyImage />}
64
+ {imageVariant === 'upload' && <UploadEmptyImage />}
65
+ </div>
66
+ )}
67
+ {customImageUrl && (
68
+ <img
69
+ className={classify(css.image, classNames?.image)}
70
+ src={customImageUrl}
71
+ alt="Empty State"
72
+ />
73
+ )}
74
+ {!!title && (
75
+ <div className={classify(css.title, classNames?.title)}>{title}</div>
76
+ )}
77
+ {!!description && (
78
+ <div className={classify(css.description, classNames?.description)}>
79
+ {description}
80
+ </div>
81
+ )}
82
+ {!!children && (
83
+ <div className={classify(css.childrenWrapper, classNames?.children)}>
84
+ {children}
85
+ </div>
86
+ )}
87
+ </div>
88
+ ),
80
89
  );
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  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); }
13
13
  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; }
14
14
  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); }
15
- const ErrorMessage = _ref => {
15
+ const ErrorMessage = /*#__PURE__*/React.forwardRef((_ref, ref) => {
16
16
  let {
17
17
  classNames,
18
18
  children,
@@ -25,7 +25,8 @@ const ErrorMessage = _ref => {
25
25
  } = _ref;
26
26
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
27
27
  "data-testid": "ErrorMessage",
28
- className: (0, _classify.default)(_ErrorMessageModule.default.wrapper, classNames?.wrapper)
28
+ className: (0, _classify.default)(_ErrorMessageModule.default.wrapper, classNames?.wrapper),
29
+ ref: ref
29
30
  }), !!imageVariant && !customImageUrl && /*#__PURE__*/React.createElement("div", {
30
31
  className: (0, _classify.default)(_ErrorMessageModule.default.image, classNames?.image)
31
32
  }, imageVariant === 'unauthorized' && /*#__PURE__*/React.createElement(_ErrorImages.UnauthorizedImage, null), imageVariant === 'forbidden' && /*#__PURE__*/React.createElement(_ErrorImages.ForbiddenImage, null), imageVariant === 'notFound' && /*#__PURE__*/React.createElement(_ErrorImages.NotFoundImage, null), imageVariant === 'serverError' && /*#__PURE__*/React.createElement(_ErrorImages.ServerErrorImage, null)), customImageUrl && /*#__PURE__*/React.createElement("img", {
@@ -41,5 +42,5 @@ const ErrorMessage = _ref => {
41
42
  }, description), !!children && /*#__PURE__*/React.createElement("div", {
42
43
  className: (0, _classify.default)(_ErrorMessageModule.default.childrenWrapper, classNames?.children)
43
44
  }, children));
44
- };
45
+ });
45
46
  exports.ErrorMessage = ErrorMessage;
@@ -34,53 +34,62 @@ export type ErrorMessageProps = {
34
34
  ...
35
35
  };
36
36
 
37
- export const ErrorMessage = ({
38
- classNames,
39
- children,
40
- imageVariant,
41
- title,
42
- description,
43
- customImageUrl,
44
- heading,
45
- ...props
46
- }: ErrorMessageProps): React.Node => (
47
- <div
48
- {...props}
49
- data-testid="ErrorMessage"
50
- className={classify(css.wrapper, classNames?.wrapper)}
51
- >
52
- {!!imageVariant && !customImageUrl && (
53
- <div className={classify(css.image, classNames?.image)}>
54
- {imageVariant === 'unauthorized' && <UnauthorizedImage />}
55
- {imageVariant === 'forbidden' && <ForbiddenImage />}
56
- {imageVariant === 'notFound' && <NotFoundImage />}
57
- {imageVariant === 'serverError' && <ServerErrorImage />}
58
- </div>
59
- )}
60
- {customImageUrl && (
61
- <img
62
- className={classify(css.image, classNames?.image)}
63
- src={customImageUrl}
64
- alt="Empty State"
65
- />
66
- )}
67
- {!!heading && (
68
- <div className={classify(css.heading, classNames?.heading)}>
69
- {heading}
70
- </div>
71
- )}
72
- {!!title && (
73
- <div className={classify(css.title, classNames?.title)}>{title}</div>
74
- )}
75
- {!!description && (
76
- <div className={classify(css.description, classNames?.description)}>
77
- {description}
78
- </div>
79
- )}
80
- {!!children && (
81
- <div className={classify(css.childrenWrapper, classNames?.children)}>
82
- {children}
83
- </div>
84
- )}
85
- </div>
37
+ export const ErrorMessage: React$AbstractComponent<
38
+ ErrorMessageProps,
39
+ HTMLDivElement,
40
+ > = React.forwardRef<ErrorMessageProps, HTMLDivElement>(
41
+ (
42
+ {
43
+ classNames,
44
+ children,
45
+ imageVariant,
46
+ title,
47
+ description,
48
+ customImageUrl,
49
+ heading,
50
+ ...props
51
+ }: ErrorMessageProps,
52
+ ref,
53
+ ): React.Node => (
54
+ <div
55
+ {...props}
56
+ data-testid="ErrorMessage"
57
+ className={classify(css.wrapper, classNames?.wrapper)}
58
+ ref={ref}
59
+ >
60
+ {!!imageVariant && !customImageUrl && (
61
+ <div className={classify(css.image, classNames?.image)}>
62
+ {imageVariant === 'unauthorized' && <UnauthorizedImage />}
63
+ {imageVariant === 'forbidden' && <ForbiddenImage />}
64
+ {imageVariant === 'notFound' && <NotFoundImage />}
65
+ {imageVariant === 'serverError' && <ServerErrorImage />}
66
+ </div>
67
+ )}
68
+ {customImageUrl && (
69
+ <img
70
+ className={classify(css.image, classNames?.image)}
71
+ src={customImageUrl}
72
+ alt="Empty State"
73
+ />
74
+ )}
75
+ {!!heading && (
76
+ <div className={classify(css.heading, classNames?.heading)}>
77
+ {heading}
78
+ </div>
79
+ )}
80
+ {!!title && (
81
+ <div className={classify(css.title, classNames?.title)}>{title}</div>
82
+ )}
83
+ {!!description && (
84
+ <div className={classify(css.description, classNames?.description)}>
85
+ {description}
86
+ </div>
87
+ )}
88
+ {!!children && (
89
+ <div className={classify(css.childrenWrapper, classNames?.children)}>
90
+ {children}
91
+ </div>
92
+ )}
93
+ </div>
94
+ ),
86
95
  );
@@ -75,7 +75,7 @@ const AlertIcon = _ref => {
75
75
  });
76
76
  }
77
77
  };
78
- const InContextAlert = props => {
78
+ const InContextAlert = /*#__PURE__*/React.forwardRef((props, ref) => {
79
79
  const {
80
80
  classNames,
81
81
  semantic = ALERT_SEMANTIC.neutral,
@@ -100,7 +100,8 @@ const InContextAlert = props => {
100
100
  [_InContextAlertModule.default.information]: semantic === ALERT_SEMANTIC.information,
101
101
  [_InContextAlertModule.default.warning]: semantic === ALERT_SEMANTIC.warning,
102
102
  [_InContextAlertModule.default.danger]: semantic === ALERT_SEMANTIC.danger
103
- }, classNames?.wrapper)
103
+ }, classNames?.wrapper),
104
+ ref: ref
104
105
  }, /*#__PURE__*/React.createElement(AlertIcon, {
105
106
  semantic: semantic,
106
107
  leftIconName: leftIconName,
@@ -122,5 +123,5 @@ const InContextAlert = props => {
122
123
  onClick: closeClickHandler,
123
124
  className: _InContextAlertModule.default.closeIcon
124
125
  }))));
125
- };
126
+ });
126
127
  exports.InContextAlert = InContextAlert;