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

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 (91) hide show
  1. package/.cspell/custom-words.txt +3 -0
  2. package/.flowconfig +1 -1
  3. package/CHANGELOG.md +19 -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/SearchInput/SearchInput.module.css +1 -1
  55. package/lib/components/SideMenuLink/SideMenuLink.js +4 -3
  56. package/lib/components/SideMenuLink/SideMenuLink.js.flow +54 -45
  57. package/lib/components/StatusIndicator/StatusIndicator.js +3 -2
  58. package/lib/components/StatusIndicator/StatusIndicator.js.flow +32 -23
  59. package/lib/components/SubMenu/SubMenu.js +4 -3
  60. package/lib/components/SubMenu/SubMenu.js.flow +41 -38
  61. package/lib/components/Table/{Row.js.flow → DefaultRow.js.flow} +1 -1
  62. package/lib/components/Table/{TableHeader.js → DefaultTableHeader.js} +2 -2
  63. package/lib/components/Table/{TableHeader.js.flow → DefaultTableHeader.js.flow} +1 -1
  64. package/lib/components/Table/StaticTable.js +8 -5
  65. package/lib/components/Table/StaticTable.js.flow +5 -2
  66. package/lib/components/Table/Table.js +10 -0
  67. package/lib/components/Table/Table.js.flow +12 -2
  68. package/lib/components/Table/hooks.js +1 -0
  69. package/lib/components/Table/hooks.js.flow +1 -0
  70. package/lib/components/Table/index.js +15 -15
  71. package/lib/components/Table/index.js.flow +2 -2
  72. package/lib/components/Tabs/TabList/TabList.js +3 -2
  73. package/lib/components/Tabs/TabList/TabList.js.flow +127 -117
  74. package/lib/components/Toggle/index.js +11 -7
  75. package/lib/components/Toggle/index.js.flow +1 -1
  76. package/lib/components/Tooltip/Tooltip.js.flow +2 -2
  77. package/lib/components/index.js +511 -0
  78. package/lib/components/index.js.flow +48 -0
  79. package/lib/index.js +60 -0
  80. package/lib/index.js.flow +7 -0
  81. package/lib/styles/index.css +15 -0
  82. package/lib/styles/index.js +104 -0
  83. package/lib/styles/index.js.flow +12 -0
  84. package/lib/styles/typography.module.css +0 -1
  85. package/lib/styles/utils.module.css +26 -0
  86. package/lib/types/index.js +38 -0
  87. package/lib/types/index.js.flow +5 -0
  88. package/lib/utils/index.js +93 -0
  89. package/lib/utils/index.js.flow +10 -0
  90. package/package.json +2 -1
  91. /package/lib/components/Table/{Row.js → DefaultRow.js} +0 -0
@@ -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
- };
@@ -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,