@atlaskit/popup 1.1.5 → 1.3.1
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 +37 -0
- package/dist/cjs/PopperWrapper.js +10 -8
- package/dist/cjs/Popup.js +6 -1
- package/dist/cjs/useCloseManager.js +7 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/PopperWrapper.js +11 -8
- package/dist/es2019/Popup.js +5 -1
- package/dist/es2019/useCloseManager.js +7 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/PopperWrapper.js +10 -7
- package/dist/esm/Popup.js +6 -1
- package/dist/esm/useCloseManager.js +7 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/PopperWrapper.d.ts +2 -1
- package/dist/types/types.d.ts +13 -1
- package/dist/types/useCloseManager.d.ts +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @atlaskit/popup
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`2e42aa0d900`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e42aa0d900) - **Note**: It is a re-release of the wrongly `patched` version `1.1.6` that should have been a `minor` release.
|
|
14
|
+
|
|
15
|
+
Expose `fallbackPlacement` modifier from to specify a list of fallback options to try incase there isn't enough space
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 1.2.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [`c2dd770a743`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2dd770a743) - Add new prop which controls is outside click should be bound using capture
|
|
26
|
+
|
|
27
|
+
## 1.1.6
|
|
28
|
+
|
|
29
|
+
_WRONG RELEASE TYPE - DON'T USE_
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [`f142150a3e8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f142150a3e8) - Expose `fallbackPlacement` modifier from to specify a list of fallback options to try incase there isn't enough space
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [`f460cc7c411`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f460cc7c411) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving bundle size.
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
|
|
3
40
|
## 1.1.5
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -21,8 +21,6 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
21
21
|
|
|
22
22
|
var _constants = require("@atlaskit/theme/constants");
|
|
23
23
|
|
|
24
|
-
var _tokens = require("@atlaskit/tokens");
|
|
25
|
-
|
|
26
24
|
var _RepositionOnUpdate = require("./RepositionOnUpdate");
|
|
27
25
|
|
|
28
26
|
var _useCloseManager = require("./useCloseManager");
|
|
@@ -35,9 +33,9 @@ var popupStyles = (0, _core.css)({
|
|
|
35
33
|
boxSizing: 'border-box',
|
|
36
34
|
zIndex: _constants.layers.layer(),
|
|
37
35
|
flex: '1 1 auto',
|
|
38
|
-
backgroundColor: (
|
|
36
|
+
backgroundColor: "var(--ds-background-overlay, ".concat(_colors.N0, ")"),
|
|
39
37
|
borderRadius: "".concat((0, _constants.borderRadius)(), "px"),
|
|
40
|
-
boxShadow: (
|
|
38
|
+
boxShadow: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"),
|
|
41
39
|
overflow: 'auto',
|
|
42
40
|
':focus': {
|
|
43
41
|
outline: 'none'
|
|
@@ -56,6 +54,7 @@ function PopperWrapper(_ref) {
|
|
|
56
54
|
offset = _ref.offset,
|
|
57
55
|
testId = _ref.testId,
|
|
58
56
|
content = _ref.content,
|
|
57
|
+
fallbackPlacements = _ref.fallbackPlacements,
|
|
59
58
|
onClose = _ref.onClose,
|
|
60
59
|
boundary = _ref.boundary,
|
|
61
60
|
rootBoundary = _ref.rootBoundary,
|
|
@@ -66,7 +65,8 @@ function PopperWrapper(_ref) {
|
|
|
66
65
|
PopupContainer = _ref$popupComponent === void 0 ? DefaultPopupComponent : _ref$popupComponent,
|
|
67
66
|
_ref$autoFocus = _ref.autoFocus,
|
|
68
67
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
69
|
-
triggerRef = _ref.triggerRef
|
|
68
|
+
triggerRef = _ref.triggerRef,
|
|
69
|
+
shouldUseCaptureOnOutsideClick = _ref.shouldUseCaptureOnOutsideClick;
|
|
70
70
|
|
|
71
71
|
var _useState = (0, _react.useState)(null),
|
|
72
72
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -86,7 +86,8 @@ function PopperWrapper(_ref) {
|
|
|
86
86
|
isOpen: isOpen,
|
|
87
87
|
onClose: onClose,
|
|
88
88
|
popupRef: popupRef,
|
|
89
|
-
triggerRef: triggerRef
|
|
89
|
+
triggerRef: triggerRef,
|
|
90
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick
|
|
90
91
|
});
|
|
91
92
|
var modifiers = (0, _react.useMemo)(function () {
|
|
92
93
|
return [{
|
|
@@ -94,10 +95,11 @@ function PopperWrapper(_ref) {
|
|
|
94
95
|
enabled: shouldFlip,
|
|
95
96
|
options: {
|
|
96
97
|
rootBoundary: rootBoundary,
|
|
97
|
-
boundary: boundary
|
|
98
|
+
boundary: boundary,
|
|
99
|
+
fallbackPlacements: fallbackPlacements
|
|
98
100
|
}
|
|
99
101
|
}];
|
|
100
|
-
}, [shouldFlip, rootBoundary, boundary]);
|
|
102
|
+
}, [shouldFlip, rootBoundary, boundary, fallbackPlacements]);
|
|
101
103
|
return (0, _core.jsx)(_popper.Popper, {
|
|
102
104
|
placement: placement,
|
|
103
105
|
offset: offset,
|
package/dist/cjs/Popup.js
CHANGED
|
@@ -39,11 +39,14 @@ var Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
39
39
|
shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
40
40
|
_ref$placement = _ref.placement,
|
|
41
41
|
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
|
42
|
+
fallbackPlacements = _ref.fallbackPlacements,
|
|
42
43
|
PopupContainer = _ref.popupComponent,
|
|
43
44
|
_ref$autoFocus = _ref.autoFocus,
|
|
44
45
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
45
46
|
_ref$zIndex = _ref.zIndex,
|
|
46
|
-
zIndex = _ref$zIndex === void 0 ? defaultLayer : _ref$zIndex
|
|
47
|
+
zIndex = _ref$zIndex === void 0 ? defaultLayer : _ref$zIndex,
|
|
48
|
+
_ref$shouldUseCapture = _ref.shouldUseCaptureOnOutsideClick,
|
|
49
|
+
shouldUseCaptureOnOutsideClick = _ref$shouldUseCapture === void 0 ? false : _ref$shouldUseCapture;
|
|
47
50
|
|
|
48
51
|
var _useState = (0, _react.useState)(null),
|
|
49
52
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -74,6 +77,7 @@ var Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
74
77
|
content: content,
|
|
75
78
|
isOpen: isOpen,
|
|
76
79
|
placement: placement,
|
|
80
|
+
fallbackPlacements: fallbackPlacements,
|
|
77
81
|
boundary: boundary,
|
|
78
82
|
rootBoundary: rootBoundary,
|
|
79
83
|
shouldFlip: shouldFlip,
|
|
@@ -83,6 +87,7 @@ var Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
83
87
|
testId: testId,
|
|
84
88
|
onClose: onClose,
|
|
85
89
|
autoFocus: autoFocus,
|
|
90
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
86
91
|
triggerRef: triggerRef
|
|
87
92
|
})));
|
|
88
93
|
});
|
|
@@ -15,7 +15,8 @@ var useCloseManager = function useCloseManager(_ref) {
|
|
|
15
15
|
var isOpen = _ref.isOpen,
|
|
16
16
|
onClose = _ref.onClose,
|
|
17
17
|
popupRef = _ref.popupRef,
|
|
18
|
-
triggerRef = _ref.triggerRef
|
|
18
|
+
triggerRef = _ref.triggerRef,
|
|
19
|
+
capture = _ref.shouldUseCaptureOnOutsideClick;
|
|
19
20
|
(0, _react.useEffect)(function () {
|
|
20
21
|
if (!isOpen || !popupRef) {
|
|
21
22
|
return noop;
|
|
@@ -61,13 +62,16 @@ var useCloseManager = function useCloseManager(_ref) {
|
|
|
61
62
|
var unbind = (0, _bindEventListener.bindAll)(window, [// --strictFunctionTypes prevents the above events from being recognised as event listeners
|
|
62
63
|
{
|
|
63
64
|
type: 'click',
|
|
64
|
-
listener: onClick
|
|
65
|
+
listener: onClick,
|
|
66
|
+
options: {
|
|
67
|
+
capture: capture
|
|
68
|
+
}
|
|
65
69
|
}, {
|
|
66
70
|
type: 'keydown',
|
|
67
71
|
listener: onKeyDown
|
|
68
72
|
}]);
|
|
69
73
|
return unbind;
|
|
70
|
-
}, [isOpen, onClose, popupRef, triggerRef]);
|
|
74
|
+
}, [isOpen, onClose, popupRef, triggerRef, capture]);
|
|
71
75
|
};
|
|
72
76
|
|
|
73
77
|
exports.useCloseManager = useCloseManager;
|
package/dist/cjs/version.json
CHANGED
|
@@ -6,7 +6,6 @@ import { css, jsx } from '@emotion/core';
|
|
|
6
6
|
import { Popper } from '@atlaskit/popper';
|
|
7
7
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
8
8
|
import { borderRadius, layers } from '@atlaskit/theme/constants';
|
|
9
|
-
import { token } from '@atlaskit/tokens';
|
|
10
9
|
import { RepositionOnUpdate } from './RepositionOnUpdate';
|
|
11
10
|
import { useCloseManager } from './useCloseManager';
|
|
12
11
|
import { useFocusManager } from './useFocusManager';
|
|
@@ -15,9 +14,9 @@ const popupStyles = css({
|
|
|
15
14
|
boxSizing: 'border-box',
|
|
16
15
|
zIndex: layers.layer(),
|
|
17
16
|
flex: '1 1 auto',
|
|
18
|
-
backgroundColor:
|
|
17
|
+
backgroundColor: `var(--ds-background-overlay, ${N0})`,
|
|
19
18
|
borderRadius: `${borderRadius()}px`,
|
|
20
|
-
boxShadow:
|
|
19
|
+
boxShadow: `var(--ds-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
|
|
21
20
|
overflow: 'auto',
|
|
22
21
|
':focus': {
|
|
23
22
|
outline: 'none'
|
|
@@ -34,6 +33,7 @@ function PopperWrapper({
|
|
|
34
33
|
offset,
|
|
35
34
|
testId,
|
|
36
35
|
content,
|
|
36
|
+
fallbackPlacements,
|
|
37
37
|
onClose,
|
|
38
38
|
boundary,
|
|
39
39
|
rootBoundary,
|
|
@@ -41,7 +41,8 @@ function PopperWrapper({
|
|
|
41
41
|
placement = 'auto',
|
|
42
42
|
popupComponent: PopupContainer = DefaultPopupComponent,
|
|
43
43
|
autoFocus = true,
|
|
44
|
-
triggerRef
|
|
44
|
+
triggerRef,
|
|
45
|
+
shouldUseCaptureOnOutsideClick
|
|
45
46
|
}) {
|
|
46
47
|
const [popupRef, setPopupRef] = useState(null);
|
|
47
48
|
const [initialFocusRef, setInitialFocusRef] = useState(null);
|
|
@@ -53,16 +54,18 @@ function PopperWrapper({
|
|
|
53
54
|
isOpen,
|
|
54
55
|
onClose,
|
|
55
56
|
popupRef,
|
|
56
|
-
triggerRef
|
|
57
|
+
triggerRef,
|
|
58
|
+
shouldUseCaptureOnOutsideClick
|
|
57
59
|
});
|
|
58
60
|
const modifiers = useMemo(() => [{
|
|
59
61
|
name: 'flip',
|
|
60
62
|
enabled: shouldFlip,
|
|
61
63
|
options: {
|
|
62
|
-
rootBoundary
|
|
63
|
-
boundary
|
|
64
|
+
rootBoundary,
|
|
65
|
+
boundary,
|
|
66
|
+
fallbackPlacements
|
|
64
67
|
}
|
|
65
|
-
}], [shouldFlip, rootBoundary, boundary]);
|
|
68
|
+
}], [shouldFlip, rootBoundary, boundary, fallbackPlacements]);
|
|
66
69
|
return jsx(Popper, {
|
|
67
70
|
placement: placement,
|
|
68
71
|
offset: offset,
|
package/dist/es2019/Popup.js
CHANGED
|
@@ -18,9 +18,11 @@ export const Popup = /*#__PURE__*/memo(({
|
|
|
18
18
|
rootBoundary = 'viewport',
|
|
19
19
|
shouldFlip = true,
|
|
20
20
|
placement = 'auto',
|
|
21
|
+
fallbackPlacements,
|
|
21
22
|
popupComponent: PopupContainer,
|
|
22
23
|
autoFocus = true,
|
|
23
|
-
zIndex = defaultLayer
|
|
24
|
+
zIndex = defaultLayer,
|
|
25
|
+
shouldUseCaptureOnOutsideClick = false
|
|
24
26
|
}) => {
|
|
25
27
|
const [triggerRef, setTriggerRef] = useState(null);
|
|
26
28
|
return jsx(Manager, null, jsx(Reference, null, ({
|
|
@@ -48,6 +50,7 @@ export const Popup = /*#__PURE__*/memo(({
|
|
|
48
50
|
content: content,
|
|
49
51
|
isOpen: isOpen,
|
|
50
52
|
placement: placement,
|
|
53
|
+
fallbackPlacements: fallbackPlacements,
|
|
51
54
|
boundary: boundary,
|
|
52
55
|
rootBoundary: rootBoundary,
|
|
53
56
|
shouldFlip: shouldFlip,
|
|
@@ -57,6 +60,7 @@ export const Popup = /*#__PURE__*/memo(({
|
|
|
57
60
|
testId: testId,
|
|
58
61
|
onClose: onClose,
|
|
59
62
|
autoFocus: autoFocus,
|
|
63
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
60
64
|
triggerRef: triggerRef
|
|
61
65
|
})));
|
|
62
66
|
});
|
|
@@ -7,7 +7,8 @@ export const useCloseManager = ({
|
|
|
7
7
|
isOpen,
|
|
8
8
|
onClose,
|
|
9
9
|
popupRef,
|
|
10
|
-
triggerRef
|
|
10
|
+
triggerRef,
|
|
11
|
+
shouldUseCaptureOnOutsideClick: capture
|
|
11
12
|
}) => {
|
|
12
13
|
useEffect(() => {
|
|
13
14
|
if (!isOpen || !popupRef) {
|
|
@@ -57,11 +58,14 @@ export const useCloseManager = ({
|
|
|
57
58
|
const unbind = bindAll(window, [// --strictFunctionTypes prevents the above events from being recognised as event listeners
|
|
58
59
|
{
|
|
59
60
|
type: 'click',
|
|
60
|
-
listener: onClick
|
|
61
|
+
listener: onClick,
|
|
62
|
+
options: {
|
|
63
|
+
capture
|
|
64
|
+
}
|
|
61
65
|
}, {
|
|
62
66
|
type: 'keydown',
|
|
63
67
|
listener: onKeyDown
|
|
64
68
|
}]);
|
|
65
69
|
return unbind;
|
|
66
|
-
}, [isOpen, onClose, popupRef, triggerRef]);
|
|
70
|
+
}, [isOpen, onClose, popupRef, triggerRef, capture]);
|
|
67
71
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -7,7 +7,6 @@ import { css, jsx } from '@emotion/core';
|
|
|
7
7
|
import { Popper } from '@atlaskit/popper';
|
|
8
8
|
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
9
9
|
import { borderRadius, layers } from '@atlaskit/theme/constants';
|
|
10
|
-
import { token } from '@atlaskit/tokens';
|
|
11
10
|
import { RepositionOnUpdate } from './RepositionOnUpdate';
|
|
12
11
|
import { useCloseManager } from './useCloseManager';
|
|
13
12
|
import { useFocusManager } from './useFocusManager';
|
|
@@ -16,9 +15,9 @@ var popupStyles = css({
|
|
|
16
15
|
boxSizing: 'border-box',
|
|
17
16
|
zIndex: layers.layer(),
|
|
18
17
|
flex: '1 1 auto',
|
|
19
|
-
backgroundColor:
|
|
18
|
+
backgroundColor: "var(--ds-background-overlay, ".concat(N0, ")"),
|
|
20
19
|
borderRadius: "".concat(borderRadius(), "px"),
|
|
21
|
-
boxShadow:
|
|
20
|
+
boxShadow: "var(--ds-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"),
|
|
22
21
|
overflow: 'auto',
|
|
23
22
|
':focus': {
|
|
24
23
|
outline: 'none'
|
|
@@ -37,6 +36,7 @@ function PopperWrapper(_ref) {
|
|
|
37
36
|
offset = _ref.offset,
|
|
38
37
|
testId = _ref.testId,
|
|
39
38
|
content = _ref.content,
|
|
39
|
+
fallbackPlacements = _ref.fallbackPlacements,
|
|
40
40
|
onClose = _ref.onClose,
|
|
41
41
|
boundary = _ref.boundary,
|
|
42
42
|
rootBoundary = _ref.rootBoundary,
|
|
@@ -47,7 +47,8 @@ function PopperWrapper(_ref) {
|
|
|
47
47
|
PopupContainer = _ref$popupComponent === void 0 ? DefaultPopupComponent : _ref$popupComponent,
|
|
48
48
|
_ref$autoFocus = _ref.autoFocus,
|
|
49
49
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
50
|
-
triggerRef = _ref.triggerRef
|
|
50
|
+
triggerRef = _ref.triggerRef,
|
|
51
|
+
shouldUseCaptureOnOutsideClick = _ref.shouldUseCaptureOnOutsideClick;
|
|
51
52
|
|
|
52
53
|
var _useState = useState(null),
|
|
53
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -67,7 +68,8 @@ function PopperWrapper(_ref) {
|
|
|
67
68
|
isOpen: isOpen,
|
|
68
69
|
onClose: onClose,
|
|
69
70
|
popupRef: popupRef,
|
|
70
|
-
triggerRef: triggerRef
|
|
71
|
+
triggerRef: triggerRef,
|
|
72
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick
|
|
71
73
|
});
|
|
72
74
|
var modifiers = useMemo(function () {
|
|
73
75
|
return [{
|
|
@@ -75,10 +77,11 @@ function PopperWrapper(_ref) {
|
|
|
75
77
|
enabled: shouldFlip,
|
|
76
78
|
options: {
|
|
77
79
|
rootBoundary: rootBoundary,
|
|
78
|
-
boundary: boundary
|
|
80
|
+
boundary: boundary,
|
|
81
|
+
fallbackPlacements: fallbackPlacements
|
|
79
82
|
}
|
|
80
83
|
}];
|
|
81
|
-
}, [shouldFlip, rootBoundary, boundary]);
|
|
84
|
+
}, [shouldFlip, rootBoundary, boundary, fallbackPlacements]);
|
|
82
85
|
return jsx(Popper, {
|
|
83
86
|
placement: placement,
|
|
84
87
|
offset: offset,
|
package/dist/esm/Popup.js
CHANGED
|
@@ -23,11 +23,14 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
|
|
|
23
23
|
shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
24
24
|
_ref$placement = _ref.placement,
|
|
25
25
|
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
|
26
|
+
fallbackPlacements = _ref.fallbackPlacements,
|
|
26
27
|
PopupContainer = _ref.popupComponent,
|
|
27
28
|
_ref$autoFocus = _ref.autoFocus,
|
|
28
29
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
29
30
|
_ref$zIndex = _ref.zIndex,
|
|
30
|
-
zIndex = _ref$zIndex === void 0 ? defaultLayer : _ref$zIndex
|
|
31
|
+
zIndex = _ref$zIndex === void 0 ? defaultLayer : _ref$zIndex,
|
|
32
|
+
_ref$shouldUseCapture = _ref.shouldUseCaptureOnOutsideClick,
|
|
33
|
+
shouldUseCaptureOnOutsideClick = _ref$shouldUseCapture === void 0 ? false : _ref$shouldUseCapture;
|
|
31
34
|
|
|
32
35
|
var _useState = useState(null),
|
|
33
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -58,6 +61,7 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
|
|
|
58
61
|
content: content,
|
|
59
62
|
isOpen: isOpen,
|
|
60
63
|
placement: placement,
|
|
64
|
+
fallbackPlacements: fallbackPlacements,
|
|
61
65
|
boundary: boundary,
|
|
62
66
|
rootBoundary: rootBoundary,
|
|
63
67
|
shouldFlip: shouldFlip,
|
|
@@ -67,6 +71,7 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
|
|
|
67
71
|
testId: testId,
|
|
68
72
|
onClose: onClose,
|
|
69
73
|
autoFocus: autoFocus,
|
|
74
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
70
75
|
triggerRef: triggerRef
|
|
71
76
|
})));
|
|
72
77
|
});
|
|
@@ -7,7 +7,8 @@ export var useCloseManager = function useCloseManager(_ref) {
|
|
|
7
7
|
var isOpen = _ref.isOpen,
|
|
8
8
|
onClose = _ref.onClose,
|
|
9
9
|
popupRef = _ref.popupRef,
|
|
10
|
-
triggerRef = _ref.triggerRef
|
|
10
|
+
triggerRef = _ref.triggerRef,
|
|
11
|
+
capture = _ref.shouldUseCaptureOnOutsideClick;
|
|
11
12
|
useEffect(function () {
|
|
12
13
|
if (!isOpen || !popupRef) {
|
|
13
14
|
return noop;
|
|
@@ -53,11 +54,14 @@ export var useCloseManager = function useCloseManager(_ref) {
|
|
|
53
54
|
var unbind = bindAll(window, [// --strictFunctionTypes prevents the above events from being recognised as event listeners
|
|
54
55
|
{
|
|
55
56
|
type: 'click',
|
|
56
|
-
listener: onClick
|
|
57
|
+
listener: onClick,
|
|
58
|
+
options: {
|
|
59
|
+
capture: capture
|
|
60
|
+
}
|
|
57
61
|
}, {
|
|
58
62
|
type: 'keydown',
|
|
59
63
|
listener: onKeyDown
|
|
60
64
|
}]);
|
|
61
65
|
return unbind;
|
|
62
|
-
}, [isOpen, onClose, popupRef, triggerRef]);
|
|
66
|
+
}, [isOpen, onClose, popupRef, triggerRef, capture]);
|
|
63
67
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { PopperWrapperProps } from './types';
|
|
2
|
-
declare function PopperWrapper({ isOpen, id, offset, testId, content, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, }: PopperWrapperProps): JSX.Element;
|
|
3
|
+
declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, }: PopperWrapperProps): JSX.Element;
|
|
3
4
|
export default PopperWrapper;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface TriggerProps {
|
|
|
7
7
|
'aria-haspopup': boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare type PopupRef = HTMLDivElement | null;
|
|
10
|
-
export declare type TriggerRef = HTMLElement | null;
|
|
10
|
+
export declare type TriggerRef = HTMLElement | HTMLButtonElement | null;
|
|
11
11
|
export interface ContentProps {
|
|
12
12
|
/**
|
|
13
13
|
* Will reposition the popup if any of the content has changed.
|
|
@@ -82,6 +82,12 @@ interface BaseProps {
|
|
|
82
82
|
* Defaults to `"auto"`.
|
|
83
83
|
*/
|
|
84
84
|
placement?: Placement;
|
|
85
|
+
/**
|
|
86
|
+
* Defines a list of placements to try.
|
|
87
|
+
* When no space is available on the preferred placement,
|
|
88
|
+
* the modifier will test the ones provided in the list, and use the first useful one.
|
|
89
|
+
*/
|
|
90
|
+
fallbackPlacements?: Placement[];
|
|
85
91
|
/**
|
|
86
92
|
* The boundary element that the popup will check for overflow.
|
|
87
93
|
* Defaults to `"clippingParents"` which are parent scroll containers,
|
|
@@ -122,6 +128,11 @@ interface BaseProps {
|
|
|
122
128
|
* Defaults to `true`.
|
|
123
129
|
*/
|
|
124
130
|
autoFocus?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Controls if the event which handles clicks outside the popup is be bound with
|
|
133
|
+
* `capture: true`
|
|
134
|
+
*/
|
|
135
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
125
136
|
}
|
|
126
137
|
export interface PopupProps extends BaseProps {
|
|
127
138
|
/**
|
|
@@ -143,6 +154,7 @@ export interface PopperWrapperProps extends BaseProps {
|
|
|
143
154
|
export declare type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
144
155
|
popupRef: PopupRef;
|
|
145
156
|
triggerRef: TriggerRef;
|
|
157
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
146
158
|
};
|
|
147
159
|
export declare type FocusManagerHook = {
|
|
148
160
|
popupRef: PopupRef;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CloseManagerHook } from './types';
|
|
2
|
-
export declare const useCloseManager: ({ isOpen, onClose, popupRef, triggerRef, }: CloseManagerHook) => void;
|
|
2
|
+
export declare const useCloseManager: ({ isOpen, onClose, popupRef, triggerRef, shouldUseCaptureOnOutsideClick: capture, }: CloseManagerHook) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/popup",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A portalled popup primitive that is tied to a trigger element.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"atlassian": {
|
|
22
22
|
"team": "Design System Team",
|
|
23
|
-
"inPublicMirror": true,
|
|
24
23
|
"releaseModel": "scheduled",
|
|
25
24
|
"website": {
|
|
26
25
|
"name": "Popup"
|
|
@@ -29,8 +28,8 @@
|
|
|
29
28
|
"dependencies": {
|
|
30
29
|
"@atlaskit/popper": "^5.0.0",
|
|
31
30
|
"@atlaskit/portal": "^4.0.0",
|
|
32
|
-
"@atlaskit/theme": "^12.
|
|
33
|
-
"@atlaskit/tokens": "^0.
|
|
31
|
+
"@atlaskit/theme": "^12.1.0",
|
|
32
|
+
"@atlaskit/tokens": "^0.5.0",
|
|
34
33
|
"@babel/runtime": "^7.0.0",
|
|
35
34
|
"@emotion/core": "^10.0.9",
|
|
36
35
|
"bind-event-listener": "^1.0.2",
|
|
@@ -41,10 +40,9 @@
|
|
|
41
40
|
"react-dom": "^16.8.0"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@atlaskit/build-utils": "*",
|
|
45
43
|
"@atlaskit/button": "^16.1.0",
|
|
46
44
|
"@atlaskit/docs": "*",
|
|
47
|
-
"@atlaskit/icon": "^21.
|
|
45
|
+
"@atlaskit/icon": "^21.10.0",
|
|
48
46
|
"@atlaskit/menu": "^1.2.0",
|
|
49
47
|
"@atlaskit/radio": "^5.3.0",
|
|
50
48
|
"@atlaskit/select": "^15.0.0",
|
|
@@ -77,7 +75,10 @@
|
|
|
77
75
|
"analytics": "analytics-next",
|
|
78
76
|
"theming": "tokens",
|
|
79
77
|
"deprecation": "no-deprecated-imports",
|
|
80
|
-
"styling":
|
|
78
|
+
"styling": [
|
|
79
|
+
"static",
|
|
80
|
+
"emotion"
|
|
81
|
+
]
|
|
81
82
|
}
|
|
82
83
|
},
|
|
83
84
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|