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