@spaced-out/ui-design-system 0.1.15 → 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 (102) hide show
  1. package/.cspell/custom-words.txt +3 -0
  2. package/.flowconfig +1 -1
  3. package/CHANGELOG.md +15 -0
  4. package/CONTRIBUTING.md +52 -6
  5. package/README.md +144 -8
  6. package/gulpfile.js +1 -0
  7. package/lib/components/Avatar/Avatar.module.css +8 -2
  8. package/lib/components/AvatarGroup/AvatarGroup.js +25 -14
  9. package/lib/components/AvatarGroup/AvatarGroup.js.flow +118 -103
  10. package/lib/components/Badge/Badge.js +4 -3
  11. package/lib/components/Badge/Badge.js.flow +21 -21
  12. package/lib/components/Badge/index.js +11 -7
  13. package/lib/components/Badge/index.js.flow +1 -2
  14. package/lib/components/Banner/Banner.js +3 -2
  15. package/lib/components/Banner/Banner.js.flow +42 -35
  16. package/lib/components/Button/Button.js +50 -10
  17. package/lib/components/Button/Button.js.flow +87 -23
  18. package/lib/components/Button/Button.module.css +14 -0
  19. package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +3 -2
  20. package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +48 -38
  21. package/lib/components/ButtonTabs/ButtonTabs.js +3 -2
  22. package/lib/components/ButtonTabs/ButtonTabs.js.flow +50 -41
  23. package/lib/components/Card/Card.js +16 -7
  24. package/lib/components/Card/Card.js.flow +73 -55
  25. package/lib/components/Checkbox/Checkbox.js +15 -10
  26. package/lib/components/Checkbox/Checkbox.js.flow +121 -100
  27. package/lib/components/Checkbox/Checkbox.module.css +4 -1
  28. package/lib/components/Checkbox/CheckboxGroup.js +4 -3
  29. package/lib/components/Checkbox/CheckboxGroup.js.flow +76 -65
  30. package/lib/components/Chip/Chip.js +3 -2
  31. package/lib/components/Chip/Chip.js.flow +66 -59
  32. package/lib/components/CircularLoader/CircularLoader.js +9 -4
  33. package/lib/components/CircularLoader/CircularLoader.js.flow +38 -24
  34. package/lib/components/CollapsibleCard/CollapsibleCard.js +4 -3
  35. package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +68 -59
  36. package/lib/components/Dropdown/Dropdown.js +4 -3
  37. package/lib/components/Dropdown/Dropdown.js.flow +83 -74
  38. package/lib/components/EmptyState/EmptyState.js +4 -3
  39. package/lib/components/EmptyState/EmptyState.js.flow +53 -44
  40. package/lib/components/ErrorMessage/ErrorMessage.js +4 -3
  41. package/lib/components/ErrorMessage/ErrorMessage.js.flow +58 -49
  42. package/lib/components/InContextAlert/InContextAlert.js +4 -3
  43. package/lib/components/InContextAlert/InContextAlert.js.flow +79 -73
  44. package/lib/components/InlineDropdown/InlineDropdown.js +4 -3
  45. package/lib/components/InlineDropdown/InlineDropdown.js.flow +94 -85
  46. package/lib/components/LinearLoader/LinearLoader.js +4 -3
  47. package/lib/components/LinearLoader/LinearLoader.js.flow +20 -18
  48. package/lib/components/Link/Link.js +8 -1
  49. package/lib/components/Link/Link.js.flow +44 -36
  50. package/lib/components/Notification/Notification.js +8 -6
  51. package/lib/components/Notification/Notification.js.flow +96 -84
  52. package/lib/components/OptionButton/OptionButton.js +7 -4
  53. package/lib/components/OptionButton/OptionButton.js.flow +69 -59
  54. package/lib/components/PageTitle/PageTitle.js +4 -3
  55. package/lib/components/PageTitle/PageTitle.js.flow +46 -44
  56. package/lib/components/Pagination/PaginationItem.js +2 -2
  57. package/lib/components/Pagination/PaginationItem.js.flow +2 -2
  58. package/lib/components/RadioButton/RadioButton.js +15 -9
  59. package/lib/components/RadioButton/RadioButton.js.flow +91 -70
  60. package/lib/components/RadioButton/RadioButton.module.css +4 -1
  61. package/lib/components/RadioButton/RadioGroup.js +4 -3
  62. package/lib/components/RadioButton/RadioGroup.js.flow +56 -47
  63. package/lib/components/SearchInput/SearchInput.js +3 -2
  64. package/lib/components/SearchInput/SearchInput.js.flow +59 -50
  65. package/lib/components/SideMenuLink/SideMenuLink.js +4 -3
  66. package/lib/components/SideMenuLink/SideMenuLink.js.flow +54 -45
  67. package/lib/components/StatusIndicator/StatusIndicator.js +3 -2
  68. package/lib/components/StatusIndicator/StatusIndicator.js.flow +32 -23
  69. package/lib/components/SubMenu/SubMenu.js +4 -3
  70. package/lib/components/SubMenu/SubMenu.js.flow +41 -38
  71. package/lib/components/Table/StaticTable.js +3 -0
  72. package/lib/components/Table/StaticTable.js.flow +3 -0
  73. package/lib/components/Table/Table.js +10 -0
  74. package/lib/components/Table/Table.js.flow +10 -0
  75. package/lib/components/Table/hooks.js +1 -0
  76. package/lib/components/Table/hooks.js.flow +1 -0
  77. package/lib/components/Tabs/TabList/TabList.js +3 -2
  78. package/lib/components/Tabs/TabList/TabList.js.flow +127 -117
  79. package/lib/components/Toast/Toast.js +8 -10
  80. package/lib/components/Toast/Toast.js.flow +19 -27
  81. package/lib/components/Toast/Toast.module.css +8 -0
  82. package/lib/components/Toggle/Toggle.js +11 -7
  83. package/lib/components/Toggle/Toggle.js.flow +16 -12
  84. package/lib/components/Toggle/Toggle.module.css +2 -0
  85. package/lib/components/Toggle/index.js +11 -7
  86. package/lib/components/Toggle/index.js.flow +1 -1
  87. package/lib/components/Tooltip/Tooltip.js.flow +2 -2
  88. package/lib/components/index.js +511 -0
  89. package/lib/components/index.js.flow +48 -0
  90. package/lib/index.js +60 -0
  91. package/lib/index.js.flow +7 -0
  92. package/lib/styles/index.css +15 -0
  93. package/lib/styles/index.js +104 -0
  94. package/lib/styles/index.js.flow +12 -0
  95. package/lib/styles/typography.module.css +0 -1
  96. package/lib/styles/utils.module.css +26 -0
  97. package/lib/types/index.js +38 -0
  98. package/lib/types/index.js.flow +5 -0
  99. package/lib/utils/click-away.js.flow +1 -1
  100. package/lib/utils/index.js +93 -0
  101. package/lib/utils/index.js.flow +10 -0
  102. package/package.json +2 -1
@@ -29,112 +29,127 @@ export type AvatarGroupProps = {
29
29
  tooltipElevation?: string,
30
30
  };
31
31
 
32
- export const AvatarGroup = ({
33
- children,
34
- size = 'medium',
35
- borderColor = colorBackgroundTertiary,
36
- maxTooltipLines = 7,
37
- placement = 'top',
38
- maxAvatars = 5,
39
- tooltipElevation,
40
- }: AvatarGroupProps): React.Node => {
41
- const childAvatarCount = React.Children.count(children);
42
-
43
- const leftOverlap = {
44
- small: spaceXXSmall,
45
- medium: `${parseInt(spaceSmall) / 2}px`,
46
- large: spaceXSmall,
47
- };
48
-
49
- let colorIndex = -1;
50
-
51
- const avatarInGroup = (child, index, color) =>
52
- React.cloneElement(child, {
53
- size,
54
- classNames: {wrapper: css.avatarInGroup},
55
- style: {
56
- borderColor,
57
- marginLeft: `-${index !== 0 ? leftOverlap[size] : 0}`,
58
- },
59
- color,
60
- });
32
+ export const AvatarGroup: React$AbstractComponent<
33
+ AvatarGroupProps,
34
+ HTMLDivElement,
35
+ > = React.forwardRef<AvatarGroupProps, HTMLDivElement>(
36
+ (
37
+ {
38
+ children,
39
+ size = 'medium',
40
+ borderColor = colorBackgroundTertiary,
41
+ maxTooltipLines = 7,
42
+ placement = 'top',
43
+ maxAvatars = 5,
44
+ tooltipElevation,
45
+ }: AvatarGroupProps,
46
+ ref,
47
+ ): React.Node => {
48
+ const childAvatarCount = React.Children.count(children);
49
+
50
+ const leftOverlap = {
51
+ small: spaceXXSmall,
52
+ medium: `${parseInt(spaceSmall) / 2}px`,
53
+ large: spaceXSmall,
54
+ };
55
+
56
+ let colorIndex = -1;
57
+
58
+ const avatarInGroup = (child, index, color) => {
59
+ const {classNames} = child.props;
60
+ const {wrapper, ...restClassNames} = classNames || {};
61
+ return React.cloneElement(child, {
62
+ size,
63
+ classNames: {
64
+ wrapper: classify(css.avatarInGroup, wrapper),
65
+ ...restClassNames,
66
+ },
67
+ style: {
68
+ borderColor,
69
+ marginLeft: `-${index !== 0 ? leftOverlap[size] : 0}`,
70
+ },
71
+ color,
72
+ });
73
+ };
74
+
75
+ const childrenArray = React.Children.toArray(children);
76
+ const totalAvatarCount = childrenArray.length;
77
+ const plusAvatar = () => {
78
+ const nameList = [];
79
+
80
+ for (let i = maxAvatars - 1; i < totalAvatarCount; i++) {
81
+ const child = childrenArray[i];
82
+ const {text} = child.props;
83
+ if (text) {
84
+ nameList.push(text);
85
+ }
86
+ }
61
87
 
62
- const childrenArray = React.Children.toArray(children);
63
- const totalAvatarCount = childrenArray.length;
64
- const plusAvatar = () => {
65
- const nameList = [];
88
+ const NameListNode = () => (
89
+ <span>
90
+ {nameList.map((name) => (
91
+ <React.Fragment key={name}>
92
+ {name}
93
+ <br />
94
+ </React.Fragment>
95
+ ))}
96
+ </span>
97
+ );
98
+ return (
99
+ <Tooltip
100
+ body={<NameListNode />}
101
+ bodyMaxLines={maxTooltipLines}
102
+ placement={placement}
103
+ elevation={tooltipElevation}
104
+ >
105
+ <div className={css.plusAvatar}>
106
+ <BaseAvatar
107
+ size={size}
108
+ color="gray"
109
+ text={`+${childAvatarCount - maxAvatars + 1}`}
110
+ classNames={{wrapper: css.avatarInGroup}}
111
+ style={{
112
+ borderColor,
113
+ marginLeft: `-${leftOverlap[size]}`,
114
+ }}
115
+ />
116
+ </div>
117
+ </Tooltip>
118
+ );
119
+ };
120
+
121
+ const childrenWithProps = React.Children.map(children, (child, index) => {
122
+ const {imageSrc} = child.props;
123
+ if (!imageSrc) {
124
+ colorIndex++;
125
+ if (colorIndex === COLOR_SEQUENCE.length) {
126
+ colorIndex = 0;
127
+ }
128
+ }
66
129
 
67
- for (let i = maxAvatars - 1; i < totalAvatarCount; i++) {
68
- const child = childrenArray[i];
69
- const {text} = child.props;
70
- if (text) {
71
- nameList.push(text);
130
+ const color = COLOR_SEQUENCE[colorIndex];
131
+ if (childAvatarCount <= maxAvatars) {
132
+ return avatarInGroup(child, index, color);
133
+ } else {
134
+ if (index < maxAvatars - 1) {
135
+ return avatarInGroup(child, index, color);
136
+ } else if (index === maxAvatars) {
137
+ return plusAvatar();
138
+ }
72
139
  }
73
- }
74
-
75
- const NameListNode = () => (
76
- <span>
77
- {nameList.map((name) => (
78
- <React.Fragment key={name}>
79
- {name}
80
- <br />
81
- </React.Fragment>
82
- ))}
83
- </span>
84
- );
140
+ });
141
+
85
142
  return (
86
- <Tooltip
87
- body={<NameListNode />}
88
- bodyMaxLines={maxTooltipLines}
89
- placement={placement}
90
- elevation={tooltipElevation}
143
+ <div
144
+ className={classify(css.avatarGroupContainer, {
145
+ [css.largeSize]: size === 'large',
146
+ [css.mediumSize]: size === 'medium',
147
+ [css.smallSize]: size === 'small',
148
+ })}
149
+ ref={ref}
91
150
  >
92
- <div className={css.plusAvatar}>
93
- <BaseAvatar
94
- size={size}
95
- color="gray"
96
- text={`+${childAvatarCount - maxAvatars + 1}`}
97
- classNames={{wrapper: css.avatarInGroup}}
98
- style={{
99
- borderColor,
100
- marginLeft: `-${leftOverlap[size]}`,
101
- }}
102
- />
103
- </div>
104
- </Tooltip>
151
+ {childrenWithProps}
152
+ </div>
105
153
  );
106
- };
107
-
108
- const childrenWithProps = React.Children.map(children, (child, index) => {
109
- const {imageSrc} = child.props;
110
- if (!imageSrc) {
111
- colorIndex++;
112
- if (colorIndex === COLOR_SEQUENCE.length) {
113
- colorIndex = 0;
114
- }
115
- }
116
-
117
- const color = COLOR_SEQUENCE[colorIndex];
118
- if (childAvatarCount <= maxAvatars) {
119
- return avatarInGroup(child, index, color);
120
- } else {
121
- if (index < maxAvatars - 1) {
122
- return avatarInGroup(child, index, color);
123
- } else if (index === maxAvatars) {
124
- return plusAvatar();
125
- }
126
- }
127
- });
128
-
129
- return (
130
- <div
131
- className={classify(css.avatarGroupContainer, {
132
- [css.largeSize]: size === 'large',
133
- [css.mediumSize]: size === 'medium',
134
- [css.smallSize]: size === 'small',
135
- })}
136
- >
137
- {childrenWithProps}
138
- </div>
139
- );
140
- };
154
+ },
155
+ );
@@ -22,7 +22,7 @@ const BADGE_COLOR = Object.freeze({
22
22
  indigo: _color.colorNeutralLightest
23
23
  });
24
24
  exports.BADGE_COLOR = BADGE_COLOR;
25
- const Badge = _ref => {
25
+ const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
26
26
  let {
27
27
  classNames,
28
28
  text,
@@ -35,7 +35,8 @@ const Badge = _ref => {
35
35
  }, classNames?.wrapper),
36
36
  style: {
37
37
  backgroundColor: BADGE_COLOR[fill]
38
- }
38
+ },
39
+ ref: ref
39
40
  }, /*#__PURE__*/React.createElement(_Text.ButtonTextSmall, null, text));
40
- };
41
+ });
41
42
  exports.Badge = Badge;
@@ -35,24 +35,24 @@ export type BadgeProps = {
35
35
  fill?: BadgeColorType,
36
36
  };
37
37
 
38
- export const Badge = ({
39
- classNames,
40
- text,
41
- fill = 'gray',
42
- }: BadgeProps): React.Node => (
43
- <div
44
- data-testid="Badge"
45
- className={classify(
46
- css.badgeWrapper,
47
- {
48
- [css.fixedWidth]: text.length <= 2,
49
- },
50
- classNames?.wrapper,
51
- )}
52
- style={{
53
- backgroundColor: BADGE_COLOR[fill],
54
- }}
55
- >
56
- <ButtonTextSmall>{text}</ButtonTextSmall>
57
- </div>
58
- );
38
+ export const Badge: React$AbstractComponent<BadgeProps, HTMLDivElement> =
39
+ React.forwardRef<BadgeProps, HTMLDivElement>(
40
+ ({classNames, text, fill = 'gray'}: BadgeProps, ref): React.Node => (
41
+ <div
42
+ data-testid="Badge"
43
+ className={classify(
44
+ css.badgeWrapper,
45
+ {
46
+ [css.fixedWidth]: text.length <= 2,
47
+ },
48
+ classNames?.wrapper,
49
+ )}
50
+ style={{
51
+ backgroundColor: BADGE_COLOR[fill],
52
+ }}
53
+ ref={ref}
54
+ >
55
+ <ButtonTextSmall>{text}</ButtonTextSmall>
56
+ </div>
57
+ ),
58
+ );
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Badge", {
7
- enumerable: true,
8
- get: function () {
9
- return _Badge.Badge;
10
- }
11
- });
12
- var _Badge = require("./Badge");
6
+ var _Badge = require("./Badge");
7
+ Object.keys(_Badge).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Badge[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Badge[key];
14
+ }
15
+ });
16
+ });
@@ -1,4 +1,3 @@
1
1
  // @flow strict
2
2
 
3
- export type {BadgeProps} from './Badge';
4
- export {Badge} from './Badge';
3
+ export * from './Badge';
@@ -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 Banner = _ref => {
15
+ const Banner = /*#__PURE__*/React.forwardRef((_ref, ref) => {
16
16
  let {
17
17
  classNames,
18
18
  semantic,
@@ -23,6 +23,7 @@ const Banner = _ref => {
23
23
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_InContextAlert.InContextAlert, _extends({}, props, {
24
24
  leftIconType: leftIconType,
25
25
  semantic: semantic,
26
+ ref: ref,
26
27
  classNames: {
27
28
  wrapper: (0, _classify.default)(_BannerModule.default.bannerContainer, {
28
29
  [_BannerModule.default.neutral]: semantic === _InContextAlert.ALERT_SEMANTIC.neutral,
@@ -37,5 +38,5 @@ const Banner = _ref => {
37
38
  actionContainer: (0, _classify.default)(_BannerModule.default.alertContainer, classNames?.actionContainer)
38
39
  }
39
40
  })));
40
- };
41
+ });
41
42
  exports.Banner = Banner;
@@ -14,38 +14,45 @@ export type BannerProps = {
14
14
  alignment?: 'top' | 'bottom',
15
15
  };
16
16
 
17
- export const Banner = ({
18
- classNames,
19
- semantic,
20
- leftIconType = 'solid',
21
- alignment = 'top',
22
- ...props
23
- }: BannerProps): React.Node => (
24
- <>
25
- <InContextAlert
26
- {...props}
27
- leftIconType={leftIconType}
28
- semantic={semantic}
29
- classNames={{
30
- wrapper: classify(
31
- css.bannerContainer,
32
- {
33
- [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
34
- [css.success]: semantic === ALERT_SEMANTIC.success,
35
- [css.information]: semantic === ALERT_SEMANTIC.information,
36
- [css.warning]: semantic === ALERT_SEMANTIC.warning,
37
- [css.danger]: semantic === ALERT_SEMANTIC.danger,
38
- [css.topAligned]: alignment === 'top',
39
- [css.bottomAligned]: alignment === 'bottom',
40
- },
41
- classNames?.wrapper,
42
- ),
43
- alertText: classify(classNames?.alertText),
44
- actionContainer: classify(
45
- css.alertContainer,
46
- classNames?.actionContainer,
47
- ),
48
- }}
49
- />
50
- </>
51
- );
17
+ export const Banner: React$AbstractComponent<BannerProps, HTMLDivElement> =
18
+ React.forwardRef<BannerProps, HTMLDivElement>(
19
+ (
20
+ {
21
+ classNames,
22
+ semantic,
23
+ leftIconType = 'solid',
24
+ alignment = 'top',
25
+ ...props
26
+ }: BannerProps,
27
+ ref,
28
+ ): React.Node => (
29
+ <>
30
+ <InContextAlert
31
+ {...props}
32
+ leftIconType={leftIconType}
33
+ semantic={semantic}
34
+ ref={ref}
35
+ classNames={{
36
+ wrapper: classify(
37
+ css.bannerContainer,
38
+ {
39
+ [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
40
+ [css.success]: semantic === ALERT_SEMANTIC.success,
41
+ [css.information]: semantic === ALERT_SEMANTIC.information,
42
+ [css.warning]: semantic === ALERT_SEMANTIC.warning,
43
+ [css.danger]: semantic === ALERT_SEMANTIC.danger,
44
+ [css.topAligned]: alignment === 'top',
45
+ [css.bottomAligned]: alignment === 'bottom',
46
+ },
47
+ classNames?.wrapper,
48
+ ),
49
+ alertText: classify(classNames?.alertText),
50
+ actionContainer: classify(
51
+ css.alertContainer,
52
+ classNames?.actionContainer,
53
+ ),
54
+ }}
55
+ />
56
+ </>
57
+ ),
58
+ );
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_ACTION_TYPE = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = require("../../utils/classify");
9
+ var _CircularLoader = require("../CircularLoader");
9
10
  var _Icon = require("../Icon");
10
11
  var _Truncate = require("../Truncate");
11
12
  var _ButtonModule = _interopRequireDefault(require("./Button.module.css"));
@@ -34,6 +35,13 @@ const ButtonTypeToIconColorMap = {
34
35
  ghost: 'primary',
35
36
  danger: 'inversePrimary'
36
37
  };
38
+ const ButtonTypeToLoaderColorMap = {
39
+ primary: 'colorTextInversePrimary',
40
+ secondary: 'colorTextClickable',
41
+ tertiary: 'colorTextPrimary',
42
+ ghost: 'colorTextPrimary',
43
+ danger: 'colorTextInversePrimary'
44
+ };
37
45
  const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
38
46
  let {
39
47
  disabled,
@@ -42,6 +50,7 @@ const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
42
50
  ariaLabel,
43
51
  actionType,
44
52
  tabIndex = 0,
53
+ isLoading,
45
54
  ...props
46
55
  } = _ref;
47
56
  return /*#__PURE__*/React.createElement("button", _extends({}, props, ariaLabel ? {
@@ -54,7 +63,7 @@ const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
54
63
  tabIndex: disabled ? -1 : tabIndex,
55
64
  type: actionType,
56
65
  onClick: event => {
57
- if (disabled) {
66
+ if (disabled || isLoading) {
58
67
  event.preventDefault();
59
68
  } else if (onClick) {
60
69
  onClick(event);
@@ -76,11 +85,13 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
76
85
  disabled = false,
77
86
  actionType = 'button',
78
87
  size = 'medium',
88
+ isLoading,
79
89
  ...props
80
90
  } = _ref2;
81
91
  return /*#__PURE__*/React.createElement(UnstyledButton, _extends({}, props, {
82
92
  actionType: actionType,
83
93
  disabled: disabled,
94
+ isLoading: isLoading,
84
95
  className: (0, _classify.classify)(_ButtonModule.default.button, {
85
96
  [_ButtonModule.default.primary]: type === 'primary',
86
97
  [_ButtonModule.default.secondary]: type === 'secondary',
@@ -100,31 +111,60 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
100
111
  }), /*#__PURE__*/React.createElement("div", {
101
112
  className: _ButtonModule.default.buttonRow
102
113
  }, !(iconLeftName || iconRightName) ? /*#__PURE__*/React.createElement("div", {
103
- className: _ButtonModule.default.textContainerCenter
104
- }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children)) :
114
+ className: _ButtonModule.default.textContainer
115
+ }, isLoading && /*#__PURE__*/React.createElement("div", {
116
+ className: _ButtonModule.default.loader
117
+ }, /*#__PURE__*/React.createElement(_CircularLoader.CircularLoader, {
118
+ size: size,
119
+ colorToken: disabled ? 'colorTextDisabled' : ButtonTypeToLoaderColorMap[type]
120
+ })), /*#__PURE__*/React.createElement(_Truncate.Truncate, {
121
+ className: (0, _classify.classify)({
122
+ [_ButtonModule.default.hidden]: isLoading
123
+ })
124
+ }, children)) :
105
125
  // has icon, but no child
106
- children == null ? /*#__PURE__*/React.createElement(_Icon.Icon, {
126
+ children == null ? /*#__PURE__*/React.createElement(React.Fragment, null, isLoading && /*#__PURE__*/React.createElement("div", {
127
+ className: _ButtonModule.default.loader
128
+ }, /*#__PURE__*/React.createElement(_CircularLoader.CircularLoader, {
129
+ size: size,
130
+ colorToken: disabled ? 'colorTextDisabled' : ButtonTypeToLoaderColorMap[type]
131
+ })), /*#__PURE__*/React.createElement(_Icon.Icon, {
107
132
  name: iconLeftName || iconRightName,
108
133
  color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
109
134
  size: size === 'medium' ? 'medium' : 'small',
110
135
  type: iconLeftName ? iconLeftType : iconRightType,
111
- className: classNames?.icon
112
- }) :
136
+ className: (0, _classify.classify)({
137
+ [_ButtonModule.default.hidden]: isLoading
138
+ }, classNames?.icon)
139
+ })) :
113
140
  // has icon _and_ child
114
141
  (iconLeftName || iconRightName) && /*#__PURE__*/React.createElement(React.Fragment, null, iconLeftName && /*#__PURE__*/React.createElement(_Icon.Icon, {
115
142
  name: iconLeftName,
116
143
  color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
117
144
  size: size === 'medium' ? 'medium' : 'small',
118
145
  type: iconLeftType,
119
- className: classNames?.icon
146
+ className: (0, _classify.classify)({
147
+ [_ButtonModule.default.hidden]: isLoading
148
+ }, classNames?.icon)
120
149
  }), /*#__PURE__*/React.createElement("div", {
121
- className: _ButtonModule.default.textContainerLeft
122
- }, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children)), iconRightName && /*#__PURE__*/React.createElement(_Icon.Icon, {
150
+ className: _ButtonModule.default.textContainer
151
+ }, isLoading && /*#__PURE__*/React.createElement("div", {
152
+ className: _ButtonModule.default.loader
153
+ }, /*#__PURE__*/React.createElement(_CircularLoader.CircularLoader, {
154
+ size: size,
155
+ colorToken: disabled ? 'colorTextDisabled' : ButtonTypeToLoaderColorMap[type]
156
+ })), /*#__PURE__*/React.createElement(_Truncate.Truncate, {
157
+ className: (0, _classify.classify)({
158
+ [_ButtonModule.default.hidden]: isLoading
159
+ })
160
+ }, children)), iconRightName && /*#__PURE__*/React.createElement(_Icon.Icon, {
123
161
  name: iconRightName,
124
162
  color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
125
163
  size: size === 'medium' ? 'medium' : 'small',
126
164
  type: iconRightType,
127
- className: classNames?.icon
165
+ className: (0, _classify.classify)({
166
+ [_ButtonModule.default.hidden]: isLoading
167
+ }, classNames?.icon)
128
168
  }))));
129
169
  });
130
170
  exports.Button = Button;