@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
@@ -22,123 +22,133 @@ export type TabListProps = {
22
22
  menuWidth?: string,
23
23
  };
24
24
 
25
- export const TabList = ({
26
- classNames,
27
- children,
28
- size,
29
- onSelect,
30
- selectedTab,
31
- menuWidth,
32
- }: TabListProps): React.Node => {
33
- const ref = React.useRef(null);
34
-
35
- const [containerWidth, setContainerWidth] = React.useState(0);
36
-
37
- const childrenWithProps = () => {
38
- const childrenArray = React.Children.toArray(children);
39
- const totalChildCount = childrenArray.length;
40
- let tabListWidth = 0;
41
- const menuOptions = [];
42
-
43
- let nodes: React.Node[] = [];
44
- const tabListNodes: React.Node[] = [];
45
- for (let i = 0; i < totalChildCount; i++) {
46
- const child = childrenArray[i];
47
- const {
48
- width = size100,
49
- tabId,
50
- label,
51
- disabled,
52
- iconName,
53
- iconType,
54
- } = child.props;
55
- const widthInt = parseInt(width);
56
- tabListWidth = tabListWidth + widthInt;
57
-
58
- if (tabListWidth < containerWidth || i === 0) {
59
- const childOnSelect = (params) => {
60
- onSelect && onSelect(params); // call the tab level onSelect
25
+ export const TabList: React$AbstractComponent<TabListProps, HTMLDivElement> =
26
+ React.forwardRef<TabListProps, HTMLDivElement>(
27
+ (
28
+ {
29
+ classNames,
30
+ children,
31
+ size,
32
+ onSelect,
33
+ selectedTab,
34
+ menuWidth,
35
+ }: TabListProps,
36
+ forwardRef,
37
+ ): React.Node => {
38
+ const ref = React.useRef(null);
39
+ React.useImperativeHandle(forwardRef, () => ref.current);
40
+
41
+ const [containerWidth, setContainerWidth] = React.useState(0);
42
+
43
+ const childrenWithProps = () => {
44
+ const childrenArray = React.Children.toArray(children);
45
+ const totalChildCount = childrenArray.length;
46
+ let tabListWidth = 0;
47
+ const menuOptions = [];
48
+
49
+ let nodes: React.Node[] = [];
50
+ const tabListNodes: React.Node[] = [];
51
+ for (let i = 0; i < totalChildCount; i++) {
52
+ const child = childrenArray[i];
53
+ const {
54
+ width = size100,
55
+ tabId,
56
+ label,
57
+ disabled,
58
+ iconName,
59
+ iconType,
60
+ } = child.props;
61
+ const widthInt = parseInt(width);
62
+ tabListWidth = tabListWidth + widthInt;
63
+
64
+ if (tabListWidth < containerWidth || i === 0) {
65
+ const childOnSelect = (params) => {
66
+ onSelect && onSelect(params); // call the tab level onSelect
67
+ };
68
+ tabListNodes.push(
69
+ React.cloneElement(child, {
70
+ size,
71
+ onSelect: childOnSelect,
72
+ selectedTab,
73
+ }),
74
+ );
75
+ } else {
76
+ menuOptions.push({
77
+ key: tabId,
78
+ label,
79
+ disabled,
80
+ iconLeft: iconName,
81
+ iconLeftType: iconType,
82
+ });
83
+ }
84
+ }
85
+
86
+ const menuOnSelect = ({key, label}) => {
87
+ onSelect && onSelect({tabId: key, label});
61
88
  };
62
- tabListNodes.push(
63
- React.cloneElement(child, {
64
- size,
65
- onSelect: childOnSelect,
66
- selectedTab,
67
- }),
68
- );
69
- } else {
70
- menuOptions.push({
71
- key: tabId,
72
- label,
73
- disabled,
74
- iconLeft: iconName,
75
- iconLeftType: iconType,
76
- });
77
- }
78
- }
79
-
80
- const menuOnSelect = ({key, label}) => {
81
- onSelect && onSelect({tabId: key, label});
82
- };
83
- const selectedKeys = [selectedTab?.tabId || ''];
84
-
85
- const isMenuOptionSelected = (() => {
86
- for (let i = 0; i < menuOptions.length; i++) {
87
- if (menuOptions[i].key === selectedTab?.tabId) {
88
- return true;
89
+ const selectedKeys = [selectedTab?.tabId || ''];
90
+
91
+ const isMenuOptionSelected = (() => {
92
+ for (let i = 0; i < menuOptions.length; i++) {
93
+ if (menuOptions[i].key === selectedTab?.tabId) {
94
+ return true;
95
+ }
96
+ }
97
+ return false;
98
+ })();
99
+
100
+ const tabDropDownNode = menuOptions.length ? (
101
+ <TabDropdown
102
+ key={'tabDropdown' + menuOptions.length}
103
+ size={size}
104
+ onOptionSelect={menuOnSelect}
105
+ props={{
106
+ tab: {
107
+ iconName: 'ellipsis',
108
+ tabId: 'tab-dropdown',
109
+ selectedTab: {
110
+ tabId: isMenuOptionSelected ? 'tab-dropdown' : '',
111
+ },
112
+ },
113
+ menu: {
114
+ isFluid: false,
115
+ menuDisabled: false,
116
+ options: menuOptions,
117
+ selectedKeys,
118
+ width: menuWidth,
119
+ },
120
+ }}
121
+ />
122
+ ) : null;
123
+
124
+ nodes = [...tabListNodes, tabDropDownNode];
125
+ return nodes;
126
+ };
127
+
128
+ React.useLayoutEffect(() => {
129
+ if (ref.current && ref.current.offsetWidth) {
130
+ const availableContainerWidth =
131
+ ref.current.offsetWidth -
132
+ (parseInt(size36) + parseInt(spaceMedium));
133
+ setContainerWidth(availableContainerWidth);
89
134
  }
90
- }
91
- return false;
92
- })();
93
-
94
- const tabDropDownNode = menuOptions.length ? (
95
- <TabDropdown
96
- key={'tabDropdown' + menuOptions.length}
97
- size={size}
98
- onOptionSelect={menuOnSelect}
99
- props={{
100
- tab: {
101
- iconName: 'ellipsis',
102
- tabId: 'tab-dropdown',
103
- selectedTab: {tabId: isMenuOptionSelected ? 'tab-dropdown' : ''},
104
- },
105
- menu: {
106
- isFluid: false,
107
- menuDisabled: false,
108
- options: menuOptions,
109
- selectedKeys,
110
- width: menuWidth,
111
- },
112
- }}
113
- />
114
- ) : null;
115
-
116
- nodes = [...tabListNodes, tabDropDownNode];
117
- return nodes;
118
- };
119
-
120
- React.useLayoutEffect(() => {
121
- if (ref.current && ref.current.offsetWidth) {
122
- const availableContainerWidth =
123
- ref.current.offsetWidth - (parseInt(size36) + parseInt(spaceMedium));
124
- setContainerWidth(availableContainerWidth);
125
- }
126
- }, [ref.current]);
127
-
128
- return (
129
- <div
130
- ref={ref}
131
- data-testid="Tabs"
132
- className={classify(
133
- css.tabsContainer,
134
- {
135
- [css.mediumSize]: size === 'medium',
136
- [css.smallSize]: size === 'small',
137
- },
138
- classNames?.wrapper,
139
- )}
140
- >
141
- {containerWidth ? childrenWithProps() : null}
142
- </div>
135
+ }, [ref.current]);
136
+
137
+ return (
138
+ <div
139
+ ref={ref}
140
+ data-testid="Tabs"
141
+ className={classify(
142
+ css.tabsContainer,
143
+ {
144
+ [css.mediumSize]: size === 'medium',
145
+ [css.smallSize]: size === 'small',
146
+ },
147
+ classNames?.wrapper,
148
+ )}
149
+ >
150
+ {containerWidth ? childrenWithProps() : null}
151
+ </div>
152
+ );
153
+ },
143
154
  );
144
- };
@@ -9,6 +9,7 @@ var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
9
9
  var _classify = _interopRequireDefault(require("../../utils/classify"));
10
10
  var _Icon = require("../Icon");
11
11
  var _Text = require("../Text");
12
+ var _typographyModule = _interopRequireDefault(require("../../styles/typography.module.css"));
12
13
  var _ToastModule = _interopRequireDefault(require("./Toast.module.css"));
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  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); }
@@ -22,13 +23,6 @@ const TOAST_SEMANTIC = Object.freeze({
22
23
  primary: 'primary'
23
24
  });
24
25
  exports.TOAST_SEMANTIC = TOAST_SEMANTIC;
25
- const TOAST_TITLE_COLOR = {
26
- success: _Text.TEXT_COLORS.success,
27
- information: _Text.TEXT_COLORS.information,
28
- warning: _Text.TEXT_COLORS.warning,
29
- danger: _Text.TEXT_COLORS.danger,
30
- primary: _Text.TEXT_COLORS.primary
31
- };
32
26
  const ToastIcon = _ref => {
33
27
  let {
34
28
  semantic
@@ -75,10 +69,11 @@ const ToastTitle = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
75
69
  let {
76
70
  children,
77
71
  semantic = '',
72
+ className,
78
73
  ...props
79
74
  } = _ref2;
80
- return /*#__PURE__*/React.createElement(_Text.SubTitleSmall, _extends({
81
- color: TOAST_TITLE_COLOR[semantic]
75
+ return /*#__PURE__*/React.createElement("div", _extends({
76
+ className: (0, _classify.default)(_ToastModule.default.toastTitle, _typographyModule.default[semantic], className)
82
77
  }, props, {
83
78
  ref: ref
84
79
  }), children);
@@ -88,9 +83,12 @@ ToastTitle.displayName = 'ToastTitle';
88
83
  const ToastBody = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
89
84
  let {
90
85
  children,
86
+ className,
91
87
  ...props
92
88
  } = _ref3;
93
- return /*#__PURE__*/React.createElement(_Text.BodyMedium, _extends({}, props, {
89
+ return /*#__PURE__*/React.createElement("div", _extends({
90
+ className: (0, _classify.default)(_ToastModule.default.toastBody, className)
91
+ }, props, {
94
92
  ref: ref
95
93
  }), children);
96
94
  });
@@ -8,16 +8,11 @@ import {
8
8
  useFloating,
9
9
  } from '@floating-ui/react-dom-interactions';
10
10
 
11
- import type {ColorTypes} from '../../types/typography';
12
11
  import classify from '../../utils/classify';
13
12
  import {CloseIcon, Icon} from '../Icon';
14
- import {
15
- BodyMedium,
16
- SubTitleExtraSmall,
17
- SubTitleSmall,
18
- TEXT_COLORS,
19
- } from '../Text';
13
+ import {SubTitleExtraSmall, TEXT_COLORS} from '../Text';
20
14
 
15
+ import typography from '../../styles/typography.module.css';
21
16
  import css from './Toast.module.css';
22
17
 
23
18
 
@@ -31,14 +26,6 @@ export const TOAST_SEMANTIC = Object.freeze({
31
26
  primary: 'primary',
32
27
  });
33
28
 
34
- const TOAST_TITLE_COLOR = {
35
- success: TEXT_COLORS.success,
36
- information: TEXT_COLORS.information,
37
- warning: TEXT_COLORS.warning,
38
- danger: TEXT_COLORS.danger,
39
- primary: TEXT_COLORS.primary,
40
- };
41
-
42
29
  export type ToastSemanticType = $Values<typeof TOAST_SEMANTIC>;
43
30
 
44
31
  export type ToastProps = {
@@ -109,17 +96,23 @@ export type ToastTitleProps = {
109
96
  children?: React.Node,
110
97
  className?: string,
111
98
  semantic?: ToastSemanticType,
112
- color?: ColorTypes,
113
99
  };
114
100
 
115
101
  export const ToastTitle: React$AbstractComponent<
116
102
  ToastTitleProps,
117
- HTMLHeadingElement,
118
- > = React.forwardRef<ToastTitleProps, HTMLHeadingElement>(
119
- ({children, semantic = '', ...props}: ToastTitleProps, ref): React.Node => (
120
- <SubTitleSmall color={TOAST_TITLE_COLOR[semantic]} {...props} ref={ref}>
103
+ HTMLDivElement,
104
+ > = React.forwardRef<ToastTitleProps, HTMLDivElement>(
105
+ (
106
+ {children, semantic = '', className, ...props}: ToastTitleProps,
107
+ ref,
108
+ ): React.Node => (
109
+ <div
110
+ className={classify(css.toastTitle, typography[semantic], className)}
111
+ {...props}
112
+ ref={ref}
113
+ >
121
114
  {children}
122
- </SubTitleSmall>
115
+ </div>
123
116
  ),
124
117
  );
125
118
 
@@ -128,17 +121,16 @@ ToastTitle.displayName = 'ToastTitle';
128
121
  export type ToastBodyProps = {
129
122
  children?: React.Node,
130
123
  className?: string,
131
- color?: ColorTypes,
132
124
  };
133
125
 
134
126
  export const ToastBody: React$AbstractComponent<
135
127
  ToastBodyProps,
136
- HTMLParagraphElement,
137
- > = React.forwardRef<ToastBodyProps, HTMLParagraphElement>(
138
- ({children, ...props}: ToastBodyProps, ref): React.Node => (
139
- <BodyMedium {...props} ref={ref}>
128
+ HTMLDivElement,
129
+ > = React.forwardRef<ToastBodyProps, HTMLDivElement>(
130
+ ({children, className, ...props}: ToastBodyProps, ref): React.Node => (
131
+ <div className={classify(css.toastBody, className)} {...props} ref={ref}>
140
132
  {children}
141
- </BodyMedium>
133
+ </div>
142
134
  ),
143
135
  );
144
136
 
@@ -44,6 +44,10 @@
44
44
  gap: spaceXXSmall;
45
45
  }
46
46
 
47
+ .toastBody {
48
+ composes: bodyMedium from '../../styles/typography.module.css';
49
+ }
50
+
47
51
  .toastFooterActions {
48
52
  display: flex;
49
53
  flex-direction: row;
@@ -54,3 +58,7 @@
54
58
  .closeIcon {
55
59
  margin-left: auto;
56
60
  }
61
+
62
+ .toastTitle {
63
+ composes: subTitleSmall from '../../styles/typography.module.css';
64
+ }
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Toggle = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = _interopRequireDefault(require("../../utils/classify"));
9
- var _Text = require("../Text/Text");
10
9
  var _ToggleModule = _interopRequireDefault(require("./Toggle.module.css"));
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
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); }
13
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; }
14
13
  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 Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
14
+ const Toggle = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
16
15
  let {
17
16
  name = 'toggle',
18
17
  value = '',
@@ -22,9 +21,11 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
22
21
  checked,
23
22
  focused,
24
23
  onChange,
24
+ ariaLabel,
25
25
  ...props
26
26
  } = _ref;
27
27
  const toggleInput = /*#__PURE__*/React.createRef();
28
+ React.useImperativeHandle(forwardRef, () => toggleInput.current);
28
29
  const handleOnChange = () => {
29
30
  if (!disabled) {
30
31
  onChange && onChange({
@@ -33,16 +34,19 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
33
34
  });
34
35
  }
35
36
  };
37
+ const onWrapClickHandler = () => {
38
+ toggleInput.current?.click();
39
+ };
36
40
  React.useEffect(() => {
37
41
  if (toggleInput.current && focused) {
38
42
  toggleInput.current.focus();
39
43
  }
40
44
  }, [focused]);
41
- return /*#__PURE__*/React.createElement("label", {
45
+ return /*#__PURE__*/React.createElement("div", {
42
46
  className: (0, _classify.default)(_ToggleModule.default.container, {
43
47
  [_ToggleModule.default.disabled]: disabled
44
48
  }, classNames?.wrapper),
45
- ref: ref
49
+ onClick: onWrapClickHandler
46
50
  }, /*#__PURE__*/React.createElement("span", {
47
51
  className: _ToggleModule.default.toggleWrap
48
52
  }, /*#__PURE__*/React.createElement("input", _extends({
@@ -52,13 +56,13 @@ const Toggle = /*#__PURE__*/React.forwardRef((_ref, ref) => {
52
56
  checked: checked,
53
57
  onChange: handleOnChange,
54
58
  ref: toggleInput,
55
- disabled: disabled
59
+ disabled: disabled,
60
+ "aria-label": ariaLabel || children
56
61
  }, props)), /*#__PURE__*/React.createElement("span", {
57
62
  className: (0, _classify.default)(_ToggleModule.default.toggle, {
58
63
  [_ToggleModule.default.disabledButton]: disabled
59
64
  })
60
- })), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement(_Text.FormLabelMedium, {
61
- color: "secondary",
65
+ })), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement("div", {
62
66
  className: (0, _classify.default)(_ToggleModule.default.toggleLabel, classNames?.label)
63
67
  }, children));
64
68
  });
@@ -3,7 +3,6 @@
3
3
  import * as React from 'react';
4
4
 
5
5
  import classify from '../../utils/classify';
6
- import {FormLabelMedium} from '../Text/Text';
7
6
 
8
7
  import css from './Toggle.module.css';
9
8
 
@@ -25,10 +24,11 @@ export type ToggleProps = {
25
24
  disabled?: boolean,
26
25
  focused?: boolean,
27
26
  value?: string,
27
+ ariaLabel?: string,
28
28
  };
29
29
 
30
- export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
31
- React.forwardRef<ToggleProps, HTMLLabelElement>(
30
+ export const Toggle: React$AbstractComponent<ToggleProps, HTMLInputElement> =
31
+ React.forwardRef<ToggleProps, HTMLInputElement>(
32
32
  (
33
33
  {
34
34
  name = 'toggle',
@@ -39,11 +39,13 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
39
39
  checked,
40
40
  focused,
41
41
  onChange,
42
+ ariaLabel,
42
43
  ...props
43
44
  }: ToggleProps,
44
- ref,
45
+ forwardRef,
45
46
  ): React.Node => {
46
47
  const toggleInput = React.createRef<HTMLInputElement>();
48
+ React.useImperativeHandle(forwardRef, () => toggleInput.current);
47
49
  const handleOnChange = () => {
48
50
  if (!disabled) {
49
51
  onChange &&
@@ -54,13 +56,17 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
54
56
  }
55
57
  };
56
58
 
59
+ const onWrapClickHandler = () => {
60
+ toggleInput.current?.click();
61
+ };
62
+
57
63
  React.useEffect(() => {
58
64
  if (toggleInput.current && focused) {
59
65
  toggleInput.current.focus();
60
66
  }
61
67
  }, [focused]);
62
68
  return (
63
- <label
69
+ <div
64
70
  className={classify(
65
71
  css.container,
66
72
  {
@@ -68,7 +74,7 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
68
74
  },
69
75
  classNames?.wrapper,
70
76
  )}
71
- ref={ref}
77
+ onClick={onWrapClickHandler}
72
78
  >
73
79
  <span className={css.toggleWrap}>
74
80
  <input
@@ -79,6 +85,7 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
79
85
  onChange={handleOnChange}
80
86
  ref={toggleInput}
81
87
  disabled={disabled}
88
+ aria-label={ariaLabel || children}
82
89
  {...props}
83
90
  />
84
91
  <span
@@ -88,14 +95,11 @@ export const Toggle: React$AbstractComponent<ToggleProps, HTMLLabelElement> =
88
95
  />
89
96
  </span>
90
97
  {React.Children.count(children) > 0 && (
91
- <FormLabelMedium
92
- color="secondary"
93
- className={classify(css.toggleLabel, classNames?.label)}
94
- >
98
+ <div className={classify(css.toggleLabel, classNames?.label)}>
95
99
  {children}
96
- </FormLabelMedium>
100
+ </div>
97
101
  )}
98
- </label>
102
+ </div>
99
103
  );
100
104
  },
101
105
  );
@@ -138,5 +138,7 @@
138
138
  }
139
139
 
140
140
  .toggleLabel {
141
+ composes: formLabelMedium from '../../styles/typography.module.css';
142
+ composes: secondary from '../../styles/typography.module.css';
141
143
  margin-left: spaceNone;
142
144
  }
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Toggle", {
7
- enumerable: true,
8
- get: function () {
9
- return _Toggle.Toggle;
10
- }
11
- });
12
- var _Toggle = require("./Toggle");
6
+ var _Toggle = require("./Toggle");
7
+ Object.keys(_Toggle).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Toggle[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Toggle[key];
14
+ }
15
+ });
16
+ });
@@ -1,2 +1,2 @@
1
1
  //@flow strict
2
- export {Toggle} from './Toggle';
2
+ export * from './Toggle';
@@ -36,7 +36,7 @@ import {Truncate} from '../Truncate';
36
36
 
37
37
  import css from './Tooltip.module.css';
38
38
 
39
-
39
+ /* eslint-disable flowtype/no-weak-types */
40
40
  type ClassNames = $ReadOnly<{tooltip?: string, title?: string, body?: string}>;
41
41
 
42
42
  export const DELAY_MOTION_DURATION_TYPES = Object.freeze({
@@ -70,7 +70,7 @@ export type TooltipProps = {
70
70
  bodyMaxLines?: number,
71
71
  titleMaxLines?: number,
72
72
  delayMotionDuration?: DelayMotionDurationType,
73
- // TODO(Nishant): Decide on a type to use
73
+ // TODO(Nishant): Decide on a type to use here
74
74
  // $FlowFixMe
75
75
  children: any,
76
76
  elevation?: string,