@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.
- package/.cspell/custom-words.txt +3 -0
- package/.flowconfig +1 -1
- package/CHANGELOG.md +19 -0
- package/CONTRIBUTING.md +52 -6
- package/README.md +144 -8
- package/gulpfile.js +1 -0
- package/lib/components/AvatarGroup/AvatarGroup.js +4 -3
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +119 -110
- package/lib/components/Badge/Badge.js +4 -3
- package/lib/components/Badge/Badge.js.flow +21 -21
- package/lib/components/Badge/index.js +11 -7
- package/lib/components/Badge/index.js.flow +1 -2
- package/lib/components/Banner/Banner.js +3 -2
- package/lib/components/Banner/Banner.js.flow +42 -35
- package/lib/components/Button/Button.js +50 -10
- package/lib/components/Button/Button.js.flow +87 -23
- package/lib/components/Button/Button.module.css +14 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +3 -2
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +48 -38
- package/lib/components/ButtonTabs/ButtonTabs.js +3 -2
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +50 -41
- package/lib/components/Card/Card.js +16 -7
- package/lib/components/Card/Card.js.flow +73 -55
- package/lib/components/Chip/Chip.js +3 -2
- package/lib/components/Chip/Chip.js.flow +66 -59
- package/lib/components/CircularLoader/CircularLoader.js +9 -4
- package/lib/components/CircularLoader/CircularLoader.js.flow +38 -24
- package/lib/components/CollapsibleCard/CollapsibleCard.js +4 -3
- package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +68 -59
- package/lib/components/Dropdown/Dropdown.js +4 -3
- package/lib/components/Dropdown/Dropdown.js.flow +83 -74
- package/lib/components/EmptyState/EmptyState.js +4 -3
- package/lib/components/EmptyState/EmptyState.js.flow +53 -44
- package/lib/components/ErrorMessage/ErrorMessage.js +4 -3
- package/lib/components/ErrorMessage/ErrorMessage.js.flow +58 -49
- package/lib/components/InContextAlert/InContextAlert.js +4 -3
- package/lib/components/InContextAlert/InContextAlert.js.flow +79 -73
- package/lib/components/InlineDropdown/InlineDropdown.js +4 -3
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +94 -85
- package/lib/components/LinearLoader/LinearLoader.js +4 -3
- package/lib/components/LinearLoader/LinearLoader.js.flow +20 -18
- package/lib/components/Link/Link.js +8 -1
- package/lib/components/Link/Link.js.flow +44 -36
- package/lib/components/Notification/Notification.js +8 -6
- package/lib/components/Notification/Notification.js.flow +96 -84
- package/lib/components/OptionButton/OptionButton.js +7 -4
- package/lib/components/OptionButton/OptionButton.js.flow +69 -59
- package/lib/components/PageTitle/PageTitle.js +4 -3
- package/lib/components/PageTitle/PageTitle.js.flow +46 -44
- package/lib/components/Pagination/PaginationItem.js +2 -2
- package/lib/components/Pagination/PaginationItem.js.flow +2 -2
- package/lib/components/SearchInput/SearchInput.js +3 -2
- package/lib/components/SearchInput/SearchInput.js.flow +59 -50
- package/lib/components/SearchInput/SearchInput.module.css +1 -1
- package/lib/components/SideMenuLink/SideMenuLink.js +4 -3
- package/lib/components/SideMenuLink/SideMenuLink.js.flow +54 -45
- package/lib/components/StatusIndicator/StatusIndicator.js +3 -2
- package/lib/components/StatusIndicator/StatusIndicator.js.flow +32 -23
- package/lib/components/SubMenu/SubMenu.js +4 -3
- package/lib/components/SubMenu/SubMenu.js.flow +41 -38
- package/lib/components/Table/{Row.js.flow → DefaultRow.js.flow} +1 -1
- package/lib/components/Table/{TableHeader.js → DefaultTableHeader.js} +2 -2
- package/lib/components/Table/{TableHeader.js.flow → DefaultTableHeader.js.flow} +1 -1
- package/lib/components/Table/StaticTable.js +8 -5
- package/lib/components/Table/StaticTable.js.flow +5 -2
- package/lib/components/Table/Table.js +10 -0
- package/lib/components/Table/Table.js.flow +12 -2
- package/lib/components/Table/hooks.js +1 -0
- package/lib/components/Table/hooks.js.flow +1 -0
- package/lib/components/Table/index.js +15 -15
- package/lib/components/Table/index.js.flow +2 -2
- package/lib/components/Tabs/TabList/TabList.js +3 -2
- package/lib/components/Tabs/TabList/TabList.js.flow +127 -117
- package/lib/components/Toggle/index.js +11 -7
- package/lib/components/Toggle/index.js.flow +1 -1
- package/lib/components/Tooltip/Tooltip.js.flow +2 -2
- package/lib/components/index.js +511 -0
- package/lib/components/index.js.flow +48 -0
- package/lib/index.js +60 -0
- package/lib/index.js.flow +7 -0
- package/lib/styles/index.css +15 -0
- package/lib/styles/index.js +104 -0
- package/lib/styles/index.js.flow +12 -0
- package/lib/styles/typography.module.css +0 -1
- package/lib/styles/utils.module.css +26 -0
- package/lib/types/index.js +38 -0
- package/lib/types/index.js.flow +5 -0
- package/lib/utils/index.js +93 -0
- package/lib/utils/index.js.flow +10 -0
- package/package.json +2 -1
- /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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
selectedTab
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
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,
|