@spaced-out/ui-design-system 0.1.126 → 0.1.127-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 +7 -0
- package/lib/components/ButtonDropdown/ButtonDropdown.js +6 -5
- package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +4 -4
- package/lib/components/ButtonTabs/ButtonTabDropdown.js +6 -5
- package/lib/components/ButtonTabs/ButtonTabDropdown.js.flow +4 -4
- package/lib/components/Dropdown/Dropdown.js +7 -6
- package/lib/components/Dropdown/Dropdown.js.flow +5 -5
- package/lib/components/InlineDropdown/InlineDropdown.js +6 -5
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +4 -4
- package/lib/components/Tabs/TabList/TabDropdown.js +6 -5
- package/lib/components/Tabs/TabList/TabDropdown.js.flow +4 -4
- package/lib/components/Typeahead/Typeahead.js +3 -4
- package/lib/components/Typeahead/Typeahead.js.flow +2 -3
- package/lib/utils/click-away/click-away.js +21 -18
- package/lib/utils/click-away/click-away.js.flow +44 -25
- package/lib/utils/merge-refs/merge-refs.js.flow +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.1.127-beta.0](https://github.com/spaced-out/ui-design-system/compare/v0.1.126...v0.1.127-beta.0) (2024-08-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* react 17 upgrade and click away changes to support the upgrade ([#249](https://github.com/spaced-out/ui-design-system/issues/249)) ([fcc75c4](https://github.com/spaced-out/ui-design-system/commit/fcc75c41d856b1c00f5b18d83ecc2956e047050c))
|
|
11
|
+
|
|
5
12
|
### [0.1.126](https://github.com/spaced-out/ui-design-system/compare/v0.1.125...v0.1.126) (2024-08-30)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -10,6 +10,7 @@ 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
|
+
var _mergeRefs = require("../../utils/merge-refs");
|
|
13
14
|
var _Button = require("../Button");
|
|
14
15
|
var _ConditionalWrapper = require("../ConditionalWrapper");
|
|
15
16
|
var _Menu = require("../Menu");
|
|
@@ -84,8 +85,9 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
84
85
|
let {
|
|
85
86
|
isOpen,
|
|
86
87
|
onOpen,
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
clickAway,
|
|
89
|
+
boundaryRef,
|
|
90
|
+
triggerRef
|
|
89
91
|
} = _ref2;
|
|
90
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
91
93
|
"data-testid": "ButtonDropdown",
|
|
@@ -103,7 +105,7 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
103
105
|
iconRightType: iconRightType,
|
|
104
106
|
disabled: disabled,
|
|
105
107
|
size: size,
|
|
106
|
-
ref: refs.setReference,
|
|
108
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
107
109
|
onClick: e => {
|
|
108
110
|
onClick?.(e);
|
|
109
111
|
e.stopPropagation();
|
|
@@ -115,8 +117,7 @@ const ButtonDropdown = /*#__PURE__*/React.forwardRef((_ref, forwardRef) => {
|
|
|
115
117
|
icon: classNames?.buttonIcon
|
|
116
118
|
}
|
|
117
119
|
}), children)), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
118
|
-
|
|
119
|
-
ref: refs.setFloating,
|
|
120
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
120
121
|
style: {
|
|
121
122
|
display: 'flex',
|
|
122
123
|
position: strategy,
|
|
@@ -18,6 +18,7 @@ import {sizeFluid} from '../../styles/variables/_size';
|
|
|
18
18
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
19
19
|
import {classify} from '../../utils/classify';
|
|
20
20
|
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
21
|
+
import {mergeRefs} from '../../utils/merge-refs';
|
|
21
22
|
import type {ButtonProps} from '../Button';
|
|
22
23
|
import {Button} from '../Button';
|
|
23
24
|
import {ConditionalWrapper} from '../ConditionalWrapper';
|
|
@@ -115,7 +116,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
115
116
|
|
|
116
117
|
return (
|
|
117
118
|
<ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
|
|
118
|
-
{({isOpen, onOpen,
|
|
119
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
119
120
|
<div
|
|
120
121
|
data-testid="ButtonDropdown"
|
|
121
122
|
className={classify(
|
|
@@ -148,7 +149,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
148
149
|
iconRightType={iconRightType}
|
|
149
150
|
disabled={disabled}
|
|
150
151
|
size={size}
|
|
151
|
-
ref={refs.setReference}
|
|
152
|
+
ref={mergeRefs([refs.setReference, triggerRef])}
|
|
152
153
|
onClick={(e) => {
|
|
153
154
|
onClick?.(e);
|
|
154
155
|
e.stopPropagation();
|
|
@@ -166,8 +167,7 @@ export const ButtonDropdown: React$AbstractComponent<
|
|
|
166
167
|
|
|
167
168
|
{isOpen && menu && (
|
|
168
169
|
<div
|
|
169
|
-
|
|
170
|
-
ref={refs.setFloating}
|
|
170
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
171
171
|
style={{
|
|
172
172
|
display: 'flex',
|
|
173
173
|
position: strategy,
|
|
@@ -9,6 +9,7 @@ var _react2 = require("@floating-ui/react");
|
|
|
9
9
|
var _lodash = require("lodash");
|
|
10
10
|
var _space = require("../../styles/variables/_space");
|
|
11
11
|
var _clickAway = require("../../utils/click-away");
|
|
12
|
+
var _mergeRefs = require("../../utils/merge-refs");
|
|
12
13
|
var _Menu = require("../Menu");
|
|
13
14
|
var _ButtonTab = require("./ButtonTab");
|
|
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); }
|
|
@@ -71,22 +72,22 @@ const ButtonTabDropdown = _ref => {
|
|
|
71
72
|
let {
|
|
72
73
|
isOpen,
|
|
73
74
|
onOpen,
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
clickAway,
|
|
76
|
+
boundaryRef,
|
|
77
|
+
triggerRef
|
|
76
78
|
} = _ref3;
|
|
77
79
|
return /*#__PURE__*/React.createElement("div", {
|
|
78
80
|
"data-testid": "ButtonTabDropdown",
|
|
79
81
|
ref: menuBtnRef
|
|
80
82
|
}, /*#__PURE__*/React.createElement(_ButtonTab.ButtonTab, _extends({}, buttonTabProps, {
|
|
81
|
-
ref: refs.setReference,
|
|
83
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
82
84
|
selectedButtonTabId: moreTabSelectedId,
|
|
83
85
|
onButtonTabSelect: (id, e) => {
|
|
84
86
|
e?.stopPropagation();
|
|
85
87
|
onOpen();
|
|
86
88
|
}
|
|
87
89
|
}), title), isOpen && /*#__PURE__*/React.createElement("div", {
|
|
88
|
-
|
|
89
|
-
ref: refs.setFloating,
|
|
90
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
90
91
|
style: {
|
|
91
92
|
display: 'flex',
|
|
92
93
|
position: strategy,
|
|
@@ -17,6 +17,7 @@ import {includes} from 'lodash';
|
|
|
17
17
|
|
|
18
18
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
19
19
|
import {ClickAway} from '../../utils/click-away';
|
|
20
|
+
import {mergeRefs} from '../../utils/merge-refs';
|
|
20
21
|
import type {AnchorType} from '../ButtonDropdown';
|
|
21
22
|
import {Menu} from '../Menu';
|
|
22
23
|
|
|
@@ -82,11 +83,11 @@ export const ButtonTabDropdown = ({
|
|
|
82
83
|
|
|
83
84
|
return (
|
|
84
85
|
<ClickAway>
|
|
85
|
-
{({isOpen, onOpen,
|
|
86
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
86
87
|
<div data-testid="ButtonTabDropdown" ref={menuBtnRef}>
|
|
87
88
|
<ButtonTab
|
|
88
89
|
{...buttonTabProps}
|
|
89
|
-
ref={refs.setReference}
|
|
90
|
+
ref={mergeRefs([refs.setReference, triggerRef])}
|
|
90
91
|
selectedButtonTabId={moreTabSelectedId}
|
|
91
92
|
onButtonTabSelect={(id, e) => {
|
|
92
93
|
e?.stopPropagation();
|
|
@@ -97,8 +98,7 @@ export const ButtonTabDropdown = ({
|
|
|
97
98
|
</ButtonTab>
|
|
98
99
|
{isOpen && (
|
|
99
100
|
<div
|
|
100
|
-
|
|
101
|
-
ref={refs.setFloating}
|
|
101
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
102
102
|
style={{
|
|
103
103
|
display: 'flex',
|
|
104
104
|
position: strategy,
|
|
@@ -10,6 +10,7 @@ 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
|
+
var _mergeRefs = require("../../utils/merge-refs");
|
|
13
14
|
var _Input = require("../Input");
|
|
14
15
|
var _Menu = require("../Menu");
|
|
15
16
|
var _DropdownModule = _interopRequireDefault(require("./Dropdown.module.css"));
|
|
@@ -58,13 +59,14 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
58
59
|
let {
|
|
59
60
|
isOpen,
|
|
60
61
|
onOpen,
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
clickAway,
|
|
63
|
+
boundaryRef,
|
|
64
|
+
triggerRef
|
|
63
65
|
} = _ref2;
|
|
64
66
|
return /*#__PURE__*/React.createElement("div", {
|
|
65
67
|
"data-testid": "Dropdown",
|
|
66
68
|
className: (0, _classify.classify)(_DropdownModule.default.dropdownContainer, classNames?.wrapper),
|
|
67
|
-
ref: dropdownRef
|
|
69
|
+
ref: (0, _mergeRefs.mergeRefs)([dropdownRef, boundaryRef])
|
|
68
70
|
}, /*#__PURE__*/React.createElement(_Input.Input, _extends({}, inputProps, {
|
|
69
71
|
onKeyDown: e => {
|
|
70
72
|
if (e.keyCode === 32) {
|
|
@@ -72,7 +74,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
72
74
|
isOpen ? clickAway() : onOpen();
|
|
73
75
|
}
|
|
74
76
|
},
|
|
75
|
-
boxRef: refs.setReference,
|
|
77
|
+
boxRef: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
76
78
|
size: size,
|
|
77
79
|
placeholder: placeholder,
|
|
78
80
|
value: dropdownInputText,
|
|
@@ -87,8 +89,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
87
89
|
},
|
|
88
90
|
ref: ref
|
|
89
91
|
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
|
|
91
|
-
ref: refs.setFloating,
|
|
92
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
92
93
|
style: {
|
|
93
94
|
position: strategy,
|
|
94
95
|
top: y ?? _space.spaceNone,
|
|
@@ -16,6 +16,7 @@ import {sizeFluid} from '../../styles/variables/_size';
|
|
|
16
16
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
17
17
|
import {classify} from '../../utils/classify';
|
|
18
18
|
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
19
|
+
import {mergeRefs} from '../../utils/merge-refs';
|
|
19
20
|
import type {InputProps} from '../Input';
|
|
20
21
|
import {Input} from '../Input';
|
|
21
22
|
import type {MenuOption, MenuProps} from '../Menu';
|
|
@@ -78,11 +79,11 @@ export const Dropdown: React$AbstractComponent<
|
|
|
78
79
|
|
|
79
80
|
return (
|
|
80
81
|
<ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
|
|
81
|
-
{({isOpen, onOpen,
|
|
82
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
82
83
|
<div
|
|
83
84
|
data-testid="Dropdown"
|
|
84
85
|
className={classify(css.dropdownContainer, classNames?.wrapper)}
|
|
85
|
-
ref={dropdownRef}
|
|
86
|
+
ref={mergeRefs([dropdownRef, boundaryRef])}
|
|
86
87
|
>
|
|
87
88
|
<Input
|
|
88
89
|
{...inputProps}
|
|
@@ -92,7 +93,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
92
93
|
isOpen ? clickAway() : onOpen();
|
|
93
94
|
}
|
|
94
95
|
}}
|
|
95
|
-
boxRef={refs.setReference}
|
|
96
|
+
boxRef={mergeRefs([refs.setReference, triggerRef])}
|
|
96
97
|
size={size}
|
|
97
98
|
placeholder={placeholder}
|
|
98
99
|
value={dropdownInputText}
|
|
@@ -108,8 +109,7 @@ export const Dropdown: React$AbstractComponent<
|
|
|
108
109
|
|
|
109
110
|
{isOpen && menu && (
|
|
110
111
|
<div
|
|
111
|
-
|
|
112
|
-
ref={refs.setFloating}
|
|
112
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
113
113
|
style={{
|
|
114
114
|
position: strategy,
|
|
115
115
|
top: y ?? spaceNone,
|
|
@@ -9,6 +9,7 @@ var _react2 = require("@floating-ui/react");
|
|
|
9
9
|
var _space = require("../../styles/variables/_space");
|
|
10
10
|
var _classify = require("../../utils/classify");
|
|
11
11
|
var _clickAway = require("../../utils/click-away");
|
|
12
|
+
var _mergeRefs = require("../../utils/merge-refs");
|
|
12
13
|
var _Button = require("../Button");
|
|
13
14
|
var _Icon = require("../Icon");
|
|
14
15
|
var _Menu = require("../Menu");
|
|
@@ -56,8 +57,9 @@ const InlineDropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
56
57
|
let {
|
|
57
58
|
isOpen,
|
|
58
59
|
onOpen,
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
clickAway,
|
|
61
|
+
boundaryRef,
|
|
62
|
+
triggerRef
|
|
61
63
|
} = _ref2;
|
|
62
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
63
65
|
"data-testid": "InlineDropdown",
|
|
@@ -65,7 +67,7 @@ const InlineDropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
65
67
|
ref: menuBtnRef
|
|
66
68
|
}, /*#__PURE__*/React.createElement(_Button.UnstyledButton, _extends({}, restButtonProps, {
|
|
67
69
|
disabled: disabled,
|
|
68
|
-
ref: refs.setReference,
|
|
70
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
69
71
|
onClick: e => {
|
|
70
72
|
e.stopPropagation();
|
|
71
73
|
onOpen();
|
|
@@ -81,8 +83,7 @@ const InlineDropdown = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
81
83
|
[_InlineDropdownModule.default.disabled]: disabled
|
|
82
84
|
})
|
|
83
85
|
})), isOpen && menu && /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
|
|
85
|
-
ref: refs.setFloating,
|
|
86
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
86
87
|
style: {
|
|
87
88
|
display: 'flex',
|
|
88
89
|
position: strategy,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
|
|
18
18
|
import {classify} from '../../utils/classify';
|
|
19
19
|
import {type ClickAwayRefType, ClickAway} from '../../utils/click-away';
|
|
20
|
+
import {mergeRefs} from '../../utils/merge-refs';
|
|
20
21
|
import type {UnstyledButtonProps} from '../Button';
|
|
21
22
|
import {UnstyledButton} from '../Button';
|
|
22
23
|
import type {AnchorType} from '../ButtonDropdown';
|
|
@@ -82,7 +83,7 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
82
83
|
|
|
83
84
|
return (
|
|
84
85
|
<ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
|
|
85
|
-
{({isOpen, onOpen,
|
|
86
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
86
87
|
<div
|
|
87
88
|
data-testid="InlineDropdown"
|
|
88
89
|
className={classify(
|
|
@@ -94,7 +95,7 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
94
95
|
<UnstyledButton
|
|
95
96
|
{...restButtonProps}
|
|
96
97
|
disabled={disabled}
|
|
97
|
-
ref={refs.setReference}
|
|
98
|
+
ref={mergeRefs([refs.setReference, triggerRef])}
|
|
98
99
|
onClick={(e) => {
|
|
99
100
|
e.stopPropagation();
|
|
100
101
|
onOpen();
|
|
@@ -120,8 +121,7 @@ export const InlineDropdown: React$AbstractComponent<
|
|
|
120
121
|
</UnstyledButton>
|
|
121
122
|
{isOpen && menu && (
|
|
122
123
|
<div
|
|
123
|
-
|
|
124
|
-
ref={refs.setFloating}
|
|
124
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
125
125
|
style={{
|
|
126
126
|
display: 'flex',
|
|
127
127
|
position: strategy,
|
|
@@ -9,6 +9,7 @@ var _react2 = require("@floating-ui/react");
|
|
|
9
9
|
var _space = require("../../../styles/variables/_space");
|
|
10
10
|
var _classify = require("../../../utils/classify");
|
|
11
11
|
var _clickAway = require("../../../utils/click-away");
|
|
12
|
+
var _mergeRefs = require("../../../utils/merge-refs");
|
|
12
13
|
var _Menu = require("../../Menu");
|
|
13
14
|
var _Tab = require("../Tab");
|
|
14
15
|
var _TabDropdownModule = _interopRequireDefault(require("./TabDropdown.module.css"));
|
|
@@ -41,8 +42,9 @@ const TabDropdown = _ref => {
|
|
|
41
42
|
let {
|
|
42
43
|
isOpen,
|
|
43
44
|
onOpen,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
clickAway,
|
|
46
|
+
boundaryRef,
|
|
47
|
+
triggerRef
|
|
46
48
|
} = _ref2;
|
|
47
49
|
return /*#__PURE__*/React.createElement("div", {
|
|
48
50
|
"data-testid": "TabDropdown",
|
|
@@ -50,7 +52,7 @@ const TabDropdown = _ref => {
|
|
|
50
52
|
ref: menuBtnRef
|
|
51
53
|
}, /*#__PURE__*/React.createElement(_Tab.Tab, _extends({}, props?.tab, {
|
|
52
54
|
size: size,
|
|
53
|
-
ref: refs.setReference,
|
|
55
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setReference, triggerRef]),
|
|
54
56
|
onClick: e => {
|
|
55
57
|
e.stopPropagation();
|
|
56
58
|
onOpen();
|
|
@@ -60,8 +62,7 @@ const TabDropdown = _ref => {
|
|
|
60
62
|
iconTextWrap: _TabDropdownModule.default.dotTextWrap
|
|
61
63
|
}
|
|
62
64
|
})), isOpen && props?.menu && /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
|
|
64
|
-
ref: refs.setFloating,
|
|
65
|
+
ref: (0, _mergeRefs.mergeRefs)([refs.setFloating, boundaryRef]),
|
|
65
66
|
style: {
|
|
66
67
|
display: 'flex',
|
|
67
68
|
position: strategy,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import {spaceNone, spaceXXSmall} from '../../../styles/variables/_space';
|
|
18
18
|
import {classify} from '../../../utils/classify';
|
|
19
19
|
import {ClickAway} from '../../../utils/click-away';
|
|
20
|
+
import {mergeRefs} from '../../../utils/merge-refs';
|
|
20
21
|
import type {AnchorType} from '../../ButtonDropdown';
|
|
21
22
|
import type {MenuOption, MenuProps} from '../../Menu';
|
|
22
23
|
import {Menu} from '../../Menu';
|
|
@@ -59,7 +60,7 @@ export const TabDropdown = ({
|
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
62
|
<ClickAway>
|
|
62
|
-
{({isOpen, onOpen,
|
|
63
|
+
{({isOpen, onOpen, clickAway, boundaryRef, triggerRef}) => (
|
|
63
64
|
<div
|
|
64
65
|
data-testid="TabDropdown"
|
|
65
66
|
className={classify(css.tabDropdownContainer, classNames?.wrapper)}
|
|
@@ -68,7 +69,7 @@ export const TabDropdown = ({
|
|
|
68
69
|
<Tab
|
|
69
70
|
{...props?.tab}
|
|
70
71
|
size={size}
|
|
71
|
-
ref={refs.setReference}
|
|
72
|
+
ref={mergeRefs([refs.setReference, triggerRef])}
|
|
72
73
|
onClick={(e) => {
|
|
73
74
|
e.stopPropagation();
|
|
74
75
|
onOpen();
|
|
@@ -80,8 +81,7 @@ export const TabDropdown = ({
|
|
|
80
81
|
/>
|
|
81
82
|
{isOpen && props?.menu && (
|
|
82
83
|
<div
|
|
83
|
-
|
|
84
|
-
ref={refs.setFloating}
|
|
84
|
+
ref={mergeRefs([refs.setFloating, boundaryRef])}
|
|
85
85
|
style={{
|
|
86
86
|
display: 'flex',
|
|
87
87
|
position: strategy,
|
|
@@ -68,13 +68,13 @@ const Typeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
68
68
|
let {
|
|
69
69
|
isOpen,
|
|
70
70
|
onOpen,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
clickAway,
|
|
72
|
+
boundaryRef
|
|
73
73
|
} = _ref2;
|
|
74
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
75
75
|
"data-testid": "Typeahead",
|
|
76
76
|
className: (0, _classify.classify)(_TypeaheadModule.default.typeaheadContainer, classNames?.wrapper),
|
|
77
|
-
|
|
77
|
+
ref: boundaryRef
|
|
78
78
|
}, /*#__PURE__*/React.createElement(_SearchInput.SearchInput, _extends({}, inputProps, {
|
|
79
79
|
ref: ref,
|
|
80
80
|
boxRef: refs.setReference,
|
|
@@ -106,7 +106,6 @@ const Typeahead = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
106
106
|
onClear?.();
|
|
107
107
|
}
|
|
108
108
|
})), isOpen && !isLoading && menu && filteredOptions && !!filteredOptions.length && /*#__PURE__*/React.createElement("div", {
|
|
109
|
-
onClickCapture: cancelNext,
|
|
110
109
|
ref: refs.setFloating,
|
|
111
110
|
style: {
|
|
112
111
|
position: strategy,
|
|
@@ -98,11 +98,11 @@ export const Typeahead: React$AbstractComponent<
|
|
|
98
98
|
|
|
99
99
|
return (
|
|
100
100
|
<ClickAway onChange={onMenuToggle} clickAwayRef={clickAwayRef}>
|
|
101
|
-
{({isOpen, onOpen,
|
|
101
|
+
{({isOpen, onOpen, clickAway, boundaryRef}) => (
|
|
102
102
|
<div
|
|
103
103
|
data-testid="Typeahead"
|
|
104
104
|
className={classify(css.typeaheadContainer, classNames?.wrapper)}
|
|
105
|
-
|
|
105
|
+
ref={boundaryRef}
|
|
106
106
|
>
|
|
107
107
|
<SearchInput
|
|
108
108
|
{...inputProps}
|
|
@@ -140,7 +140,6 @@ export const Typeahead: React$AbstractComponent<
|
|
|
140
140
|
filteredOptions &&
|
|
141
141
|
!!filteredOptions.length && (
|
|
142
142
|
<div
|
|
143
|
-
onClickCapture={cancelNext}
|
|
144
143
|
ref={refs.setFloating}
|
|
145
144
|
style={{
|
|
146
145
|
position: strategy,
|
|
@@ -22,7 +22,8 @@ class ClickAway extends React.Component {
|
|
|
22
22
|
pageBottom: null
|
|
23
23
|
});
|
|
24
24
|
_defineProperty(this, "el", null);
|
|
25
|
-
_defineProperty(this, "
|
|
25
|
+
_defineProperty(this, "boundaryRef", /*#__PURE__*/React.createRef());
|
|
26
|
+
_defineProperty(this, "triggerRef", /*#__PURE__*/React.createRef());
|
|
26
27
|
_defineProperty(this, "handleOpenClick", () => {
|
|
27
28
|
// NOTE (kyle): we recalculate the position on click because sibling and niece components
|
|
28
29
|
// could have changed.
|
|
@@ -33,21 +34,20 @@ class ClickAway extends React.Component {
|
|
|
33
34
|
pageBottom = this.pageBottom();
|
|
34
35
|
}
|
|
35
36
|
this.setState({
|
|
36
|
-
isOpen:
|
|
37
|
+
isOpen: !this.state.isOpen,
|
|
37
38
|
pageBottom
|
|
38
39
|
}, this.handleOnChange);
|
|
39
40
|
});
|
|
40
41
|
_defineProperty(this, "handleCloseClick", evt => {
|
|
41
|
-
if (this.
|
|
42
|
+
if (evt.target instanceof Node && this.boundaryRef && (this.boundaryRef === evt.target || this.boundaryRef.current?.contains(evt.target))) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
if (this.
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
this.setState({
|
|
48
|
-
isOpen: false
|
|
49
|
-
}, this.handleOnChange);
|
|
45
|
+
if (evt.target instanceof Node && this.triggerRef && (this.triggerRef === evt.target || this.triggerRef.current?.contains(evt.target))) {
|
|
46
|
+
return;
|
|
50
47
|
}
|
|
48
|
+
this.setState({
|
|
49
|
+
isOpen: false
|
|
50
|
+
}, this.handleOnChange);
|
|
51
51
|
});
|
|
52
52
|
_defineProperty(this, "handleCloseOnEscapeKeypress", evt => {
|
|
53
53
|
if (evt?.key === 'Escape') {
|
|
@@ -59,9 +59,6 @@ class ClickAway extends React.Component {
|
|
|
59
59
|
isOpen: false
|
|
60
60
|
}, this.handleOnChange);
|
|
61
61
|
});
|
|
62
|
-
_defineProperty(this, "cancelNextClickAway", () => {
|
|
63
|
-
this.cancelNext = true;
|
|
64
|
-
});
|
|
65
62
|
_defineProperty(this, "handleOnChange", () => this.props.onChange && this.props.onChange(this.state.isOpen));
|
|
66
63
|
}
|
|
67
64
|
componentDidMount() {
|
|
@@ -78,18 +75,24 @@ class ClickAway extends React.Component {
|
|
|
78
75
|
} = this.state;
|
|
79
76
|
if (prevState.isOpen !== isOpen) {
|
|
80
77
|
if (this.state.isOpen) {
|
|
81
|
-
window.document.addEventListener('click', this.handleCloseClick
|
|
78
|
+
window.document.addEventListener('click', this.handleCloseClick, {
|
|
79
|
+
capture: true
|
|
80
|
+
});
|
|
82
81
|
if (this.props.closeOnEscapeKeypress) {
|
|
83
82
|
window.document.addEventListener('keyup', this.handleCloseOnEscapeKeypress);
|
|
84
83
|
}
|
|
85
84
|
} else {
|
|
86
|
-
window.document.removeEventListener('click', this.handleCloseClick
|
|
85
|
+
window.document.removeEventListener('click', this.handleCloseClick, {
|
|
86
|
+
capture: true
|
|
87
|
+
});
|
|
87
88
|
window.document.removeEventListener('keyup', this.handleCloseOnEscapeKeypress);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
componentWillUnmount() {
|
|
92
|
-
window.document.removeEventListener('click', this.handleCloseClick
|
|
93
|
+
window.document.removeEventListener('click', this.handleCloseClick, {
|
|
94
|
+
capture: true
|
|
95
|
+
});
|
|
93
96
|
window.document.removeEventListener('keyup', this.handleCloseOnEscapeKeypress);
|
|
94
97
|
}
|
|
95
98
|
render() {
|
|
@@ -112,9 +115,10 @@ class ClickAway extends React.Component {
|
|
|
112
115
|
isOpen,
|
|
113
116
|
height,
|
|
114
117
|
pageBottom,
|
|
115
|
-
cancelNext: this.cancelNextClickAway,
|
|
116
118
|
clickAway: this.forceClose,
|
|
117
|
-
anchorRef: el => this.el = el
|
|
119
|
+
anchorRef: el => this.el = el,
|
|
120
|
+
boundaryRef: this.boundaryRef,
|
|
121
|
+
triggerRef: this.triggerRef
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
pageBottom() {
|
|
@@ -125,6 +129,5 @@ class ClickAway extends React.Component {
|
|
|
125
129
|
}
|
|
126
130
|
exports.ClickAway = ClickAway;
|
|
127
131
|
_defineProperty(ClickAway, "defaultProps", {
|
|
128
|
-
shouldCancel: () => false,
|
|
129
132
|
closeOnEscapeKeypress: true
|
|
130
133
|
});
|
|
@@ -6,14 +6,23 @@ import invariant from 'invariant';
|
|
|
6
6
|
import {pageHeight} from '../dom';
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
type BoundaryRefType<T> = {
|
|
10
|
+
current: ?T,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type TriggerRefType<T> = {
|
|
14
|
+
current: ?T,
|
|
15
|
+
};
|
|
16
|
+
|
|
9
17
|
export type ChildProps = {
|
|
10
18
|
onOpen: () => void,
|
|
11
19
|
isOpen: boolean,
|
|
12
20
|
height: ?number,
|
|
13
21
|
pageBottom: ?number,
|
|
14
|
-
cancelNext: () => void,
|
|
15
22
|
clickAway: () => void,
|
|
16
23
|
anchorRef: (?HTMLElement) => mixed,
|
|
24
|
+
boundaryRef: BoundaryRefType<?HTMLElement>,
|
|
25
|
+
triggerRef: TriggerRefType<?HTMLElement>,
|
|
17
26
|
};
|
|
18
27
|
|
|
19
28
|
export type ClickAwayRefType = ?{
|
|
@@ -26,7 +35,6 @@ export type ClickAwayRefType = ?{
|
|
|
26
35
|
export type ClickAwayProps = {
|
|
27
36
|
closeOnEscapeKeypress?: boolean,
|
|
28
37
|
children: (props: ChildProps) => React.Node,
|
|
29
|
-
shouldCancel: (event: MouseEvent) => boolean,
|
|
30
38
|
onChange?: (isOpen: boolean) => mixed,
|
|
31
39
|
clickAwayRef?: ClickAwayRefType,
|
|
32
40
|
};
|
|
@@ -41,10 +49,8 @@ type ClickAwayState = {
|
|
|
41
49
|
|
|
42
50
|
export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
43
51
|
static defaultProps: {
|
|
44
|
-
shouldCancel: () => boolean,
|
|
45
52
|
closeOnEscapeKeypress?: boolean,
|
|
46
53
|
} = {
|
|
47
|
-
shouldCancel: () => false,
|
|
48
54
|
closeOnEscapeKeypress: true,
|
|
49
55
|
};
|
|
50
56
|
|
|
@@ -55,7 +61,8 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
el: ?HTMLElement = null;
|
|
58
|
-
|
|
64
|
+
boundaryRef: BoundaryRefType<?HTMLElement> = React.createRef();
|
|
65
|
+
triggerRef: TriggerRefType<?HTMLElement> = React.createRef();
|
|
59
66
|
|
|
60
67
|
componentDidMount() {
|
|
61
68
|
if (this.el) {
|
|
@@ -70,7 +77,9 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
70
77
|
const {isOpen} = this.state;
|
|
71
78
|
if (prevState.isOpen !== isOpen) {
|
|
72
79
|
if (this.state.isOpen) {
|
|
73
|
-
window.document.addEventListener('click', this.handleCloseClick
|
|
80
|
+
window.document.addEventListener('click', this.handleCloseClick, {
|
|
81
|
+
capture: true,
|
|
82
|
+
});
|
|
74
83
|
if (this.props.closeOnEscapeKeypress) {
|
|
75
84
|
window.document.addEventListener(
|
|
76
85
|
'keyup',
|
|
@@ -78,7 +87,9 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
78
87
|
);
|
|
79
88
|
}
|
|
80
89
|
} else {
|
|
81
|
-
window.document.removeEventListener('click', this.handleCloseClick
|
|
90
|
+
window.document.removeEventListener('click', this.handleCloseClick, {
|
|
91
|
+
capture: true,
|
|
92
|
+
});
|
|
82
93
|
window.document.removeEventListener(
|
|
83
94
|
'keyup',
|
|
84
95
|
this.handleCloseOnEscapeKeypress,
|
|
@@ -88,7 +99,9 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
componentWillUnmount() {
|
|
91
|
-
window.document.removeEventListener('click', this.handleCloseClick
|
|
102
|
+
window.document.removeEventListener('click', this.handleCloseClick, {
|
|
103
|
+
capture: true,
|
|
104
|
+
});
|
|
92
105
|
window.document.removeEventListener(
|
|
93
106
|
'keyup',
|
|
94
107
|
this.handleCloseOnEscapeKeypress,
|
|
@@ -98,7 +111,6 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
98
111
|
render(): React.Node {
|
|
99
112
|
const {height, isOpen, pageBottom} = this.state;
|
|
100
113
|
const {clickAwayRef} = this.props;
|
|
101
|
-
|
|
102
114
|
if (clickAwayRef) {
|
|
103
115
|
clickAwayRef.current = {
|
|
104
116
|
forceClose: this.forceClose,
|
|
@@ -110,9 +122,10 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
110
122
|
isOpen,
|
|
111
123
|
height,
|
|
112
124
|
pageBottom,
|
|
113
|
-
cancelNext: this.cancelNextClickAway,
|
|
114
125
|
clickAway: this.forceClose,
|
|
115
126
|
anchorRef: (el) => (this.el = el),
|
|
127
|
+
boundaryRef: this.boundaryRef,
|
|
128
|
+
triggerRef: this.triggerRef,
|
|
116
129
|
});
|
|
117
130
|
}
|
|
118
131
|
|
|
@@ -126,7 +139,7 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
126
139
|
|
|
127
140
|
this.setState(
|
|
128
141
|
{
|
|
129
|
-
isOpen:
|
|
142
|
+
isOpen: !this.state.isOpen,
|
|
130
143
|
pageBottom,
|
|
131
144
|
},
|
|
132
145
|
this.handleOnChange,
|
|
@@ -134,20 +147,30 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
134
147
|
};
|
|
135
148
|
|
|
136
149
|
handleCloseClick: (evt: MouseEvent) => void = (evt: MouseEvent) => {
|
|
137
|
-
if (
|
|
150
|
+
if (
|
|
151
|
+
evt.target instanceof Node &&
|
|
152
|
+
this.boundaryRef &&
|
|
153
|
+
(this.boundaryRef === evt.target ||
|
|
154
|
+
this.boundaryRef.current?.contains(evt.target))
|
|
155
|
+
) {
|
|
138
156
|
return;
|
|
139
157
|
}
|
|
140
158
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.handleOnChange,
|
|
149
|
-
);
|
|
159
|
+
if (
|
|
160
|
+
evt.target instanceof Node &&
|
|
161
|
+
this.triggerRef &&
|
|
162
|
+
(this.triggerRef === evt.target ||
|
|
163
|
+
this.triggerRef.current?.contains(evt.target))
|
|
164
|
+
) {
|
|
165
|
+
return;
|
|
150
166
|
}
|
|
167
|
+
|
|
168
|
+
this.setState(
|
|
169
|
+
{
|
|
170
|
+
isOpen: false,
|
|
171
|
+
},
|
|
172
|
+
this.handleOnChange,
|
|
173
|
+
);
|
|
151
174
|
};
|
|
152
175
|
|
|
153
176
|
handleCloseOnEscapeKeypress: (
|
|
@@ -162,10 +185,6 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
162
185
|
this.setState({isOpen: false}, this.handleOnChange);
|
|
163
186
|
};
|
|
164
187
|
|
|
165
|
-
cancelNextClickAway: () => void = () => {
|
|
166
|
-
this.cancelNext = true;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
188
|
handleOnChange: () => mixed = () =>
|
|
170
189
|
this.props.onChange && this.props.onChange(this.state.isOpen);
|
|
171
190
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
export function mergeRefs(
|
|
3
|
-
refs: Array<{current: ?HTMLElement
|
|
4
|
-
): (value:
|
|
3
|
+
refs: Array<{current: ?HTMLElement}>,
|
|
4
|
+
): (value: ?HTMLElement) => void {
|
|
5
5
|
return (value) => {
|
|
6
6
|
refs.forEach((ref) => {
|
|
7
7
|
if (typeof ref === 'function') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaced-out/ui-design-system",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.127-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Sense UI components library",
|
|
6
6
|
"author": {
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"node-sass": "^7.0.0",
|
|
105
105
|
"paths.macro": "^3.0.1",
|
|
106
106
|
"prettier": "^2.5.1",
|
|
107
|
-
"react": "
|
|
108
|
-
"react-dom": "
|
|
107
|
+
"react": "17.0.2",
|
|
108
|
+
"react-dom": "17.0.2",
|
|
109
109
|
"rimraf": "^3.0.2",
|
|
110
110
|
"simple-git": "^3.12.0",
|
|
111
111
|
"standard-version": "^9.5.0",
|