@spaced-out/ui-design-system 0.0.23-beta.0 → 0.0.24
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 +20 -0
- package/lib/components/Avatar/Avatar.js +27 -12
- package/lib/components/Avatar/Avatar.js.flow +25 -0
- package/lib/components/Avatar/Avatar.module.css +21 -1
- package/lib/components/Button/index.js.flow +6 -1
- package/lib/components/InlineDropdown/InlineDropdown.js +97 -0
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +134 -0
- package/lib/components/InlineDropdown/InlineDropdown.module.css +44 -0
- package/lib/components/InlineDropdown/index.js +16 -0
- package/lib/components/InlineDropdown/index.js.flow +3 -0
- package/lib/components/StatusIndicator/StatusIndicator.js +6 -1
- package/lib/components/StatusIndicator/StatusIndicator.js.flow +7 -0
- package/lib/components/StatusIndicator/StatusIndicator.module.css +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.24](https://github.com/spaced-out/ui-design-system/compare/v0.0.23...v0.0.24) (2023-02-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* inline dropdown ([#65](https://github.com/spaced-out/ui-design-system/issues/65)) ([c6063d3](https://github.com/spaced-out/ui-design-system/commit/c6063d376a61dce4d94e0f0079e2dcf44c5a86bf))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* border fixes for Status inddicator ([d2b2903](https://github.com/spaced-out/ui-design-system/commit/d2b2903c37c521a95566f1016845b1ce8e8eeee5))
|
|
16
|
+
|
|
17
|
+
### [0.0.23](https://github.com/spaced-out/ui-design-system/compare/v0.0.23-beta.0...v0.0.23) (2023-02-14)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* import fixes for avataar ([1880ed7](https://github.com/spaced-out/ui-design-system/commit/1880ed760283e48347b68c220a7ba11a54dfcd4f))
|
|
23
|
+
* status support for avataar ([e877b88](https://github.com/spaced-out/ui-design-system/commit/e877b88c326262f9738da89457bd417d4f684002))
|
|
24
|
+
|
|
5
25
|
### [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
26
|
|
|
7
27
|
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.avatarSizeOptions = exports.BaseAvatar = exports.Avatar = exports.AVATAR_SIZE = exports.AVATAR_COLOR = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _Text = require("../../components/Text");
|
|
9
|
-
var
|
|
9
|
+
var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
|
|
10
10
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
11
|
var _Icon = require("../Icon");
|
|
12
|
+
var _StatusIndicator = require("../StatusIndicator");
|
|
12
13
|
var _AvatarModule = _interopRequireDefault(require("./Avatar.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); }
|
|
@@ -23,12 +24,12 @@ exports.AVATAR_SIZE = AVATAR_SIZE;
|
|
|
23
24
|
const avatarSizeOptions = [...Object.keys(AVATAR_SIZE)];
|
|
24
25
|
exports.avatarSizeOptions = avatarSizeOptions;
|
|
25
26
|
const AVATAR_COLOR = Object.freeze({
|
|
26
|
-
red:
|
|
27
|
-
orange:
|
|
28
|
-
green:
|
|
29
|
-
blue:
|
|
30
|
-
gray:
|
|
31
|
-
indigo:
|
|
27
|
+
red: COLORS.colorDangerLightest,
|
|
28
|
+
orange: COLORS.colorWarningLightest,
|
|
29
|
+
green: COLORS.colorSuccessLightest,
|
|
30
|
+
blue: COLORS.colorInformationLightest,
|
|
31
|
+
gray: COLORS.colorGrayLightest,
|
|
32
|
+
indigo: COLORS.colorNeutralLightest
|
|
32
33
|
});
|
|
33
34
|
exports.AVATAR_COLOR = AVATAR_COLOR;
|
|
34
35
|
const getAvatarText = function () {
|
|
@@ -66,14 +67,22 @@ const AvatarConditionalContent = _ref2 => {
|
|
|
66
67
|
iconName,
|
|
67
68
|
size,
|
|
68
69
|
iconType,
|
|
69
|
-
color = 'blue'
|
|
70
|
+
color = 'blue',
|
|
71
|
+
status,
|
|
72
|
+
statusBorderColorToken
|
|
70
73
|
} = _ref2;
|
|
71
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
75
|
className: _AvatarModule.default.innerContainer,
|
|
73
76
|
style: {
|
|
74
77
|
background: AVATAR_COLOR[color]
|
|
75
78
|
}
|
|
76
|
-
},
|
|
79
|
+
}, !!status && /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: (0, _classify.default)(_AvatarModule.default.statusIndicatorWrapper, _AvatarModule.default[size])
|
|
81
|
+
}, /*#__PURE__*/React.createElement(_StatusIndicator.StatusIndicator, {
|
|
82
|
+
status: status,
|
|
83
|
+
withBorder: true,
|
|
84
|
+
borderColorToken: statusBorderColorToken
|
|
85
|
+
})), imageSrc ? /*#__PURE__*/React.createElement("img", {
|
|
77
86
|
src: imageSrc,
|
|
78
87
|
alt: "Avatar",
|
|
79
88
|
className: _AvatarModule.default.avatar
|
|
@@ -96,7 +105,9 @@ const Avatar = _ref3 => {
|
|
|
96
105
|
iconName,
|
|
97
106
|
iconType,
|
|
98
107
|
color,
|
|
99
|
-
ring = false
|
|
108
|
+
ring = false,
|
|
109
|
+
status,
|
|
110
|
+
statusBorderColorToken
|
|
100
111
|
} = _ref3;
|
|
101
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
102
113
|
className: (0, _classify.default)(_AvatarModule.default.container, {
|
|
@@ -115,14 +126,18 @@ const Avatar = _ref3 => {
|
|
|
115
126
|
iconName: iconName,
|
|
116
127
|
iconType: iconType,
|
|
117
128
|
color: color,
|
|
118
|
-
size: size
|
|
129
|
+
size: size,
|
|
130
|
+
status: status,
|
|
131
|
+
statusBorderColorToken: statusBorderColorToken
|
|
119
132
|
}))) : /*#__PURE__*/React.createElement(AvatarConditionalContent, {
|
|
120
133
|
imageSrc: imageSrc,
|
|
121
134
|
text: text,
|
|
122
135
|
iconName: iconName,
|
|
123
136
|
iconType: iconType,
|
|
124
137
|
color: color,
|
|
125
|
-
size: size
|
|
138
|
+
size: size,
|
|
139
|
+
status: status,
|
|
140
|
+
statusBorderColorToken: statusBorderColorToken
|
|
126
141
|
}));
|
|
127
142
|
};
|
|
128
143
|
exports.Avatar = Avatar;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SubTitleMedium,
|
|
8
8
|
SubTitleSmall,
|
|
9
9
|
} from '../../components/Text';
|
|
10
|
+
import * as COLORS from '../../styles/variables/_color';
|
|
10
11
|
import {
|
|
11
12
|
colorDangerLightest,
|
|
12
13
|
colorGrayLightest,
|
|
@@ -18,6 +19,8 @@ import {
|
|
|
18
19
|
import classify from '../../utils/classify';
|
|
19
20
|
import type {IconType} from '../Icon';
|
|
20
21
|
import {Icon} from '../Icon';
|
|
22
|
+
import type {StatusSemanticType} from '../StatusIndicator';
|
|
23
|
+
import {StatusIndicator} from '../StatusIndicator';
|
|
21
24
|
|
|
22
25
|
import css from './Avatar.module.css';
|
|
23
26
|
|
|
@@ -55,6 +58,8 @@ export type AvatarProps = {
|
|
|
55
58
|
iconName?: string,
|
|
56
59
|
iconType?: IconType,
|
|
57
60
|
ring?: boolean,
|
|
61
|
+
status?: StatusSemanticType,
|
|
62
|
+
statusBorderColorToken?: $Keys<typeof COLORS>,
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
const getAvatarText = (text = '') => {
|
|
@@ -96,6 +101,8 @@ export type AvatarContentProps = {
|
|
|
96
101
|
size: AvatarSize,
|
|
97
102
|
color?: AvatarColorType,
|
|
98
103
|
ring?: boolean,
|
|
104
|
+
status?: StatusSemanticType,
|
|
105
|
+
statusBorderColorToken?: $Keys<typeof COLORS>,
|
|
99
106
|
};
|
|
100
107
|
|
|
101
108
|
const AvatarConditionalContent = ({
|
|
@@ -105,8 +112,20 @@ const AvatarConditionalContent = ({
|
|
|
105
112
|
size,
|
|
106
113
|
iconType,
|
|
107
114
|
color = 'blue',
|
|
115
|
+
status,
|
|
116
|
+
statusBorderColorToken,
|
|
108
117
|
}: AvatarContentProps) => (
|
|
109
118
|
<div className={css.innerContainer} style={{background: AVATAR_COLOR[color]}}>
|
|
119
|
+
{!!status && (
|
|
120
|
+
<div className={classify(css.statusIndicatorWrapper, css[size])}>
|
|
121
|
+
<StatusIndicator
|
|
122
|
+
status={status}
|
|
123
|
+
withBorder
|
|
124
|
+
borderColorToken={statusBorderColorToken}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
|
|
110
129
|
{imageSrc ? (
|
|
111
130
|
<img src={imageSrc} alt="Avatar" className={css.avatar}></img>
|
|
112
131
|
) : iconName ? (
|
|
@@ -127,6 +146,8 @@ export const Avatar = ({
|
|
|
127
146
|
iconType,
|
|
128
147
|
color,
|
|
129
148
|
ring = false,
|
|
149
|
+
status,
|
|
150
|
+
statusBorderColorToken,
|
|
130
151
|
}: AvatarProps): React.Node => (
|
|
131
152
|
<div
|
|
132
153
|
className={classify(
|
|
@@ -150,6 +171,8 @@ export const Avatar = ({
|
|
|
150
171
|
iconType={iconType}
|
|
151
172
|
color={color}
|
|
152
173
|
size={size}
|
|
174
|
+
status={status}
|
|
175
|
+
statusBorderColorToken={statusBorderColorToken}
|
|
153
176
|
/>
|
|
154
177
|
</div>
|
|
155
178
|
</div>
|
|
@@ -161,6 +184,8 @@ export const Avatar = ({
|
|
|
161
184
|
iconType={iconType}
|
|
162
185
|
color={color}
|
|
163
186
|
size={size}
|
|
187
|
+
status={status}
|
|
188
|
+
statusBorderColorToken={statusBorderColorToken}
|
|
164
189
|
/>
|
|
165
190
|
)}
|
|
166
191
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@value (colorFillPrimary, colorBackgroundTertiary, colorInformation) from '../../styles/variables/_color.css';
|
|
2
2
|
@value ( size34, size42, size60, sizeFluid) from '../../styles/variables/_size.css';
|
|
3
3
|
@value (borderRadiusCircle, borderRadiusLarge, borderRadiusXLarge, borderWidthSecondary) from '../../styles/variables/_border.css';
|
|
4
|
-
@value (spaceXXSmall, spaceXSmall) from '../../styles/variables/_space.css';
|
|
4
|
+
@value (spaceNone, spaceXXSmall, spaceXSmall) from '../../styles/variables/_space.css';
|
|
5
5
|
|
|
6
6
|
.container {
|
|
7
7
|
border-radius: borderRadiusCircle;
|
|
@@ -79,9 +79,29 @@
|
|
|
79
79
|
|
|
80
80
|
.innerContainer {
|
|
81
81
|
display: flex;
|
|
82
|
+
position: relative;
|
|
82
83
|
border-radius: borderRadiusCircle;
|
|
83
84
|
width: sizeFluid;
|
|
84
85
|
height: sizeFluid;
|
|
85
86
|
align-items: center;
|
|
86
87
|
justify-content: center;
|
|
87
88
|
}
|
|
89
|
+
|
|
90
|
+
.statusIndicatorWrapper {
|
|
91
|
+
position: absolute;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.statusIndicatorWrapper.large {
|
|
95
|
+
top: calc(spaceXXSmall / 2);
|
|
96
|
+
right: calc(spaceXXSmall / 2);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.statusIndicatorWrapper.medium {
|
|
100
|
+
top: spaceNone;
|
|
101
|
+
right: spaceNone;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.statusIndicatorWrapper.small {
|
|
105
|
+
top: calc((spaceXXSmall / 2) * -1);
|
|
106
|
+
right: calc((spaceXXSmall / 2) * -1);
|
|
107
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InlineDropdown = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactDom = require("@floating-ui/react-dom");
|
|
9
|
+
var _space = require("../../styles/variables/_space");
|
|
10
|
+
var _classify = require("../../utils/classify");
|
|
11
|
+
var _clickAway = require("../../utils/click-away");
|
|
12
|
+
var _Button = require("../Button");
|
|
13
|
+
var _Icon = require("../Icon");
|
|
14
|
+
var _Menu = require("../Menu");
|
|
15
|
+
var _Truncate = require("../Truncate");
|
|
16
|
+
var _InlineDropdownModule = _interopRequireDefault(require("./InlineDropdown.module.css"));
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
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); }
|
|
21
|
+
const InlineDropdown = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
anchorPosition = 'bottom-start',
|
|
24
|
+
size = 'medium',
|
|
25
|
+
onOptionSelect,
|
|
26
|
+
menu,
|
|
27
|
+
classNames,
|
|
28
|
+
disabled,
|
|
29
|
+
onMenuOpen,
|
|
30
|
+
onMenuClose,
|
|
31
|
+
children,
|
|
32
|
+
...restButtonProps
|
|
33
|
+
} = _ref;
|
|
34
|
+
const menuBtnRef = React.useRef();
|
|
35
|
+
const {
|
|
36
|
+
x,
|
|
37
|
+
y,
|
|
38
|
+
reference,
|
|
39
|
+
floating,
|
|
40
|
+
strategy
|
|
41
|
+
} = (0, _reactDom.useFloating)({
|
|
42
|
+
strategy: 'absolute',
|
|
43
|
+
placement: anchorPosition,
|
|
44
|
+
whileElementsMounted: _reactDom.autoUpdate,
|
|
45
|
+
middleware: [(0, _reactDom.shift)(), (0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
|
|
46
|
+
});
|
|
47
|
+
const onMenuToggle = isOpen => {
|
|
48
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
49
|
+
};
|
|
50
|
+
return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
|
|
51
|
+
onChange: onMenuToggle
|
|
52
|
+
}, _ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
isOpen,
|
|
55
|
+
onOpen,
|
|
56
|
+
cancelNext,
|
|
57
|
+
clickAway
|
|
58
|
+
} = _ref2;
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
"data-testid": "InlineDropdown",
|
|
61
|
+
className: (0, _classify.classify)(_InlineDropdownModule.default.inlineDropdownContainer, classNames?.dropdownContainer),
|
|
62
|
+
ref: menuBtnRef
|
|
63
|
+
}, /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({}, restButtonProps, {
|
|
64
|
+
disabled: disabled,
|
|
65
|
+
ref: reference,
|
|
66
|
+
onClick: e => {
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
onOpen();
|
|
69
|
+
},
|
|
70
|
+
className: (0, _classify.classify)(_InlineDropdownModule.default.inlineButton, {
|
|
71
|
+
[_InlineDropdownModule.default.disabled]: disabled
|
|
72
|
+
}, _InlineDropdownModule.default[size], classNames?.buttonWrapper)
|
|
73
|
+
}), /*#__PURE__*/React.createElement(_Truncate.Truncate, null, children), /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
74
|
+
name: isOpen ? 'caret-up' : 'caret-down',
|
|
75
|
+
size: "small",
|
|
76
|
+
type: "solid",
|
|
77
|
+
className: (0, _classify.classify)({
|
|
78
|
+
[_InlineDropdownModule.default.disabled]: disabled
|
|
79
|
+
})
|
|
80
|
+
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
onClickCapture: cancelNext,
|
|
82
|
+
ref: floating,
|
|
83
|
+
style: {
|
|
84
|
+
display: 'flex',
|
|
85
|
+
position: strategy,
|
|
86
|
+
top: y ?? _space.spaceNone,
|
|
87
|
+
left: x ?? _space.spaceNone
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
90
|
+
onSelect: option => {
|
|
91
|
+
onOptionSelect && onOptionSelect(option);
|
|
92
|
+
clickAway();
|
|
93
|
+
}
|
|
94
|
+
}))));
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
exports.InlineDropdown = InlineDropdown;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import {
|
|
5
|
+
// $FlowFixMe[untyped-import]
|
|
6
|
+
autoUpdate,
|
|
7
|
+
// $FlowFixMe[untyped-import]
|
|
8
|
+
flip,
|
|
9
|
+
// $FlowFixMe[untyped-import]
|
|
10
|
+
offset,
|
|
11
|
+
// $FlowFixMe[untyped-import]
|
|
12
|
+
shift,
|
|
13
|
+
// $FlowFixMe[untyped-import]
|
|
14
|
+
useFloating,
|
|
15
|
+
} from '@floating-ui/react-dom';
|
|
16
|
+
|
|
17
|
+
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
18
|
+
import {classify} from '../../utils/classify';
|
|
19
|
+
import {ClickAway} from '../../utils/click-away';
|
|
20
|
+
import type {UnstyledButtonProps} from '../Button';
|
|
21
|
+
import {UnstyledButton} from '../Button';
|
|
22
|
+
import type {AnchorType} from '../ButtonDropdown';
|
|
23
|
+
import {Icon} from '../Icon';
|
|
24
|
+
import type {MenuOption, MenuProps} from '../Menu';
|
|
25
|
+
import {Menu} from '../Menu';
|
|
26
|
+
import {Truncate} from '../Truncate';
|
|
27
|
+
|
|
28
|
+
import css from './InlineDropdown.module.css';
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
type ClassNames = $ReadOnly<{
|
|
32
|
+
buttonWrapper?: string,
|
|
33
|
+
dropdownContainer?: string,
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
export type InlineDropdownProps = {
|
|
37
|
+
...UnstyledButtonProps,
|
|
38
|
+
classNames?: ClassNames,
|
|
39
|
+
menu: MenuProps,
|
|
40
|
+
anchorPosition?: AnchorType,
|
|
41
|
+
onOptionSelect?: (option: MenuOption) => mixed,
|
|
42
|
+
onMenuOpen?: () => mixed,
|
|
43
|
+
onMenuClose?: () => mixed,
|
|
44
|
+
size?: 'medium' | 'small' | 'extraSmall',
|
|
45
|
+
...
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const InlineDropdown = ({
|
|
49
|
+
anchorPosition = 'bottom-start',
|
|
50
|
+
size = 'medium',
|
|
51
|
+
onOptionSelect,
|
|
52
|
+
menu,
|
|
53
|
+
classNames,
|
|
54
|
+
disabled,
|
|
55
|
+
onMenuOpen,
|
|
56
|
+
onMenuClose,
|
|
57
|
+
children,
|
|
58
|
+
...restButtonProps
|
|
59
|
+
}: InlineDropdownProps): React.Node => {
|
|
60
|
+
const menuBtnRef = React.useRef();
|
|
61
|
+
const {x, y, reference, floating, strategy} = useFloating({
|
|
62
|
+
strategy: 'absolute',
|
|
63
|
+
placement: anchorPosition,
|
|
64
|
+
whileElementsMounted: autoUpdate,
|
|
65
|
+
middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const onMenuToggle = (isOpen: boolean) => {
|
|
69
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ClickAway onChange={onMenuToggle}>
|
|
74
|
+
{({isOpen, onOpen, cancelNext, clickAway}) => (
|
|
75
|
+
<div
|
|
76
|
+
data-testid="InlineDropdown"
|
|
77
|
+
className={classify(
|
|
78
|
+
css.inlineDropdownContainer,
|
|
79
|
+
classNames?.dropdownContainer,
|
|
80
|
+
)}
|
|
81
|
+
ref={menuBtnRef}
|
|
82
|
+
>
|
|
83
|
+
<UnstyledButton
|
|
84
|
+
{...restButtonProps}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
ref={reference}
|
|
87
|
+
onClick={(e) => {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
onOpen();
|
|
90
|
+
}}
|
|
91
|
+
className={classify(
|
|
92
|
+
css.inlineButton,
|
|
93
|
+
{
|
|
94
|
+
[css.disabled]: disabled,
|
|
95
|
+
},
|
|
96
|
+
css[size],
|
|
97
|
+
classNames?.buttonWrapper,
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
<Truncate>{children}</Truncate>
|
|
101
|
+
<Icon
|
|
102
|
+
name={isOpen ? 'caret-up' : 'caret-down'}
|
|
103
|
+
size="small"
|
|
104
|
+
type="solid"
|
|
105
|
+
className={classify({
|
|
106
|
+
[css.disabled]: disabled,
|
|
107
|
+
})}
|
|
108
|
+
/>
|
|
109
|
+
</UnstyledButton>
|
|
110
|
+
{isOpen && menu && (
|
|
111
|
+
<div
|
|
112
|
+
onClickCapture={cancelNext}
|
|
113
|
+
ref={floating}
|
|
114
|
+
style={{
|
|
115
|
+
display: 'flex',
|
|
116
|
+
position: strategy,
|
|
117
|
+
top: y ?? spaceNone,
|
|
118
|
+
left: x ?? spaceNone,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
<Menu
|
|
122
|
+
{...menu}
|
|
123
|
+
onSelect={(option) => {
|
|
124
|
+
onOptionSelect && onOptionSelect(option);
|
|
125
|
+
clickAway();
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
</ClickAway>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@value ( sizeFluid) from '../../styles/variables/_size.css';
|
|
2
|
+
@value ( spaceXXSmall) from '../../styles/variables/_space.css';
|
|
3
|
+
@value ( colorTextDisabled, colorFocusPrimary) from '../../styles/variables/_color.css';
|
|
4
|
+
@value ( borderWidthNone, borderWidthTertiary, borderRadiusXSmall) from '../../styles/variables/_border.css';
|
|
5
|
+
|
|
6
|
+
.inlineDropdownContainer {
|
|
7
|
+
display: flex;
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.isFluid {
|
|
12
|
+
width: sizeFluid;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.inlineButton {
|
|
16
|
+
display: flex;
|
|
17
|
+
gap: spaceXXSmall;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
align-items: center;
|
|
20
|
+
border-radius: borderRadiusXSmall;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.inlineButton:focus {
|
|
24
|
+
box-shadow: borderWidthNone borderWidthNone borderWidthNone
|
|
25
|
+
borderWidthTertiary colorFocusPrimary;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.medium {
|
|
29
|
+
composes: buttonTextMedium from '../../styles/typography.module.css';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.small {
|
|
33
|
+
composes: buttonTextSmall from '../../styles/typography.module.css';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.extraSmall {
|
|
37
|
+
composes: buttonTextExtraSmall from '../../styles/typography.module.css';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.disabled {
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
color: colorTextDisabled;
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _InlineDropdown = require("./InlineDropdown");
|
|
7
|
+
Object.keys(_InlineDropdown).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _InlineDropdown[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _InlineDropdown[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.StatusIndicator = exports.STATUS_SEMANTIC = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
|
|
8
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
10
|
var _StatusIndicatorModule = _interopRequireDefault(require("./StatusIndicator.module.css"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -24,13 +25,17 @@ const StatusIndicator = _ref => {
|
|
|
24
25
|
classNames,
|
|
25
26
|
status = 'information',
|
|
26
27
|
withBorder,
|
|
28
|
+
borderColorToken = 'colorBackgroundTertiary',
|
|
27
29
|
...props
|
|
28
30
|
} = _ref;
|
|
29
31
|
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
30
32
|
"data-testid": "StatusIndicator",
|
|
31
33
|
className: (0, _classify.default)(_StatusIndicatorModule.default.statusWrapper, _StatusIndicatorModule.default[status], {
|
|
32
34
|
[_StatusIndicatorModule.default.withBorder]: withBorder
|
|
33
|
-
}, classNames?.wrapper)
|
|
35
|
+
}, classNames?.wrapper),
|
|
36
|
+
style: {
|
|
37
|
+
'--border-color': COLORS[borderColorToken] || COLORS['colorBackgroundTertiary']
|
|
38
|
+
}
|
|
34
39
|
}));
|
|
35
40
|
};
|
|
36
41
|
exports.StatusIndicator = StatusIndicator;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
|
+
import * as COLORS from '../../styles/variables/_color';
|
|
5
6
|
import classify from '../../utils/classify';
|
|
6
7
|
|
|
7
8
|
import css from './StatusIndicator.module.css';
|
|
@@ -23,6 +24,7 @@ export type StatusIndicatorProps = {
|
|
|
23
24
|
classNames?: ClassNames,
|
|
24
25
|
status?: StatusSemanticType,
|
|
25
26
|
withBorder?: boolean,
|
|
27
|
+
borderColorToken?: $Keys<typeof COLORS>,
|
|
26
28
|
...
|
|
27
29
|
};
|
|
28
30
|
|
|
@@ -30,6 +32,7 @@ export const StatusIndicator = ({
|
|
|
30
32
|
classNames,
|
|
31
33
|
status = 'information',
|
|
32
34
|
withBorder,
|
|
35
|
+
borderColorToken = 'colorBackgroundTertiary',
|
|
33
36
|
...props
|
|
34
37
|
}: StatusIndicatorProps): React.Node => (
|
|
35
38
|
<div
|
|
@@ -43,5 +46,9 @@ export const StatusIndicator = ({
|
|
|
43
46
|
},
|
|
44
47
|
classNames?.wrapper,
|
|
45
48
|
)}
|
|
49
|
+
style={{
|
|
50
|
+
'--border-color':
|
|
51
|
+
COLORS[borderColorToken] || COLORS['colorBackgroundTertiary'],
|
|
52
|
+
}}
|
|
46
53
|
></div>
|
|
47
54
|
);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
@value (borderRadiusCircle, borderWidthTertiary) from '../../styles/variables/_border.css';
|
|
4
4
|
|
|
5
5
|
.statusWrapper {
|
|
6
|
+
--border-color: colorBackgroundTertiary;
|
|
6
7
|
display: flex;
|
|
7
8
|
color: colorFillPrimary;
|
|
8
9
|
width: size8;
|
|
@@ -33,5 +34,5 @@
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
.withBorder {
|
|
36
|
-
border: borderWidthTertiary solid
|
|
37
|
+
border: borderWidthTertiary solid var(--border-color);
|
|
37
38
|
}
|