@atlaskit/inline-dialog 13.4.9 → 13.5.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 +6 -0
- package/dist/cjs/InlineDialog/index.js +30 -10
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/InlineDialog/index.js +31 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/InlineDialog/index.js +30 -10
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/inline-dialog
|
|
2
2
|
|
|
3
|
+
## 13.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c0dd48dfb67`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c0dd48dfb67) - [ux] Adds keyboard support of using escape to close inline dialog.
|
|
8
|
+
|
|
3
9
|
## 13.4.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -19,7 +19,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
19
|
/** @jsx jsx */
|
|
20
20
|
|
|
21
21
|
var packageName = "@atlaskit/inline-dialog";
|
|
22
|
-
var packageVersion = "13.
|
|
22
|
+
var packageVersion = "13.5.0";
|
|
23
23
|
var checkIsChildOfPortal = function checkIsChildOfPortal(node) {
|
|
24
24
|
if (!node) {
|
|
25
25
|
return false;
|
|
@@ -46,12 +46,12 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref) {
|
|
|
46
46
|
children = _ref.children;
|
|
47
47
|
var containerRef = (0, _react.useRef)(null);
|
|
48
48
|
var triggerRef = (0, _react.useRef)(null);
|
|
49
|
-
// we put this into a ref to avoid
|
|
49
|
+
// we put this into a ref to avoid handleCloseRequest having this as a dependency
|
|
50
50
|
var onCloseRef = (0, _react.useRef)(onClose);
|
|
51
51
|
(0, _react.useEffect)(function () {
|
|
52
52
|
onCloseRef.current = onClose;
|
|
53
53
|
});
|
|
54
|
-
var
|
|
54
|
+
var handleCloseRequest = (0, _react.useCallback)(function (event) {
|
|
55
55
|
var target = event.target;
|
|
56
56
|
|
|
57
57
|
// checks for when target is not HTMLElement
|
|
@@ -66,11 +66,6 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref) {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
70
|
-
if (triggerRef.current && triggerRef.current.contains(target)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
69
|
// handles the case where inline dialog opens portalled elements such as modal
|
|
75
70
|
if (checkIsChildOfPortal(target)) {
|
|
76
71
|
return;
|
|
@@ -85,19 +80,44 @@ var InlineDialog = /*#__PURE__*/(0, _react.memo)(function InlineDialog(_ref) {
|
|
|
85
80
|
});
|
|
86
81
|
}
|
|
87
82
|
}, []);
|
|
83
|
+
var handleClick = (0, _react.useCallback)(function (event) {
|
|
84
|
+
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
85
|
+
if (triggerRef.current && triggerRef.current.contains(event.target)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
handleCloseRequest(event);
|
|
89
|
+
}, [handleCloseRequest]);
|
|
88
90
|
(0, _react.useEffect)(function () {
|
|
89
91
|
if (!isOpen) {
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
94
|
var unbind = (0, _bindEventListener.bind)(window, {
|
|
93
95
|
type: 'click',
|
|
94
|
-
listener:
|
|
96
|
+
listener: handleClick,
|
|
97
|
+
options: {
|
|
98
|
+
capture: true
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return unbind;
|
|
102
|
+
}, [isOpen, handleClick]);
|
|
103
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
104
|
+
if (event.key === 'Escape') {
|
|
105
|
+
handleCloseRequest(event);
|
|
106
|
+
}
|
|
107
|
+
}, [handleCloseRequest]);
|
|
108
|
+
(0, _react.useEffect)(function () {
|
|
109
|
+
if (!isOpen) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var unbind = (0, _bindEventListener.bind)(window, {
|
|
113
|
+
type: 'keydown',
|
|
114
|
+
listener: handleKeyDown,
|
|
95
115
|
options: {
|
|
96
116
|
capture: true
|
|
97
117
|
}
|
|
98
118
|
});
|
|
99
119
|
return unbind;
|
|
100
|
-
}, [isOpen,
|
|
120
|
+
}, [isOpen, handleKeyDown]);
|
|
101
121
|
var popper = isOpen ? (0, _react2.jsx)(_popper.Popper, {
|
|
102
122
|
placement: placement,
|
|
103
123
|
strategy: strategy
|
package/dist/cjs/version.json
CHANGED
|
@@ -8,7 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
8
8
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
9
9
|
import { Container } from './styled/container';
|
|
10
10
|
const packageName = "@atlaskit/inline-dialog";
|
|
11
|
-
const packageVersion = "13.
|
|
11
|
+
const packageVersion = "13.5.0";
|
|
12
12
|
const checkIsChildOfPortal = node => {
|
|
13
13
|
if (!node) {
|
|
14
14
|
return false;
|
|
@@ -29,12 +29,12 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
|
|
|
29
29
|
}) {
|
|
30
30
|
const containerRef = useRef(null);
|
|
31
31
|
const triggerRef = useRef(null);
|
|
32
|
-
// we put this into a ref to avoid
|
|
32
|
+
// we put this into a ref to avoid handleCloseRequest having this as a dependency
|
|
33
33
|
const onCloseRef = useRef(onClose);
|
|
34
34
|
useEffect(() => {
|
|
35
35
|
onCloseRef.current = onClose;
|
|
36
36
|
});
|
|
37
|
-
const
|
|
37
|
+
const handleCloseRequest = useCallback(event => {
|
|
38
38
|
const {
|
|
39
39
|
target
|
|
40
40
|
} = event;
|
|
@@ -51,11 +51,6 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
55
|
-
if (triggerRef.current && triggerRef.current.contains(target)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
54
|
// handles the case where inline dialog opens portalled elements such as modal
|
|
60
55
|
if (checkIsChildOfPortal(target)) {
|
|
61
56
|
return;
|
|
@@ -66,23 +61,48 @@ const InlineDialog = /*#__PURE__*/memo(function InlineDialog({
|
|
|
66
61
|
var _onCloseRef$current;
|
|
67
62
|
(_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef, {
|
|
68
63
|
isOpen: false,
|
|
69
|
-
event
|
|
64
|
+
event
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
67
|
}, []);
|
|
68
|
+
const handleClick = useCallback(event => {
|
|
69
|
+
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
70
|
+
if (triggerRef.current && triggerRef.current.contains(event.target)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
handleCloseRequest(event);
|
|
74
|
+
}, [handleCloseRequest]);
|
|
73
75
|
useEffect(() => {
|
|
74
76
|
if (!isOpen) {
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
const unbind = bind(window, {
|
|
78
80
|
type: 'click',
|
|
79
|
-
listener:
|
|
81
|
+
listener: handleClick,
|
|
82
|
+
options: {
|
|
83
|
+
capture: true
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return unbind;
|
|
87
|
+
}, [isOpen, handleClick]);
|
|
88
|
+
const handleKeyDown = useCallback(event => {
|
|
89
|
+
if (event.key === 'Escape') {
|
|
90
|
+
handleCloseRequest(event);
|
|
91
|
+
}
|
|
92
|
+
}, [handleCloseRequest]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!isOpen) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const unbind = bind(window, {
|
|
98
|
+
type: 'keydown',
|
|
99
|
+
listener: handleKeyDown,
|
|
80
100
|
options: {
|
|
81
101
|
capture: true
|
|
82
102
|
}
|
|
83
103
|
});
|
|
84
104
|
return unbind;
|
|
85
|
-
}, [isOpen,
|
|
105
|
+
}, [isOpen, handleKeyDown]);
|
|
86
106
|
const popper = isOpen ? jsx(Popper, {
|
|
87
107
|
placement: placement,
|
|
88
108
|
strategy: strategy
|
package/dist/es2019/version.json
CHANGED
|
@@ -8,7 +8,7 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
8
8
|
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
9
9
|
import { Container } from './styled/container';
|
|
10
10
|
var packageName = "@atlaskit/inline-dialog";
|
|
11
|
-
var packageVersion = "13.
|
|
11
|
+
var packageVersion = "13.5.0";
|
|
12
12
|
var checkIsChildOfPortal = function checkIsChildOfPortal(node) {
|
|
13
13
|
if (!node) {
|
|
14
14
|
return false;
|
|
@@ -35,12 +35,12 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref) {
|
|
|
35
35
|
children = _ref.children;
|
|
36
36
|
var containerRef = useRef(null);
|
|
37
37
|
var triggerRef = useRef(null);
|
|
38
|
-
// we put this into a ref to avoid
|
|
38
|
+
// we put this into a ref to avoid handleCloseRequest having this as a dependency
|
|
39
39
|
var onCloseRef = useRef(onClose);
|
|
40
40
|
useEffect(function () {
|
|
41
41
|
onCloseRef.current = onClose;
|
|
42
42
|
});
|
|
43
|
-
var
|
|
43
|
+
var handleCloseRequest = useCallback(function (event) {
|
|
44
44
|
var target = event.target;
|
|
45
45
|
|
|
46
46
|
// checks for when target is not HTMLElement
|
|
@@ -55,11 +55,6 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
59
|
-
if (triggerRef.current && triggerRef.current.contains(target)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
58
|
// handles the case where inline dialog opens portalled elements such as modal
|
|
64
59
|
if (checkIsChildOfPortal(target)) {
|
|
65
60
|
return;
|
|
@@ -74,19 +69,44 @@ var InlineDialog = /*#__PURE__*/memo(function InlineDialog(_ref) {
|
|
|
74
69
|
});
|
|
75
70
|
}
|
|
76
71
|
}, []);
|
|
72
|
+
var handleClick = useCallback(function (event) {
|
|
73
|
+
// exit if we click outside but on the trigger — it can handle the clicks itself
|
|
74
|
+
if (triggerRef.current && triggerRef.current.contains(event.target)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
handleCloseRequest(event);
|
|
78
|
+
}, [handleCloseRequest]);
|
|
77
79
|
useEffect(function () {
|
|
78
80
|
if (!isOpen) {
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
83
|
var unbind = bind(window, {
|
|
82
84
|
type: 'click',
|
|
83
|
-
listener:
|
|
85
|
+
listener: handleClick,
|
|
86
|
+
options: {
|
|
87
|
+
capture: true
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return unbind;
|
|
91
|
+
}, [isOpen, handleClick]);
|
|
92
|
+
var handleKeyDown = useCallback(function (event) {
|
|
93
|
+
if (event.key === 'Escape') {
|
|
94
|
+
handleCloseRequest(event);
|
|
95
|
+
}
|
|
96
|
+
}, [handleCloseRequest]);
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
if (!isOpen) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var unbind = bind(window, {
|
|
102
|
+
type: 'keydown',
|
|
103
|
+
listener: handleKeyDown,
|
|
84
104
|
options: {
|
|
85
105
|
capture: true
|
|
86
106
|
}
|
|
87
107
|
});
|
|
88
108
|
return unbind;
|
|
89
|
-
}, [isOpen,
|
|
109
|
+
}, [isOpen, handleKeyDown]);
|
|
90
110
|
var popper = isOpen ? jsx(Popper, {
|
|
91
111
|
placement: placement,
|
|
92
112
|
strategy: strategy
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/inline-dialog",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.5.0",
|
|
4
4
|
"description": "An inline dialog is a pop-up container for small amounts of information. It can also contain controls.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react": "^16.8.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@atlaskit/button": "^16.
|
|
51
|
+
"@atlaskit/button": "^16.6.0",
|
|
52
52
|
"@atlaskit/datetime-picker": "^12.3.0",
|
|
53
53
|
"@atlaskit/docs": "*",
|
|
54
54
|
"@atlaskit/icon": "^21.11.0",
|