@spaced-out/ui-design-system 0.3.47-beta.0 → 0.3.48
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 +1 -0
- package/CHANGELOG.md +14 -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/SideMenuLink/SideMenuLink.js +5 -0
- package/lib/components/SideMenuLink/SideMenuLink.js.flow +5 -0
- 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
|
@@ -6,14 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Typeahead = 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 _Menu = require("../Menu");
|
|
15
15
|
var _SearchInput = require("../SearchInput");
|
|
16
|
-
var _Tooltip = require("../Tooltip");
|
|
17
16
|
var _TypeaheadModule = _interopRequireDefault(require("./Typeahead.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); }
|
|
@@ -34,7 +33,6 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
34
33
|
menuOpenOffset = 1,
|
|
35
34
|
onFocus,
|
|
36
35
|
clickAwayRef,
|
|
37
|
-
elevation = 'modal',
|
|
38
36
|
...inputProps
|
|
39
37
|
} = _ref;
|
|
40
38
|
const menuOptions = menu?.options;
|
|
@@ -42,8 +40,7 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
42
40
|
x,
|
|
43
41
|
y,
|
|
44
42
|
refs,
|
|
45
|
-
strategy
|
|
46
|
-
context
|
|
43
|
+
strategy
|
|
47
44
|
} = (0, _react2.useFloating)({
|
|
48
45
|
open: true,
|
|
49
46
|
strategy: 'absolute',
|
|
@@ -51,7 +48,6 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
51
48
|
whileElementsMounted: _react2.autoUpdate,
|
|
52
49
|
middleware: [(0, _react2.flip)(), (0, _react2.offset)(parseInt(_space.spaceXXSmall))]
|
|
53
50
|
});
|
|
54
|
-
const dropdownWidth = (0, _hooks.useReferenceElementWidth)(refs.reference?.current);
|
|
55
51
|
const onMenuToggle = isOpen => {
|
|
56
52
|
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
57
53
|
};
|
|
@@ -68,7 +64,8 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
68
64
|
} = _ref2;
|
|
69
65
|
return /*#__PURE__*/React.createElement("div", {
|
|
70
66
|
"data-testid": "Typeahead",
|
|
71
|
-
className: (0, _classify.classify)(_TypeaheadModule.default.typeaheadContainer, classNames?.wrapper)
|
|
67
|
+
className: (0, _classify.classify)(_TypeaheadModule.default.typeaheadContainer, classNames?.wrapper),
|
|
68
|
+
ref: boundaryRef
|
|
72
69
|
}, /*#__PURE__*/React.createElement(_SearchInput.SearchInput, _extends({}, inputProps, {
|
|
73
70
|
ref: ref,
|
|
74
71
|
boxRef: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
@@ -99,27 +96,13 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
99
96
|
onClear: _e => {
|
|
100
97
|
onClear?.();
|
|
101
98
|
}
|
|
102
|
-
})), isOpen && !isLoading && menu && menuOptions && !!menuOptions.length && /*#__PURE__*/React.createElement(
|
|
103
|
-
|
|
104
|
-
context: context,
|
|
105
|
-
returnFocus: false,
|
|
106
|
-
initialFocus: refs.reference
|
|
107
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
108
|
-
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
109
|
-
className: _TypeaheadModule.default.menuWrapper,
|
|
99
|
+
})), isOpen && !isLoading && menu && menuOptions && !!menuOptions.length && /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
ref: refs.setFloating,
|
|
110
101
|
style: {
|
|
111
102
|
position: strategy,
|
|
112
103
|
top: y ?? _space.spaceNone,
|
|
113
104
|
left: x ?? _space.spaceNone,
|
|
114
|
-
|
|
115
|
-
so its parent is effectively the <body> element. This means the menu
|
|
116
|
-
would otherwise default to the body's width. To support fluid width,
|
|
117
|
-
we must manually set the dropdown width here; otherwise, it uses a fixed width.
|
|
118
|
-
Also, Only treat menu as non-fluid if isFluid is strictly false, since default is true in menu and undefined means fluid. */
|
|
119
|
-
...(menu.isFluid !== false && {
|
|
120
|
-
'--dropdown-width': dropdownWidth
|
|
121
|
-
}),
|
|
122
|
-
'--menu-elevation': (0, _Tooltip.getElevationValue)(elevation)
|
|
105
|
+
width: _size.sizeFluid
|
|
123
106
|
}
|
|
124
107
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({}, menu, {
|
|
125
108
|
options: menuOptions,
|
|
@@ -133,7 +116,7 @@ const BaseTypeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
133
116
|
},
|
|
134
117
|
size: menu.size || size,
|
|
135
118
|
onTabOut: clickAway
|
|
136
|
-
}))))
|
|
119
|
+
}))));
|
|
137
120
|
});
|
|
138
121
|
});
|
|
139
122
|
const StatefulTypeahead = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
@@ -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,8 +21,6 @@ import type {InputProps} from '../Input';
|
|
|
25
21
|
import type {MenuOption, MenuProps} from '../Menu';
|
|
26
22
|
import {Menu} from '../Menu';
|
|
27
23
|
import {SearchInput} from '../SearchInput';
|
|
28
|
-
import type {ElevationType} from '../Tooltip';
|
|
29
|
-
import {getElevationValue} from '../Tooltip';
|
|
30
24
|
|
|
31
25
|
import css from './Typeahead.module.css';
|
|
32
26
|
|
|
@@ -46,7 +40,6 @@ type BaseTypeaheadProps = {
|
|
|
46
40
|
isLoading?: boolean,
|
|
47
41
|
menuOpenOffset?: number,
|
|
48
42
|
clickAwayRef?: ClickAwayRefType,
|
|
49
|
-
elevation?: ElevationType,
|
|
50
43
|
...
|
|
51
44
|
};
|
|
52
45
|
|
|
@@ -76,14 +69,12 @@ const BaseTypeahead: React$AbstractComponent<
|
|
|
76
69
|
menuOpenOffset = 1,
|
|
77
70
|
onFocus,
|
|
78
71
|
clickAwayRef,
|
|
79
|
-
elevation = 'modal',
|
|
80
72
|
...inputProps
|
|
81
73
|
}: BaseTypeaheadProps,
|
|
82
74
|
ref,
|
|
83
75
|
): React.Node => {
|
|
84
76
|
const menuOptions = menu?.options;
|
|
85
|
-
|
|
86
|
-
const {x, y, refs, strategy, context} = useFloating({
|
|
77
|
+
const {x, y, refs, strategy} = useFloating({
|
|
87
78
|
open: true,
|
|
88
79
|
strategy: 'absolute',
|
|
89
80
|
placement: 'bottom-start',
|
|
@@ -91,8 +82,6 @@ const BaseTypeahead: React$AbstractComponent<
|
|
|
91
82
|
middleware: [flip(), offset(parseInt(spaceXXSmall))],
|
|
92
83
|
});
|
|
93
84
|
|
|
94
|
-
const dropdownWidth = useReferenceElementWidth(refs.reference?.current);
|
|
95
|
-
|
|
96
85
|
const onMenuToggle = (isOpen: boolean) => {
|
|
97
86
|
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
98
87
|
};
|
|
@@ -103,6 +92,7 @@ const BaseTypeahead: React$AbstractComponent<
|
|
|
103
92
|
<div
|
|
104
93
|
data-testid="Typeahead"
|
|
105
94
|
className={classify(css.typeaheadContainer, classNames?.wrapper)}
|
|
95
|
+
ref={boundaryRef}
|
|
106
96
|
>
|
|
107
97
|
<SearchInput
|
|
108
98
|
{...inputProps}
|
|
@@ -139,51 +129,33 @@ const BaseTypeahead: React$AbstractComponent<
|
|
|
139
129
|
menu &&
|
|
140
130
|
menuOptions &&
|
|
141
131
|
!!menuOptions.length && (
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
options={menuOptions}
|
|
170
|
-
onSelect={(option, e) => {
|
|
171
|
-
onSelect && onSelect(option, e);
|
|
172
|
-
if (
|
|
173
|
-
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
174
|
-
!option.keepMenuOpenOnOptionSelect &&
|
|
175
|
-
(!menu.optionsVariant ||
|
|
176
|
-
menu.optionsVariant === 'normal')
|
|
177
|
-
) {
|
|
178
|
-
clickAway();
|
|
179
|
-
}
|
|
180
|
-
}}
|
|
181
|
-
size={menu.size || size}
|
|
182
|
-
onTabOut={clickAway}
|
|
183
|
-
/>
|
|
184
|
-
</div>
|
|
185
|
-
</FloatingFocusManager>
|
|
186
|
-
</FloatingPortal>
|
|
132
|
+
<div
|
|
133
|
+
ref={refs.setFloating}
|
|
134
|
+
style={{
|
|
135
|
+
position: strategy,
|
|
136
|
+
top: y ?? spaceNone,
|
|
137
|
+
left: x ?? spaceNone,
|
|
138
|
+
width: sizeFluid,
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<Menu
|
|
142
|
+
{...menu}
|
|
143
|
+
options={menuOptions}
|
|
144
|
+
onSelect={(option, e) => {
|
|
145
|
+
onSelect && onSelect(option, e);
|
|
146
|
+
if (
|
|
147
|
+
// option.keepMenuOpenOnOptionSelect - to allow the menu persist its open stat upon option selection in normal variant
|
|
148
|
+
!option.keepMenuOpenOnOptionSelect &&
|
|
149
|
+
(!menu.optionsVariant ||
|
|
150
|
+
menu.optionsVariant === 'normal')
|
|
151
|
+
) {
|
|
152
|
+
clickAway();
|
|
153
|
+
}
|
|
154
|
+
}}
|
|
155
|
+
size={menu.size || size}
|
|
156
|
+
onTabOut={clickAway}
|
|
157
|
+
/>
|
|
158
|
+
</div>
|
|
187
159
|
)}
|
|
188
160
|
</div>
|
|
189
161
|
)}
|
package/lib/hooks/index.js
CHANGED
|
@@ -124,17 +124,6 @@ Object.keys(_usePagination).forEach(function (key) {
|
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
var _useReferenceElementWidth = require("./useReferenceElementWidth");
|
|
128
|
-
Object.keys(_useReferenceElementWidth).forEach(function (key) {
|
|
129
|
-
if (key === "default" || key === "__esModule") return;
|
|
130
|
-
if (key in exports && exports[key] === _useReferenceElementWidth[key]) return;
|
|
131
|
-
Object.defineProperty(exports, key, {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
get: function () {
|
|
134
|
-
return _useReferenceElementWidth[key];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
127
|
var _useResizeObserver = require("./useResizeObserver");
|
|
139
128
|
Object.keys(_useResizeObserver).forEach(function (key) {
|
|
140
129
|
if (key === "default" || key === "__esModule") return;
|
package/lib/hooks/index.js.flow
CHANGED
|
@@ -11,7 +11,6 @@ export * from './useLockedBody';
|
|
|
11
11
|
export * from './useModal';
|
|
12
12
|
export * from './useMountTransition';
|
|
13
13
|
export * from './usePagination';
|
|
14
|
-
export * from './useReferenceElementWidth';
|
|
15
14
|
export * from './useResizeObserver';
|
|
16
15
|
export * from './useToastPortal';
|
|
17
16
|
export * from './useToggle';
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _useReferenceElementWidth = require("./useReferenceElementWidth");
|
|
7
|
-
Object.keys(_useReferenceElementWidth).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _useReferenceElementWidth[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _useReferenceElementWidth[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useReferenceElementWidth = useReferenceElementWidth;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _size = require("../../styles/variables/_size");
|
|
9
|
-
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); }
|
|
10
|
-
const MIN_FLUID_WIDTH = 160;
|
|
11
|
-
function useReferenceElementWidth(ref) {
|
|
12
|
-
let minWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MIN_FLUID_WIDTH;
|
|
13
|
-
const [width, setWidth] = React.useState(_size.sizeFluid);
|
|
14
|
-
const refWidth = ref?.offsetWidth;
|
|
15
|
-
React.useLayoutEffect(() => {
|
|
16
|
-
if (refWidth) {
|
|
17
|
-
setWidth(Math.max(refWidth, minWidth) + 'px');
|
|
18
|
-
}
|
|
19
|
-
}, [refWidth, minWidth]);
|
|
20
|
-
return width;
|
|
21
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
import {sizeFluid} from '../../styles/variables/_size';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const MIN_FLUID_WIDTH = 160;
|
|
8
|
-
|
|
9
|
-
export function useReferenceElementWidth(
|
|
10
|
-
ref: ?HTMLElement,
|
|
11
|
-
minWidth: number = MIN_FLUID_WIDTH,
|
|
12
|
-
): string {
|
|
13
|
-
const [width, setWidth] = React.useState(sizeFluid);
|
|
14
|
-
|
|
15
|
-
const refWidth = ref?.offsetWidth;
|
|
16
|
-
React.useLayoutEffect(() => {
|
|
17
|
-
if (refWidth) {
|
|
18
|
-
setWidth(Math.max(refWidth, minWidth) + 'px');
|
|
19
|
-
}
|
|
20
|
-
}, [refWidth, minWidth]);
|
|
21
|
-
|
|
22
|
-
return width;
|
|
23
|
-
}
|