@spaced-out/ui-design-system 0.0.21 → 0.0.23-beta.0
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/CHANGELOG.md +21 -0
- package/design-tokens/color/app-color.json +7 -0
- package/design-tokens/size/base-size.json +6 -0
- package/lib/components/Button/Button.js +9 -5
- package/lib/components/Button/Button.js.flow +11 -3
- package/lib/components/Button/Button.module.css +1 -1
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +48 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +67 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.module.css +75 -0
- package/lib/components/ButtonTabs/ButtonTab/index.js +16 -0
- package/lib/components/ButtonTabs/ButtonTab/index.js.flow +3 -0
- package/lib/components/ButtonTabs/ButtonTabs.js +47 -0
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +62 -0
- package/lib/components/ButtonTabs/ButtonTabs.module.css +27 -0
- package/lib/components/ButtonTabs/index.js +27 -0
- package/lib/components/ButtonTabs/index.js.flow +4 -0
- package/lib/components/Chip/Chip.js +11 -3
- package/lib/components/Chip/Chip.js.flow +12 -2
- package/lib/components/Chip/Chip.module.css +31 -0
- package/lib/components/Icon/Icon.js.flow +1 -1
- package/lib/components/SideMenuLink/SideMenuLink.module.css +1 -0
- package/lib/components/StatusIndicator/StatusIndicator.js +36 -0
- package/lib/components/StatusIndicator/StatusIndicator.js.flow +47 -0
- package/lib/components/StatusIndicator/StatusIndicator.module.css +37 -0
- package/lib/components/StatusIndicator/index.js +16 -0
- package/lib/components/StatusIndicator/index.js.flow +3 -0
- package/lib/components/SubMenu/SubMenu.js +168 -0
- package/lib/components/SubMenu/SubMenu.js.flow +243 -0
- package/lib/components/SubMenu/SubMenu.module.css +119 -0
- package/lib/components/SubMenu/index.js +42 -0
- package/lib/components/SubMenu/index.js.flow +11 -0
- package/lib/components/Tabs/Tab/Tab.js +2 -2
- package/lib/components/Tabs/Tab/Tab.js.flow +24 -19
- package/lib/components/Tabs/Tab/Tab.module.css +5 -1
- package/lib/styles/variables/_color.css +2 -0
- package/lib/styles/variables/_color.js +3 -1
- package/lib/styles/variables/_color.js.flow +2 -0
- package/lib/styles/variables/_size.css +4 -0
- package/lib/styles/variables/_size.js +6 -2
- package/lib/styles/variables/_size.js.flow +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.23-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.0.22...v0.0.23-beta.0) (2023-02-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* [GDS-118] sub menu ([#61](https://github.com/spaced-out/ui-design-system/issues/61)) ([7e32aae](https://github.com/spaced-out/ui-design-system/commit/7e32aaebb5427188e8e3f35f5fcd7066557be579))
|
|
11
|
+
* status indicator component ([7f6b0bd](https://github.com/spaced-out/ui-design-system/commit/7f6b0bdcb0c5506f9f5c4c3fcc50206073f4eabe))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* chip states and chip truncate text fixes ([16573d2](https://github.com/spaced-out/ui-design-system/commit/16573d24ff201335c33a888aff3d7cf3dd36a133))
|
|
17
|
+
* tab onhover and icon only center ([#64](https://github.com/spaced-out/ui-design-system/issues/64)) ([148606a](https://github.com/spaced-out/ui-design-system/commit/148606af18fa7808612236bd0cb34a61908a2f49))
|
|
18
|
+
|
|
19
|
+
### [0.0.22](https://github.com/spaced-out/ui-design-system/compare/v0.0.21...v0.0.22) (2023-02-09)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* button tabs component and button text fixes ([#62](https://github.com/spaced-out/ui-design-system/issues/62)) ([bd44a54](https://github.com/spaced-out/ui-design-system/commit/bd44a547e7ba0bcb9cf59be212191dd6353f79e0))
|
|
25
|
+
|
|
5
26
|
### [0.0.21](https://github.com/spaced-out/ui-design-system/compare/v0.0.20...v0.0.21) (2023-02-08)
|
|
6
27
|
|
|
7
28
|
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
"240": {
|
|
70
70
|
"value": "240px"
|
|
71
71
|
},
|
|
72
|
+
"260": {
|
|
73
|
+
"value": "260px"
|
|
74
|
+
},
|
|
72
75
|
"276": {
|
|
73
76
|
"value": "276px"
|
|
74
77
|
},
|
|
@@ -98,6 +101,9 @@
|
|
|
98
101
|
},
|
|
99
102
|
"fluid": {
|
|
100
103
|
"value": "100%"
|
|
104
|
+
},
|
|
105
|
+
"fullViewportHeight": {
|
|
106
|
+
"value": "100vh"
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
}
|
|
@@ -7,6 +7,7 @@ exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = exports.BUTTON_
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = require("../../utils/classify");
|
|
9
9
|
var _Icon = require("../Icon");
|
|
10
|
+
var _Truncate = require("../Truncate");
|
|
10
11
|
var _ButtonModule = _interopRequireDefault(require("./Button.module.css"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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); }
|
|
@@ -97,27 +98,30 @@ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
97
98
|
className: _ButtonModule.default.buttonRow
|
|
98
99
|
}, !(iconLeftName || iconRightName) ? /*#__PURE__*/React.createElement("div", {
|
|
99
100
|
className: _ButtonModule.default.textContainerCenter
|
|
100
|
-
}, children) :
|
|
101
|
+
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children)) :
|
|
101
102
|
// has icon, but no child
|
|
102
103
|
children == null ? /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
103
104
|
name: iconLeftName || iconRightName,
|
|
104
105
|
color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
|
|
105
106
|
size: size === 'medium' ? 'medium' : 'small',
|
|
106
|
-
type: iconLeftType || iconRightType
|
|
107
|
+
type: iconLeftType || iconRightType,
|
|
108
|
+
className: classNames?.icon
|
|
107
109
|
}) :
|
|
108
110
|
// has icon _and_ child
|
|
109
111
|
(iconLeftName || iconRightName) && /*#__PURE__*/React.createElement(React.Fragment, null, iconLeftName && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
110
112
|
name: iconLeftName,
|
|
111
113
|
color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
|
|
112
114
|
size: size === 'medium' ? 'medium' : 'small',
|
|
113
|
-
type: iconLeftType
|
|
115
|
+
type: iconLeftType,
|
|
116
|
+
className: classNames?.icon
|
|
114
117
|
}), /*#__PURE__*/React.createElement("div", {
|
|
115
118
|
className: _ButtonModule.default.textContainerLeft
|
|
116
|
-
}, children), iconRightName && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
119
|
+
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children)), iconRightName && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
117
120
|
name: iconRightName,
|
|
118
121
|
color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
|
|
119
122
|
size: size === 'medium' ? 'medium' : 'small',
|
|
120
|
-
type: iconRightType
|
|
123
|
+
type: iconRightType,
|
|
124
|
+
className: classNames?.icon
|
|
121
125
|
}))));
|
|
122
126
|
});
|
|
123
127
|
exports.Button = Button;
|
|
@@ -5,11 +5,12 @@ import * as React from 'react';
|
|
|
5
5
|
import {classify} from '../../utils/classify';
|
|
6
6
|
import type {IconType} from '../Icon';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {Truncate} from '../Truncate';
|
|
8
9
|
|
|
9
10
|
import css from './Button.module.css';
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
13
|
+
type ClassNames = $ReadOnly<{wrapper?: string, icon?: string}>;
|
|
13
14
|
|
|
14
15
|
export const BUTTON_TYPES = Object.freeze({
|
|
15
16
|
primary: 'primary',
|
|
@@ -143,7 +144,9 @@ export const Button: React$AbstractComponent<ButtonProps, HTMLButtonElement> =
|
|
|
143
144
|
<div className={css.buttonRow}>
|
|
144
145
|
{/* Has no icon, only child */}
|
|
145
146
|
{!(iconLeftName || iconRightName) ? (
|
|
146
|
-
<div className={css.textContainerCenter}>
|
|
147
|
+
<div className={css.textContainerCenter}>
|
|
148
|
+
<Truncate>{children}</Truncate>
|
|
149
|
+
</div>
|
|
147
150
|
) : // has icon, but no child
|
|
148
151
|
children == null ? (
|
|
149
152
|
<Icon
|
|
@@ -151,6 +154,7 @@ export const Button: React$AbstractComponent<ButtonProps, HTMLButtonElement> =
|
|
|
151
154
|
color={disabled ? 'disabled' : ButtonTypeToIconColorMap[type]}
|
|
152
155
|
size={size === 'medium' ? 'medium' : 'small'}
|
|
153
156
|
type={iconLeftType || iconRightType}
|
|
157
|
+
className={classNames?.icon}
|
|
154
158
|
/>
|
|
155
159
|
) : (
|
|
156
160
|
// has icon _and_ child
|
|
@@ -164,9 +168,12 @@ export const Button: React$AbstractComponent<ButtonProps, HTMLButtonElement> =
|
|
|
164
168
|
}
|
|
165
169
|
size={size === 'medium' ? 'medium' : 'small'}
|
|
166
170
|
type={iconLeftType}
|
|
171
|
+
className={classNames?.icon}
|
|
167
172
|
/>
|
|
168
173
|
)}
|
|
169
|
-
<div className={css.textContainerLeft}>
|
|
174
|
+
<div className={css.textContainerLeft}>
|
|
175
|
+
<Truncate>{children}</Truncate>
|
|
176
|
+
</div>
|
|
170
177
|
{iconRightName && (
|
|
171
178
|
<Icon
|
|
172
179
|
name={iconRightName}
|
|
@@ -175,6 +182,7 @@ export const Button: React$AbstractComponent<ButtonProps, HTMLButtonElement> =
|
|
|
175
182
|
}
|
|
176
183
|
size={size === 'medium' ? 'medium' : 'small'}
|
|
177
184
|
type={iconRightType}
|
|
185
|
+
className={classNames?.icon}
|
|
178
186
|
/>
|
|
179
187
|
)}
|
|
180
188
|
</>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ButtonTab = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../../utils/classify"));
|
|
9
|
+
var _Button = require("../../Button");
|
|
10
|
+
var _ButtonTabModule = _interopRequireDefault(require("./ButtonTab.module.css"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
+
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
|
+
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 ButtonTab = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
classNames,
|
|
18
|
+
children,
|
|
19
|
+
iconName,
|
|
20
|
+
iconType = 'regular',
|
|
21
|
+
size,
|
|
22
|
+
onButtonTabSelect,
|
|
23
|
+
id,
|
|
24
|
+
selectedButtonTabId,
|
|
25
|
+
disabled,
|
|
26
|
+
...props
|
|
27
|
+
} = _ref;
|
|
28
|
+
return /*#__PURE__*/React.createElement(_Button.Button, _extends({}, props, {
|
|
29
|
+
disabled: disabled,
|
|
30
|
+
size: size,
|
|
31
|
+
type: id === selectedButtonTabId ? 'tertiary' : 'ghost',
|
|
32
|
+
classNames: {
|
|
33
|
+
wrapper: (0, _classify.default)(_ButtonTabModule.default.buttonTabWrapper, {
|
|
34
|
+
[_ButtonTabModule.default.mediumButtonTab]: size === 'medium',
|
|
35
|
+
[_ButtonTabModule.default.smallButtonTab]: size === 'small',
|
|
36
|
+
[_ButtonTabModule.default.onlyIcon]: iconName && !children,
|
|
37
|
+
[_ButtonTabModule.default.isSelected]: id === selectedButtonTabId,
|
|
38
|
+
[_ButtonTabModule.default.isUnSelected]: id !== selectedButtonTabId,
|
|
39
|
+
[_ButtonTabModule.default.disabled]: disabled
|
|
40
|
+
}, classNames?.wrapper),
|
|
41
|
+
icon: _ButtonTabModule.default.icon
|
|
42
|
+
},
|
|
43
|
+
iconLeftName: iconName,
|
|
44
|
+
iconLeftType: iconType,
|
|
45
|
+
onClick: e => onButtonTabSelect && onButtonTabSelect(id, e)
|
|
46
|
+
}), children);
|
|
47
|
+
};
|
|
48
|
+
exports.ButtonTab = ButtonTab;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../../utils/classify';
|
|
6
|
+
import {Button} from '../../Button';
|
|
7
|
+
import type {IconType} from '../../Icon';
|
|
8
|
+
|
|
9
|
+
import css from './ButtonTab.module.css';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
13
|
+
|
|
14
|
+
export type ButtonTabProps = {
|
|
15
|
+
classNames?: ClassNames,
|
|
16
|
+
children?: React.Node,
|
|
17
|
+
disabled?: boolean,
|
|
18
|
+
onButtonTabSelect?: ?(id: string, e?: SyntheticEvent<HTMLElement>) => mixed,
|
|
19
|
+
iconName?: string,
|
|
20
|
+
iconType?: IconType,
|
|
21
|
+
size?: 'medium' | 'small',
|
|
22
|
+
isFluid?: boolean,
|
|
23
|
+
ariaLabel?: string,
|
|
24
|
+
id: string,
|
|
25
|
+
selectedButtonTabId?: string,
|
|
26
|
+
...
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const ButtonTab = ({
|
|
30
|
+
classNames,
|
|
31
|
+
children,
|
|
32
|
+
iconName,
|
|
33
|
+
iconType = 'regular',
|
|
34
|
+
size,
|
|
35
|
+
onButtonTabSelect,
|
|
36
|
+
id,
|
|
37
|
+
selectedButtonTabId,
|
|
38
|
+
disabled,
|
|
39
|
+
...props
|
|
40
|
+
}: ButtonTabProps): React.Node => (
|
|
41
|
+
<Button
|
|
42
|
+
{...props}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
size={size}
|
|
45
|
+
type={id === selectedButtonTabId ? 'tertiary' : 'ghost'}
|
|
46
|
+
classNames={{
|
|
47
|
+
wrapper: classify(
|
|
48
|
+
css.buttonTabWrapper,
|
|
49
|
+
{
|
|
50
|
+
[css.mediumButtonTab]: size === 'medium',
|
|
51
|
+
[css.smallButtonTab]: size === 'small',
|
|
52
|
+
[css.onlyIcon]: iconName && !children,
|
|
53
|
+
[css.isSelected]: id === selectedButtonTabId,
|
|
54
|
+
[css.isUnSelected]: id !== selectedButtonTabId,
|
|
55
|
+
[css.disabled]: disabled,
|
|
56
|
+
},
|
|
57
|
+
classNames?.wrapper,
|
|
58
|
+
),
|
|
59
|
+
icon: css.icon,
|
|
60
|
+
}}
|
|
61
|
+
iconLeftName={iconName}
|
|
62
|
+
iconLeftType={iconType}
|
|
63
|
+
onClick={(e) => onButtonTabSelect && onButtonTabSelect(id, e)}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</Button>
|
|
67
|
+
);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@value (colorTextDisabled, colorTextPrimary, colorTextSecondary, colorBackgroundTertiary, colorButtonFillTertiaryEnabled) from '../../../styles/variables/_color.css';
|
|
2
|
+
@value (size38, size30) from '../../../styles/variables/_size.css';
|
|
3
|
+
@value (spaceSmall) from '../../../styles/variables/_space.css';
|
|
4
|
+
@value (borderWidthPrimary) from '../../../styles/variables/_border.css';
|
|
5
|
+
|
|
6
|
+
button.buttonTabWrapper {
|
|
7
|
+
padding-left: spaceSmall;
|
|
8
|
+
padding-right: spaceSmall;
|
|
9
|
+
height: size38;
|
|
10
|
+
color: colorTextSecondary;
|
|
11
|
+
min-width: initial;
|
|
12
|
+
text-align: left;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.buttonTabWrapper .icon {
|
|
16
|
+
color: colorTextSecondary;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
button.buttonTabWrapper:hover {
|
|
20
|
+
color: colorTextPrimary;
|
|
21
|
+
background-color: initial;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
button.buttonTabWrapper:hover .icon {
|
|
25
|
+
color: colorTextPrimary;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.buttonTabWrapper.mediumButtonTab {
|
|
29
|
+
height: size38;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.buttonTabWrapper.smallButtonTab {
|
|
33
|
+
height: size30;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.onlyIcon {
|
|
37
|
+
color: colorTextSecondary;
|
|
38
|
+
padding-left: initial;
|
|
39
|
+
padding-right: initial;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.mediumButtonTab.onlyIcon {
|
|
43
|
+
max-width: size38;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.smallButtonTab.onlyIcon {
|
|
47
|
+
max-width: size30;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.buttonTabWrapper.isSelected {
|
|
51
|
+
background-color: colorBackgroundTertiary;
|
|
52
|
+
color: colorTextPrimary;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.buttonTabWrapper.isSelected:hover {
|
|
56
|
+
background-color: colorBackgroundTertiary;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.buttonTabWrapper.isSelected .icon {
|
|
60
|
+
color: colorTextPrimary;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.buttonTabWrapper.disabled {
|
|
64
|
+
color: colorTextDisabled;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.buttonTabWrapper.disabled .icon {
|
|
68
|
+
color: colorTextDisabled;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.buttonTabWrapper.isUnSelected {
|
|
72
|
+
padding-left: spaceSmall;
|
|
73
|
+
padding-right: spaceSmall;
|
|
74
|
+
border: borderWidthPrimary solid colorButtonFillTertiaryEnabled;
|
|
75
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ButtonTab = require("./ButtonTab");
|
|
7
|
+
Object.keys(_ButtonTab).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ButtonTab[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ButtonTab[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ButtonTabs = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
+
var _ButtonTabsModule = _interopRequireDefault(require("./ButtonTabs.module.css"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
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; }
|
|
13
|
+
|
|
14
|
+
const ButtonTabs = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
classNames,
|
|
17
|
+
children,
|
|
18
|
+
isFluid,
|
|
19
|
+
size = 'medium',
|
|
20
|
+
disabled,
|
|
21
|
+
selectedButtonTabId,
|
|
22
|
+
onButtonTabSelect
|
|
23
|
+
} = _ref;
|
|
24
|
+
const childrenWithProps = React.Children.map(children, child => {
|
|
25
|
+
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
26
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
27
|
+
...child.props,
|
|
28
|
+
isFluid,
|
|
29
|
+
size,
|
|
30
|
+
disabled,
|
|
31
|
+
selectedButtonTabId,
|
|
32
|
+
onButtonTabSelect
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return child;
|
|
36
|
+
});
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
"data-testid": "ButtonTabs",
|
|
39
|
+
className: (0, _classify.default)(_ButtonTabsModule.default.buttonTabsWrapper, {
|
|
40
|
+
[_ButtonTabsModule.default.medium]: size === 'medium',
|
|
41
|
+
[_ButtonTabsModule.default.small]: size === 'small',
|
|
42
|
+
[_ButtonTabsModule.default.isFluid]: isFluid,
|
|
43
|
+
[_ButtonTabsModule.default.disabled]: disabled
|
|
44
|
+
}, classNames?.wrapper)
|
|
45
|
+
}, childrenWithProps);
|
|
46
|
+
};
|
|
47
|
+
exports.ButtonTabs = ButtonTabs;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../utils/classify';
|
|
6
|
+
|
|
7
|
+
import css from './ButtonTabs.module.css';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
11
|
+
|
|
12
|
+
export type ButtonTabsProps = {
|
|
13
|
+
classNames?: ClassNames,
|
|
14
|
+
children: React.Node,
|
|
15
|
+
isFluid?: boolean,
|
|
16
|
+
size?: 'medium' | 'small',
|
|
17
|
+
disabled?: boolean,
|
|
18
|
+
selectedButtonTabId?: string,
|
|
19
|
+
onButtonTabSelect?: ?(id: string, e?: SyntheticEvent<HTMLElement>) => mixed,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const ButtonTabs = ({
|
|
23
|
+
classNames,
|
|
24
|
+
children,
|
|
25
|
+
isFluid,
|
|
26
|
+
size = 'medium',
|
|
27
|
+
disabled,
|
|
28
|
+
selectedButtonTabId,
|
|
29
|
+
onButtonTabSelect,
|
|
30
|
+
}: ButtonTabsProps): React.Node => {
|
|
31
|
+
const childrenWithProps = React.Children.map(children, (child) => {
|
|
32
|
+
if (React.isValidElement(child)) {
|
|
33
|
+
return React.cloneElement(child, {
|
|
34
|
+
...child.props,
|
|
35
|
+
isFluid,
|
|
36
|
+
size,
|
|
37
|
+
disabled,
|
|
38
|
+
selectedButtonTabId,
|
|
39
|
+
onButtonTabSelect,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return child;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
data-testid="ButtonTabs"
|
|
48
|
+
className={classify(
|
|
49
|
+
css.buttonTabsWrapper,
|
|
50
|
+
{
|
|
51
|
+
[css.medium]: size === 'medium',
|
|
52
|
+
[css.small]: size === 'small',
|
|
53
|
+
[css.isFluid]: isFluid,
|
|
54
|
+
[css.disabled]: disabled,
|
|
55
|
+
},
|
|
56
|
+
classNames?.wrapper,
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
{childrenWithProps}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@value (colorBackgroundSecondary) from '../../styles/variables/_color.css';
|
|
2
|
+
@value (size42, size34, sizeFluid) from '../../styles/variables/_size.css';
|
|
3
|
+
@value (spaceXXSmall) from '../../styles/variables/_space.css';
|
|
4
|
+
@value (borderRadiusMedium) from '../../styles/variables/_border.css';
|
|
5
|
+
|
|
6
|
+
.buttonTabsWrapper {
|
|
7
|
+
display: flex;
|
|
8
|
+
gap: spaceXXSmall;
|
|
9
|
+
background-color: colorBackgroundSecondary;
|
|
10
|
+
align-items: center;
|
|
11
|
+
padding-left: calc(spaceXXSmall / 2);
|
|
12
|
+
padding-right: calc(spaceXXSmall / 2);
|
|
13
|
+
width: fit-content;
|
|
14
|
+
border-radius: borderRadiusMedium;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.buttonTabsWrapper.medium {
|
|
18
|
+
height: size42;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.buttonTabsWrapper.small {
|
|
22
|
+
height: size34;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.buttonTabsWrapper.isFluid {
|
|
26
|
+
width: sizeFluid;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ButtonTab = require("./ButtonTab");
|
|
7
|
+
Object.keys(_ButtonTab).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ButtonTab[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ButtonTab[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _ButtonTabs = require("./ButtonTabs");
|
|
18
|
+
Object.keys(_ButtonTabs).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _ButtonTabs[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _ButtonTabs[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -7,6 +7,7 @@ exports.Chip = exports.CHIP_SEMANTIC = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classify = require("../../utils/classify");
|
|
9
9
|
var _Icon = require("../Icon");
|
|
10
|
+
var _Truncate = require("../Truncate");
|
|
10
11
|
var _ChipModule = _interopRequireDefault(require("./Chip.module.css"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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); }
|
|
@@ -31,6 +32,7 @@ const Chip = _ref => {
|
|
|
31
32
|
iconType = 'regular',
|
|
32
33
|
dismissable = false,
|
|
33
34
|
onDismiss = () => null,
|
|
35
|
+
onClick,
|
|
34
36
|
disabled
|
|
35
37
|
} = _ref;
|
|
36
38
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -47,18 +49,24 @@ const Chip = _ref => {
|
|
|
47
49
|
[_ChipModule.default.dismissable]: dismissable,
|
|
48
50
|
[_ChipModule.default.withIcon]: !!iconName && size !== 'small',
|
|
49
51
|
[_ChipModule.default.disabled]: disabled
|
|
50
|
-
}, classNames?.wrapper)
|
|
52
|
+
}, classNames?.wrapper),
|
|
53
|
+
onClick: onClick
|
|
51
54
|
}, iconName && size !== 'small' && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
52
55
|
className: _ChipModule.default.chipIcon,
|
|
53
56
|
name: iconName,
|
|
54
57
|
type: iconType,
|
|
55
58
|
size: "small"
|
|
56
|
-
}), children, dismissable && size !== 'small' && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
59
|
+
}), /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children), dismissable && size !== 'small' && /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
57
60
|
className: _ChipModule.default.dismissIcon,
|
|
58
61
|
name: "xmark",
|
|
59
62
|
type: iconType,
|
|
60
63
|
size: "small",
|
|
61
|
-
onClick: event =>
|
|
64
|
+
onClick: event => {
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
if (!disabled && onDismiss) {
|
|
67
|
+
onDismiss(event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
}));
|
|
63
71
|
};
|
|
64
72
|
exports.Chip = Chip;
|
|
@@ -5,6 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import {classify} from '../../utils/classify';
|
|
6
6
|
import type {IconType} from '../Icon';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {Truncate} from '../Truncate';
|
|
8
9
|
|
|
9
10
|
import css from './Chip.module.css';
|
|
10
11
|
|
|
@@ -27,6 +28,7 @@ export type BaseChipProps = {
|
|
|
27
28
|
semantic?: ChipSemanticType,
|
|
28
29
|
children: React.Node,
|
|
29
30
|
disabled?: boolean,
|
|
31
|
+
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type MediumChipProps = {
|
|
@@ -53,6 +55,7 @@ export const Chip = ({
|
|
|
53
55
|
iconType = 'regular',
|
|
54
56
|
dismissable = false,
|
|
55
57
|
onDismiss = () => null,
|
|
58
|
+
onClick,
|
|
56
59
|
disabled,
|
|
57
60
|
}: ChipProps): React.Node => (
|
|
58
61
|
<div
|
|
@@ -74,6 +77,7 @@ export const Chip = ({
|
|
|
74
77
|
},
|
|
75
78
|
classNames?.wrapper,
|
|
76
79
|
)}
|
|
80
|
+
onClick={onClick}
|
|
77
81
|
>
|
|
78
82
|
{iconName && size !== 'small' && (
|
|
79
83
|
<Icon
|
|
@@ -83,14 +87,20 @@ export const Chip = ({
|
|
|
83
87
|
size="small"
|
|
84
88
|
/>
|
|
85
89
|
)}
|
|
86
|
-
{children}
|
|
90
|
+
<Truncate>{children}</Truncate>
|
|
91
|
+
|
|
87
92
|
{dismissable && size !== 'small' && (
|
|
88
93
|
<Icon
|
|
89
94
|
className={css.dismissIcon}
|
|
90
95
|
name="xmark"
|
|
91
96
|
type={iconType}
|
|
92
97
|
size="small"
|
|
93
|
-
onClick={(event) =>
|
|
98
|
+
onClick={(event) => {
|
|
99
|
+
event.stopPropagation();
|
|
100
|
+
if (!disabled && onDismiss) {
|
|
101
|
+
onDismiss(event);
|
|
102
|
+
}
|
|
103
|
+
}}
|
|
94
104
|
/>
|
|
95
105
|
)}
|
|
96
106
|
</div>
|