@spaced-out/ui-design-system 0.3.47-beta.0 → 0.3.47
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 +7 -0
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +2 -2
- package/lib/components/ButtonDropdown/ButtonDropdown.js +10 -22
- package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +33 -58
- package/lib/components/ButtonDropdown/ButtonDropdown.module.css +1 -8
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js +0 -3
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +1 -6
- package/lib/components/ButtonTabs/ButtonTabDropdown.js +6 -13
- package/lib/components/ButtonTabs/ButtonTabDropdown.js.flow +24 -40
- package/lib/components/ButtonTabs/ButtonTabDropdown.module.css +0 -4
- package/lib/components/ButtonTabs/ButtonTabs.js +0 -2
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +0 -4
- package/lib/components/DateRangePicker/DateRangePicker.js +6 -2
- package/lib/components/DateRangePicker/DateRangePicker.js.flow +6 -0
- package/lib/components/DateRangePicker/DateRangeWrapper.js +4 -4
- package/lib/components/DateRangePicker/DateRangeWrapper.js.flow +4 -4
- package/lib/components/Dropdown/Dropdown.js +8 -23
- package/lib/components/Dropdown/Dropdown.js.flow +32 -57
- package/lib/components/Dropdown/Dropdown.module.css +0 -5
- package/lib/components/Dropdown/SimpleDropdown.js +0 -2
- package/lib/components/Dropdown/SimpleDropdown.js.flow +0 -4
- package/lib/components/InlineDropdown/InlineDropdown.js +8 -25
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +30 -57
- package/lib/components/InlineDropdown/InlineDropdown.module.css +0 -5
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js +0 -2
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +0 -4
- package/lib/components/Table/StaticTable.js +1 -1
- package/lib/components/Table/StaticTable.js.flow +1 -1
- package/lib/components/Table/Table.docs.js +1 -1
- package/lib/components/Table/Table.docs.js.flow +1 -1
- package/lib/components/Tabs/TabList/TabDropdown.js +7 -14
- package/lib/components/Tabs/TabList/TabDropdown.js.flow +22 -38
- package/lib/components/Tabs/TabList/TabDropdown.module.css +0 -4
- package/lib/components/Tabs/TabList/TabList.js +2 -4
- package/lib/components/Tabs/TabList/TabList.js.flow +0 -4
- package/lib/components/TokenListInput/TokenListInput.js +7 -26
- package/lib/components/TokenListInput/TokenListInput.js.flow +32 -58
- package/lib/components/TokenListInput/TokenListInput.module.css +0 -5
- package/lib/components/Tooltip/Tooltip.js +1 -2
- package/lib/components/Tooltip/Tooltip.js.flow +2 -2
- package/lib/components/Typeahead/SimpleTypeahead.js +1 -3
- package/lib/components/Typeahead/SimpleTypeahead.js.flow +0 -4
- package/lib/components/Typeahead/Typeahead.js +8 -25
- package/lib/components/Typeahead/Typeahead.js.flow +30 -58
- package/lib/components/Typeahead/Typeahead.module.css +0 -5
- package/lib/hooks/index.js +0 -11
- package/lib/hooks/index.js.flow +0 -1
- package/package.json +1 -1
- package/lib/hooks/useReferenceElementWidth/index.js +0 -16
- package/lib/hooks/useReferenceElementWidth/index.js.flow +0 -3
- package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js +0 -21
- package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js.flow +0 -23
|
@@ -188,8 +188,8 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
188
188
|
cardWrapperClass,
|
|
189
189
|
hideTimezone,
|
|
190
190
|
today,
|
|
191
|
-
startDateLabel
|
|
192
|
-
endDateLabel
|
|
191
|
+
startDateLabel,
|
|
192
|
+
endDateLabel,
|
|
193
193
|
}: DateRangeWrapperProps,
|
|
194
194
|
ref,
|
|
195
195
|
): React.Node => {
|
|
@@ -238,7 +238,7 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
238
238
|
className={css.selectedDate}
|
|
239
239
|
color={TEXT_COLORS.secondary}
|
|
240
240
|
>
|
|
241
|
-
{`${startDateLabel}: ${getFormattedDate(
|
|
241
|
+
{`${startDateLabel || 'Start Date'}: ${getFormattedDate(
|
|
242
242
|
MARKERS.DATE_RANGE_START,
|
|
243
243
|
dateRange,
|
|
244
244
|
)}`}
|
|
@@ -255,7 +255,7 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
255
255
|
className={css.selectedDate}
|
|
256
256
|
color={TEXT_COLORS.secondary}
|
|
257
257
|
>
|
|
258
|
-
{`${endDateLabel}: ${getFormattedDate(
|
|
258
|
+
{`${endDateLabel || 'End Date'}: ${getFormattedDate(
|
|
259
259
|
MARKERS.DATE_RANGE_END,
|
|
260
260
|
dateRange,
|
|
261
261
|
)}`}
|
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Dropdown = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _react2 = require("@floating-ui/react");
|
|
9
|
-
var
|
|
9
|
+
var _size = require("../../styles/variables/_size");
|
|
10
10
|
var _space = require("../../styles/variables/_space");
|
|
11
11
|
var _classify = require("../../utils/classify");
|
|
12
12
|
var _clickAway = require("../../utils/click-away");
|
|
13
13
|
var _mergeRefs = require("../../utils/merge-refs");
|
|
14
14
|
var _Input = require("../Input");
|
|
15
15
|
var _Menu = require("../Menu");
|
|
16
|
-
var _Tooltip = require("../Tooltip");
|
|
17
16
|
var _DropdownModule = _interopRequireDefault(require("./Dropdown.module.css"));
|
|
18
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -30,16 +29,15 @@ const Dropdown = exports.Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
30
29
|
scrollMenuToBottom = false,
|
|
31
30
|
dropdownInputText = '',
|
|
32
31
|
clickAwayRef,
|
|
33
|
-
elevation = 'modal',
|
|
34
32
|
...inputProps
|
|
35
33
|
} = _ref;
|
|
34
|
+
const dropdownRef = React.useRef();
|
|
36
35
|
const menuRef = React.useRef();
|
|
37
36
|
const {
|
|
38
37
|
x,
|
|
39
38
|
y,
|
|
40
39
|
refs,
|
|
41
|
-
strategy
|
|
42
|
-
context
|
|
40
|
+
strategy
|
|
43
41
|
} = (0, _react2.useFloating)({
|
|
44
42
|
open: true,
|
|
45
43
|
strategy: 'absolute',
|
|
@@ -47,7 +45,6 @@ const Dropdown = exports.Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
47
45
|
whileElementsMounted: _react2.autoUpdate,
|
|
48
46
|
middleware: [(0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
49
47
|
});
|
|
50
|
-
const dropdownWidth = (0, _hooks.useReferenceElementWidth)(refs.reference?.current);
|
|
51
48
|
const onMenuToggle = isOpen => {
|
|
52
49
|
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
53
50
|
if (scrollMenuToBottom && menuRef.current && isOpen) {
|
|
@@ -66,8 +63,9 @@ const Dropdown = exports.Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
66
63
|
triggerRef
|
|
67
64
|
} = _ref2;
|
|
68
65
|
return /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
"data-testid": "Dropdown",
|
|
69
67
|
className: (0, _classify.classify)(_DropdownModule.default.dropdownContainer, classNames?.wrapper),
|
|
70
|
-
|
|
68
|
+
ref: (0, _mergeRefs.mergeRefs)([dropdownRef, boundaryRef])
|
|
71
69
|
}, /*#__PURE__*/React.createElement(_Input.Input, _extends({}, inputProps, {
|
|
72
70
|
onKeyDown: e => {
|
|
73
71
|
if (e.keyCode === 32) {
|
|
@@ -90,26 +88,13 @@ const Dropdown = exports.Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
90
88
|
onOpen();
|
|
91
89
|
},
|
|
92
90
|
ref: ref
|
|
93
|
-
})), isOpen && menu && /*#__PURE__*/React.createElement(
|
|
94
|
-
modal: false,
|
|
95
|
-
context: context,
|
|
96
|
-
initialFocus: refs.reference
|
|
97
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
98
92
|
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
99
|
-
className: _DropdownModule.default.menuWrapper,
|
|
100
93
|
style: {
|
|
101
94
|
position: strategy,
|
|
102
95
|
top: y ?? _space.spaceNone,
|
|
103
96
|
left: x ?? _space.spaceNone,
|
|
104
|
-
|
|
105
|
-
so its parent is effectively the <body> element. This means the menu
|
|
106
|
-
would otherwise default to the body's width. To support fluid width,
|
|
107
|
-
we must manually set the dropdown width here; otherwise, it uses a fixed width.
|
|
108
|
-
Also, Only treat menu as non-fluid if isFluid is strictly false, since default is true in menu and undefined means fluid. */
|
|
109
|
-
...(menu.isFluid !== false && {
|
|
110
|
-
'--dropdown-width': dropdownWidth
|
|
111
|
-
}),
|
|
112
|
-
'--menu-elevation': (0, _Tooltip.getElevationValue)(elevation)
|
|
97
|
+
width: _size.sizeFluid
|
|
113
98
|
}
|
|
114
99
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
115
100
|
onSelect: (option, e) => {
|
|
@@ -124,6 +109,6 @@ const Dropdown = exports.Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
124
109
|
size: menu.size || size,
|
|
125
110
|
onTabOut: clickAway,
|
|
126
111
|
ref: menuRef
|
|
127
|
-
}))))
|
|
112
|
+
}))));
|
|
128
113
|
});
|
|
129
114
|
});
|
|
@@ -7,16 +7,12 @@ import {
|
|
|
7
7
|
// $FlowFixMe[untyped-import]
|
|
8
8
|
flip,
|
|
9
9
|
// $FlowFixMe[untyped-import]
|
|
10
|
-
FloatingFocusManager,
|
|
11
|
-
// $FlowFixMe[untyped-import]
|
|
12
|
-
FloatingPortal,
|
|
13
|
-
// $FlowFixMe[untyped-import]
|
|
14
10
|
offset,
|
|
15
11
|
// $FlowFixMe[untyped-import]
|
|
16
12
|
useFloating,
|
|
17
13
|
} from '@floating-ui/react';
|
|
18
14
|
|
|
19
|
-
import {
|
|
15
|
+
import {sizeFluid} from '../../styles/variables/_size';
|
|
20
16
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
21
17
|
import {classify} from '../../utils/classify';
|
|
22
18
|
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
@@ -25,7 +21,6 @@ import type {InputProps} from '../Input';
|
|
|
25
21
|
import {Input} from '../Input';
|
|
26
22
|
import type {MenuOption, MenuProps} from '../Menu';
|
|
27
23
|
import {Menu} from '../Menu';
|
|
28
|
-
import {type ElevationType, getElevationValue} from '../Tooltip';
|
|
29
24
|
|
|
30
25
|
import css from './Dropdown.module.css';
|
|
31
26
|
|
|
@@ -45,7 +40,6 @@ export type DropdownProps = {
|
|
|
45
40
|
scrollMenuToBottom?: boolean,
|
|
46
41
|
dropdownInputText?: string,
|
|
47
42
|
menu?: MenuProps,
|
|
48
|
-
elevation?: ElevationType,
|
|
49
43
|
clickAwayRef?: ClickAwayRefType,
|
|
50
44
|
...
|
|
51
45
|
};
|
|
@@ -66,21 +60,19 @@ export const Dropdown: React$AbstractComponent<
|
|
|
66
60
|
scrollMenuToBottom = false,
|
|
67
61
|
dropdownInputText = '',
|
|
68
62
|
clickAwayRef,
|
|
69
|
-
elevation = 'modal',
|
|
70
63
|
...inputProps
|
|
71
64
|
}: DropdownProps,
|
|
72
65
|
ref,
|
|
73
66
|
): React.Node => {
|
|
67
|
+
const dropdownRef = React.useRef();
|
|
74
68
|
const menuRef = React.useRef();
|
|
75
|
-
|
|
76
|
-
const {x, y, refs, strategy, context} = useFloating({
|
|
69
|
+
const {x, y, refs, strategy} = useFloating({
|
|
77
70
|
open: true,
|
|
78
71
|
strategy: 'absolute',
|
|
79
72
|
placement: 'bottom-start',
|
|
80
73
|
whileElementsMounted: autoUpdate,
|
|
81
74
|
middleware: [flip(), offset(parseInt(spaceXXSmall))],
|
|
82
75
|
});
|
|
83
|
-
const dropdownWidth = useReferenceElementWidth(refs.reference?.current);
|
|
84
76
|
|
|
85
77
|
const onMenuToggle = (isOpen: boolean) => {
|
|
86
78
|
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
@@ -93,8 +85,9 @@ export const Dropdown: React$AbstractComponent<
|
|
|
93
85
|
<ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
|
|
94
86
|
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
95
87
|
<div
|
|
96
|
-
className={classify(css.dropdownContainer, classNames?.wrapper)}
|
|
97
88
|
data-testid="Dropdown"
|
|
89
|
+
className={classify(css.dropdownContainer, classNames?.wrapper)}
|
|
90
|
+
ref={mergeRefs([dropdownRef, boundaryRef])}
|
|
98
91
|
>
|
|
99
92
|
<Input
|
|
100
93
|
{...inputProps}
|
|
@@ -122,51 +115,33 @@ export const Dropdown: React$AbstractComponent<
|
|
|
122
115
|
/>
|
|
123
116
|
|
|
124
117
|
{isOpen && menu && (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
onChange && onChange(option, e);
|
|
153
|
-
if (
|
|
154
|
-
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
155
|
-
!option.keepMenuOpenOnOptionSelect &&
|
|
156
|
-
(!menu.optionsVariant ||
|
|
157
|
-
menu.optionsVariant === 'normal')
|
|
158
|
-
) {
|
|
159
|
-
clickAway();
|
|
160
|
-
refs.reference.current.querySelector('input').focus();
|
|
161
|
-
}
|
|
162
|
-
}}
|
|
163
|
-
size={menu.size || size}
|
|
164
|
-
onTabOut={clickAway}
|
|
165
|
-
ref={menuRef}
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
</FloatingFocusManager>
|
|
169
|
-
</FloatingPortal>
|
|
118
|
+
<div
|
|
119
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
120
|
+
style={{
|
|
121
|
+
position: strategy,
|
|
122
|
+
top: y ?? spaceNone,
|
|
123
|
+
left: x ?? spaceNone,
|
|
124
|
+
width: sizeFluid,
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<Menu
|
|
128
|
+
{...menu}
|
|
129
|
+
onSelect={(option, e) => {
|
|
130
|
+
onChange && onChange(option, e);
|
|
131
|
+
if (
|
|
132
|
+
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
133
|
+
!option.keepMenuOpenOnOptionSelect &&
|
|
134
|
+
(!menu.optionsVariant || menu.optionsVariant === 'normal')
|
|
135
|
+
) {
|
|
136
|
+
clickAway();
|
|
137
|
+
refs.reference.current.querySelector('input').focus();
|
|
138
|
+
}
|
|
139
|
+
}}
|
|
140
|
+
size={menu.size || size}
|
|
141
|
+
onTabOut={clickAway}
|
|
142
|
+
ref={menuRef}
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
170
145
|
)}
|
|
171
146
|
</div>
|
|
172
147
|
)}
|
|
@@ -22,7 +22,6 @@ const SimpleDropdownBase = (props, ref) => {
|
|
|
22
22
|
onMenuOpen,
|
|
23
23
|
onMenuClose,
|
|
24
24
|
resolveLabel,
|
|
25
|
-
elevation = 'modal',
|
|
26
25
|
menuVirtualization,
|
|
27
26
|
resolveSecondaryLabel,
|
|
28
27
|
isMenuFluid = true,
|
|
@@ -62,7 +61,6 @@ const SimpleDropdownBase = (props, ref) => {
|
|
|
62
61
|
return /*#__PURE__*/React.createElement(_Dropdown.Dropdown, _extends({}, inputProps, {
|
|
63
62
|
classNames: classNames,
|
|
64
63
|
size: size,
|
|
65
|
-
elevation: elevation,
|
|
66
64
|
placeholder: placeholder,
|
|
67
65
|
onChange: handleOptionChange,
|
|
68
66
|
onMenuOpen: onMenuOpen,
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '../../utils/menu';
|
|
11
11
|
import type {InputProps} from '../Input';
|
|
12
12
|
import type {MenuOption, MenuOptionsVariant, Virtualization} from '../Menu';
|
|
13
|
-
import type {ElevationType} from '../Tooltip';
|
|
14
13
|
|
|
15
14
|
import {Dropdown} from './Dropdown';
|
|
16
15
|
|
|
@@ -28,7 +27,6 @@ export type SimpleDropdownProps = {
|
|
|
28
27
|
// Input props
|
|
29
28
|
...InputProps,
|
|
30
29
|
|
|
31
|
-
elevation?: ElevationType,
|
|
32
30
|
classNames?: ClassNames,
|
|
33
31
|
clickAwayRef?: ClickAwayRefType,
|
|
34
32
|
|
|
@@ -69,7 +67,6 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
|
|
|
69
67
|
onMenuOpen,
|
|
70
68
|
onMenuClose,
|
|
71
69
|
resolveLabel,
|
|
72
|
-
elevation = 'modal',
|
|
73
70
|
menuVirtualization,
|
|
74
71
|
resolveSecondaryLabel,
|
|
75
72
|
isMenuFluid = true,
|
|
@@ -128,7 +125,6 @@ const SimpleDropdownBase = (props: SimpleDropdownProps, ref) => {
|
|
|
128
125
|
{...inputProps}
|
|
129
126
|
classNames={classNames}
|
|
130
127
|
size={size}
|
|
131
|
-
elevation={elevation}
|
|
132
128
|
placeholder={placeholder}
|
|
133
129
|
onChange={handleOptionChange}
|
|
134
130
|
onMenuOpen={onMenuOpen}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.InlineDropdown = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _react2 = require("@floating-ui/react");
|
|
9
|
-
var _hooks = require("../../hooks");
|
|
10
9
|
var _space = require("../../styles/variables/_space");
|
|
11
10
|
var _classify = require("../../utils/classify");
|
|
12
11
|
var _clickAway = require("../../utils/click-away");
|
|
@@ -14,7 +13,6 @@ var _mergeRefs = require("../../utils/merge-refs");
|
|
|
14
13
|
var _Button = require("../Button");
|
|
15
14
|
var _Icon = require("../Icon");
|
|
16
15
|
var _Menu = require("../Menu");
|
|
17
|
-
var _Tooltip = require("../Tooltip");
|
|
18
16
|
var _Truncate = require("../Truncate");
|
|
19
17
|
var _InlineDropdownModule = _interopRequireDefault(require("./InlineDropdown.module.css"));
|
|
20
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -32,15 +30,15 @@ const InlineDropdown = exports.InlineDropdown = /*#__PURE__*/React.forwardRef((_
|
|
|
32
30
|
onMenuClose,
|
|
33
31
|
children,
|
|
34
32
|
clickAwayRef,
|
|
35
|
-
elevation = 'modal',
|
|
36
33
|
...restButtonProps
|
|
37
34
|
} = _ref;
|
|
35
|
+
const menuBtnRef = React.useRef(null);
|
|
36
|
+
React.useImperativeHandle(ref, () => menuBtnRef.current);
|
|
38
37
|
const {
|
|
39
38
|
x,
|
|
40
39
|
y,
|
|
41
40
|
refs,
|
|
42
|
-
strategy
|
|
43
|
-
context
|
|
41
|
+
strategy
|
|
44
42
|
} = (0, _react2.useFloating)({
|
|
45
43
|
open: true,
|
|
46
44
|
strategy: 'absolute',
|
|
@@ -48,9 +46,8 @@ const InlineDropdown = exports.InlineDropdown = /*#__PURE__*/React.forwardRef((_
|
|
|
48
46
|
whileElementsMounted: _react2.autoUpdate,
|
|
49
47
|
middleware: [(0, _react2.shift)(), (0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
50
48
|
});
|
|
51
|
-
const dropdownWidth = (0, _hooks.useReferenceElementWidth)(refs.reference?.current);
|
|
52
49
|
const onMenuToggle = isOpen => {
|
|
53
|
-
isOpen ? onMenuOpen
|
|
50
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
54
51
|
};
|
|
55
52
|
return /*#__PURE__*/React.createElement(_clickAway.ClickAway, {
|
|
56
53
|
onChange: onMenuToggle,
|
|
@@ -66,7 +63,7 @@ const InlineDropdown = exports.InlineDropdown = /*#__PURE__*/React.forwardRef((_
|
|
|
66
63
|
return /*#__PURE__*/React.createElement("div", {
|
|
67
64
|
"data-testid": "InlineDropdown",
|
|
68
65
|
className: (0, _classify.classify)(_InlineDropdownModule.default.inlineDropdownContainer, classNames?.dropdownContainer),
|
|
69
|
-
ref:
|
|
66
|
+
ref: menuBtnRef
|
|
70
67
|
}, /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({}, restButtonProps, {
|
|
71
68
|
disabled: disabled,
|
|
72
69
|
ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
@@ -84,27 +81,13 @@ const InlineDropdown = exports.InlineDropdown = /*#__PURE__*/React.forwardRef((_
|
|
|
84
81
|
className: (0, _classify.classify)({
|
|
85
82
|
[_InlineDropdownModule.default.disabled]: disabled
|
|
86
83
|
})
|
|
87
|
-
})), isOpen && menu && /*#__PURE__*/React.createElement(
|
|
88
|
-
modal: false,
|
|
89
|
-
context: context,
|
|
90
|
-
initialFocus: triggerRef
|
|
91
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className: _InlineDropdownModule.default.menuWrapper,
|
|
84
|
+
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
93
85
|
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
94
86
|
style: {
|
|
95
87
|
display: 'flex',
|
|
96
88
|
position: strategy,
|
|
97
89
|
top: y ?? _space.spaceNone,
|
|
98
|
-
left: x ?? _space.spaceNone
|
|
99
|
-
/* NOTE(Sharad): The FloatingPortal renders the menu outside the normal DOM structure,
|
|
100
|
-
so its parent is effectively the <body> element. This means the menu
|
|
101
|
-
would otherwise default to the body's width. To support fluid width,
|
|
102
|
-
we must manually set the dropdown width here; otherwise, it uses a fixed width.
|
|
103
|
-
Also, Only treat menu as non-fluid if isFluid is strictly false, since default is true in menu and undefined means fluid. */
|
|
104
|
-
...(menu.isFluid !== false && {
|
|
105
|
-
'--dropdown-width': dropdownWidth
|
|
106
|
-
}),
|
|
107
|
-
'--menu-elevation': (0, _Tooltip.getElevationValue)(elevation)
|
|
90
|
+
left: x ?? _space.spaceNone
|
|
108
91
|
}
|
|
109
92
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
110
93
|
onSelect: (option, e) => {
|
|
@@ -117,6 +100,6 @@ const InlineDropdown = exports.InlineDropdown = /*#__PURE__*/React.forwardRef((_
|
|
|
117
100
|
},
|
|
118
101
|
size: menu.size || 'medium',
|
|
119
102
|
onTabOut: clickAway
|
|
120
|
-
}))))
|
|
103
|
+
}))));
|
|
121
104
|
});
|
|
122
105
|
});
|
|
@@ -7,10 +7,6 @@ import {
|
|
|
7
7
|
// $FlowFixMe[untyped-import]
|
|
8
8
|
flip,
|
|
9
9
|
// $FlowFixMe[untyped-import]
|
|
10
|
-
FloatingFocusManager,
|
|
11
|
-
// $FlowFixMe[untyped-import]
|
|
12
|
-
FloatingPortal,
|
|
13
|
-
// $FlowFixMe[untyped-import]
|
|
14
10
|
offset,
|
|
15
11
|
// $FlowFixMe[untyped-import]
|
|
16
12
|
shift,
|
|
@@ -18,7 +14,6 @@ import {
|
|
|
18
14
|
useFloating,
|
|
19
15
|
} from '@floating-ui/react';
|
|
20
16
|
|
|
21
|
-
import {useReferenceElementWidth} from '../../hooks';
|
|
22
17
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
23
18
|
import {classify} from '../../utils/classify';
|
|
24
19
|
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
@@ -29,7 +24,6 @@ import type {AnchorType} from '../ButtonDropdown';
|
|
|
29
24
|
import {Icon} from '../Icon';
|
|
30
25
|
import type {MenuOption, MenuProps} from '../Menu';
|
|
31
26
|
import {Menu} from '../Menu';
|
|
32
|
-
import {type ElevationType, getElevationValue} from '../Tooltip';
|
|
33
27
|
import {Truncate} from '../Truncate';
|
|
34
28
|
|
|
35
29
|
import css from './InlineDropdown.module.css';
|
|
@@ -49,7 +43,6 @@ export type InlineDropdownProps = {
|
|
|
49
43
|
onMenuOpen?: () => mixed,
|
|
50
44
|
onMenuClose?: () => mixed,
|
|
51
45
|
size?: 'medium' | 'small' | 'extraSmall',
|
|
52
|
-
elevation?: ElevationType,
|
|
53
46
|
clickAwayRef?: ClickAwayRefType,
|
|
54
47
|
...
|
|
55
48
|
};
|
|
@@ -70,12 +63,13 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
70
63
|
onMenuClose,
|
|
71
64
|
children,
|
|
72
65
|
clickAwayRef,
|
|
73
|
-
elevation = 'modal',
|
|
74
66
|
...restButtonProps
|
|
75
67
|
}: InlineDropdownProps,
|
|
76
68
|
ref,
|
|
77
69
|
): React.Node => {
|
|
78
|
-
const
|
|
70
|
+
const menuBtnRef = React.useRef(null);
|
|
71
|
+
React.useImperativeHandle(ref, () => menuBtnRef.current);
|
|
72
|
+
const {x, y, refs, strategy} = useFloating({
|
|
79
73
|
open: true,
|
|
80
74
|
strategy: 'absolute',
|
|
81
75
|
placement: anchorPosition,
|
|
@@ -83,10 +77,8 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
83
77
|
middleware: [shift(), flip(), offset(parseInt(spaceXXSmall))],
|
|
84
78
|
});
|
|
85
79
|
|
|
86
|
-
const dropdownWidth = useReferenceElementWidth(refs.reference?.current);
|
|
87
|
-
|
|
88
80
|
const onMenuToggle = (isOpen: boolean) => {
|
|
89
|
-
isOpen ? onMenuOpen
|
|
81
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
90
82
|
};
|
|
91
83
|
|
|
92
84
|
return (
|
|
@@ -98,7 +90,7 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
98
90
|
css.inlineDropdownContainer,
|
|
99
91
|
classNames?.dropdownContainer,
|
|
100
92
|
)}
|
|
101
|
-
ref={
|
|
93
|
+
ref={menuBtnRef}
|
|
102
94
|
>
|
|
103
95
|
<UnstyledButton
|
|
104
96
|
{...restButtonProps}
|
|
@@ -128,50 +120,31 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
128
120
|
/>
|
|
129
121
|
</UnstyledButton>
|
|
130
122
|
{isOpen && menu && (
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<Menu
|
|
157
|
-
{...menu}
|
|
158
|
-
onSelect={(option, e) => {
|
|
159
|
-
onOptionSelect && onOptionSelect(option, e);
|
|
160
|
-
if (
|
|
161
|
-
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
162
|
-
!option.keepMenuOpenOnOptionSelect &&
|
|
163
|
-
(!menu.optionsVariant ||
|
|
164
|
-
menu.optionsVariant === 'normal')
|
|
165
|
-
) {
|
|
166
|
-
clickAway();
|
|
167
|
-
}
|
|
168
|
-
}}
|
|
169
|
-
size={menu.size || 'medium'}
|
|
170
|
-
onTabOut={clickAway}
|
|
171
|
-
/>
|
|
172
|
-
</div>
|
|
173
|
-
</FloatingFocusManager>
|
|
174
|
-
</FloatingPortal>
|
|
123
|
+
<div
|
|
124
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
125
|
+
style={{
|
|
126
|
+
display: 'flex',
|
|
127
|
+
position: strategy,
|
|
128
|
+
top: y ?? spaceNone,
|
|
129
|
+
left: x ?? spaceNone,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<Menu
|
|
133
|
+
{...menu}
|
|
134
|
+
onSelect={(option, e) => {
|
|
135
|
+
onOptionSelect && onOptionSelect(option, e);
|
|
136
|
+
if (
|
|
137
|
+
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
138
|
+
!option.keepMenuOpenOnOptionSelect &&
|
|
139
|
+
(!menu.optionsVariant || menu.optionsVariant === 'normal')
|
|
140
|
+
) {
|
|
141
|
+
clickAway();
|
|
142
|
+
}
|
|
143
|
+
}}
|
|
144
|
+
size={menu.size || 'medium'}
|
|
145
|
+
onTabOut={clickAway}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
175
148
|
)}
|
|
176
149
|
</div>
|
|
177
150
|
)}
|
|
@@ -32,7 +32,6 @@ const SimpleInlineDropdownBase = (props, ref) => {
|
|
|
32
32
|
showLabelTooltip,
|
|
33
33
|
clickAwayRef,
|
|
34
34
|
allowWrap = false,
|
|
35
|
-
elevation = 'modal',
|
|
36
35
|
...buttonProps
|
|
37
36
|
} = props;
|
|
38
37
|
const [btnText, setBtnText] = React.useState('');
|
|
@@ -68,7 +67,6 @@ const SimpleInlineDropdownBase = (props, ref) => {
|
|
|
68
67
|
onMenuOpen: onMenuOpen,
|
|
69
68
|
onMenuClose: onMenuClose,
|
|
70
69
|
clickAwayRef: clickAwayRef,
|
|
71
|
-
elevation: elevation,
|
|
72
70
|
menu: {
|
|
73
71
|
isFluid,
|
|
74
72
|
options,
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
import type {ButtonProps} from '../Button';
|
|
12
12
|
import type {AnchorType} from '../ButtonDropdown';
|
|
13
13
|
import type {MenuOption, MenuOptionsVariant, Virtualization} from '../Menu';
|
|
14
|
-
import type {ElevationType} from '../Tooltip';
|
|
15
14
|
|
|
16
15
|
import {InlineDropdown} from './InlineDropdown';
|
|
17
16
|
|
|
@@ -29,7 +28,6 @@ export type SimpleInlineDropdownProps = {
|
|
|
29
28
|
// Input props
|
|
30
29
|
...ButtonProps,
|
|
31
30
|
|
|
32
|
-
elevation?: ElevationType,
|
|
33
31
|
classNames?: ClassNames,
|
|
34
32
|
anchorPosition?: AnchorType,
|
|
35
33
|
|
|
@@ -81,7 +79,6 @@ const SimpleInlineDropdownBase = (props: SimpleInlineDropdownProps, ref) => {
|
|
|
81
79
|
showLabelTooltip,
|
|
82
80
|
clickAwayRef,
|
|
83
81
|
allowWrap = false,
|
|
84
|
-
elevation = 'modal',
|
|
85
82
|
...buttonProps
|
|
86
83
|
} = props;
|
|
87
84
|
|
|
@@ -136,7 +133,6 @@ const SimpleInlineDropdownBase = (props: SimpleInlineDropdownProps, ref) => {
|
|
|
136
133
|
onMenuOpen={onMenuOpen}
|
|
137
134
|
onMenuClose={onMenuClose}
|
|
138
135
|
clickAwayRef={clickAwayRef}
|
|
139
|
-
elevation={elevation}
|
|
140
136
|
menu={{
|
|
141
137
|
isFluid,
|
|
142
138
|
options,
|
|
@@ -74,7 +74,7 @@ function StaticTable(props) {
|
|
|
74
74
|
}, [width]);
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* this function is also used to decide weather to show checkbox in header or not. so it's value is undefined
|
|
77
|
+
* this function is also used to decide weather to show checkbox in header or not. so it's value is undefined incase selectedKeys is not there.
|
|
78
78
|
*/
|
|
79
79
|
|
|
80
80
|
const handleHeaderCheckboxClick = selectedKeys ? ({
|
|
@@ -89,7 +89,7 @@ export function StaticTable<Data: GenericObject, Extras: GenericObject>(props: {
|
|
|
89
89
|
}, [width]);
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* this function is also used to decide weather to show checkbox in header or not. so it's value is undefined
|
|
92
|
+
* this function is also used to decide weather to show checkbox in header or not. so it's value is undefined incase selectedKeys is not there.
|
|
93
93
|
*/
|
|
94
94
|
|
|
95
95
|
const handleHeaderCheckboxClick = selectedKeys
|
|
@@ -104,7 +104,7 @@ const TABLE_DOCS = exports.TABLE_DOCS = {
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
selectedKeys: {
|
|
107
|
-
description: 'array of keys which are selected. This prop is also used to decide weather to show checkboxes or not. So, pass an empty array
|
|
107
|
+
description: 'array of keys which are selected. This prop is also used to decide weather to show checkboxes or not. So, pass an empty array incase no row is selected.',
|
|
108
108
|
control: {
|
|
109
109
|
type: 'object'
|
|
110
110
|
},
|
|
@@ -89,7 +89,7 @@ export const TABLE_DOCS = {
|
|
|
89
89
|
},
|
|
90
90
|
selectedKeys: {
|
|
91
91
|
description:
|
|
92
|
-
'array of keys which are selected. This prop is also used to decide weather to show checkboxes or not. So, pass an empty array
|
|
92
|
+
'array of keys which are selected. This prop is also used to decide weather to show checkboxes or not. So, pass an empty array incase no row is selected.',
|
|
93
93
|
control: {
|
|
94
94
|
type: 'object',
|
|
95
95
|
},
|