@citygross/components 0.8.170 → 0.8.171
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/build/cjs/components/src/components/ToolTipDialog/ToolTipDialog.js +18 -5
- package/build/cjs/components/src/components/ToolTipDialog/ToolTipDialog.js.map +1 -1
- package/build/es/components/src/components/ToolTipDialog/ToolTipDialog.js +19 -6
- package/build/es/components/src/components/ToolTipDialog/ToolTipDialog.js.map +1 -1
- package/package.json +2 -2
|
@@ -15,12 +15,22 @@ var ToolTipDialog = function (_a) {
|
|
|
15
15
|
var id = _a.id, info = _a.info, onBottom = _a.onBottom, toggle = _a.toggle;
|
|
16
16
|
var infoRef = React.useRef(null);
|
|
17
17
|
var isOpenRef = React.useRef(true);
|
|
18
|
-
|
|
18
|
+
var triggerElementRef = React.useRef(null);
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
triggerElementRef.current = document.activeElement;
|
|
21
|
+
}, []);
|
|
22
|
+
var handleClose = React.useCallback(function () {
|
|
23
|
+
if (triggerElementRef.current) {
|
|
24
|
+
triggerElementRef.current.focus();
|
|
25
|
+
}
|
|
26
|
+
toggle();
|
|
27
|
+
}, [toggle]);
|
|
28
|
+
utils.useOutsideClick(infoRef, handleClose);
|
|
19
29
|
React.useEffect(function () {
|
|
20
30
|
var focusTrapCleanup;
|
|
21
31
|
if (infoRef.current) {
|
|
22
32
|
focusTrapCleanup = utils.focusTrap({
|
|
23
|
-
exitFunction:
|
|
33
|
+
exitFunction: handleClose,
|
|
24
34
|
ref: infoRef
|
|
25
35
|
});
|
|
26
36
|
}
|
|
@@ -28,7 +38,7 @@ var ToolTipDialog = function (_a) {
|
|
|
28
38
|
if (event.key === 'Escape' && isOpenRef.current && infoRef.current) {
|
|
29
39
|
event.stopPropagation();
|
|
30
40
|
isOpenRef.current = false;
|
|
31
|
-
|
|
41
|
+
handleClose();
|
|
32
42
|
}
|
|
33
43
|
};
|
|
34
44
|
document.addEventListener('keydown', handleKeyDown, true);
|
|
@@ -36,11 +46,14 @@ var ToolTipDialog = function (_a) {
|
|
|
36
46
|
isOpenRef.current = false;
|
|
37
47
|
document.removeEventListener('keydown', handleKeyDown, true);
|
|
38
48
|
focusTrapCleanup === null || focusTrapCleanup === void 0 ? void 0 : focusTrapCleanup();
|
|
49
|
+
if (triggerElementRef.current) {
|
|
50
|
+
triggerElementRef.current.focus();
|
|
51
|
+
}
|
|
39
52
|
};
|
|
40
|
-
}, [
|
|
53
|
+
}, [handleClose]);
|
|
41
54
|
return (React__default["default"].createElement(ToolTipDialog_styles.DialogContainer, { "aria-live": "polite", id: id, onBottom: onBottom, ref: infoRef, role: "tooltip" },
|
|
42
55
|
info,
|
|
43
|
-
React__default["default"].createElement(ToolTipDialog_styles.DialogClose, { "aria-label": "St\u00E4ng", onClick:
|
|
56
|
+
React__default["default"].createElement(ToolTipDialog_styles.DialogClose, { "aria-label": "St\u00E4ng", onClick: handleClose },
|
|
44
57
|
React__default["default"].createElement(icons.Icons.Cross, { "aria-hidden": "true", color: "white", height: 20, width: 20 }))));
|
|
45
58
|
};
|
|
46
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolTipDialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolTipDialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react';
|
|
1
|
+
import React, { useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
import { useOutsideClick, focusTrap } from '@citygross/utils';
|
|
3
3
|
import { Icons } from '@citygross/icons';
|
|
4
4
|
import { DialogContainer, DialogClose } from './ToolTipDialog.styles.js';
|
|
@@ -7,12 +7,22 @@ var ToolTipDialog = function (_a) {
|
|
|
7
7
|
var id = _a.id, info = _a.info, onBottom = _a.onBottom, toggle = _a.toggle;
|
|
8
8
|
var infoRef = useRef(null);
|
|
9
9
|
var isOpenRef = useRef(true);
|
|
10
|
-
|
|
10
|
+
var triggerElementRef = useRef(null);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
triggerElementRef.current = document.activeElement;
|
|
13
|
+
}, []);
|
|
14
|
+
var handleClose = useCallback(function () {
|
|
15
|
+
if (triggerElementRef.current) {
|
|
16
|
+
triggerElementRef.current.focus();
|
|
17
|
+
}
|
|
18
|
+
toggle();
|
|
19
|
+
}, [toggle]);
|
|
20
|
+
useOutsideClick(infoRef, handleClose);
|
|
11
21
|
useEffect(function () {
|
|
12
22
|
var focusTrapCleanup;
|
|
13
23
|
if (infoRef.current) {
|
|
14
24
|
focusTrapCleanup = focusTrap({
|
|
15
|
-
exitFunction:
|
|
25
|
+
exitFunction: handleClose,
|
|
16
26
|
ref: infoRef
|
|
17
27
|
});
|
|
18
28
|
}
|
|
@@ -20,7 +30,7 @@ var ToolTipDialog = function (_a) {
|
|
|
20
30
|
if (event.key === 'Escape' && isOpenRef.current && infoRef.current) {
|
|
21
31
|
event.stopPropagation();
|
|
22
32
|
isOpenRef.current = false;
|
|
23
|
-
|
|
33
|
+
handleClose();
|
|
24
34
|
}
|
|
25
35
|
};
|
|
26
36
|
document.addEventListener('keydown', handleKeyDown, true);
|
|
@@ -28,11 +38,14 @@ var ToolTipDialog = function (_a) {
|
|
|
28
38
|
isOpenRef.current = false;
|
|
29
39
|
document.removeEventListener('keydown', handleKeyDown, true);
|
|
30
40
|
focusTrapCleanup === null || focusTrapCleanup === void 0 ? void 0 : focusTrapCleanup();
|
|
41
|
+
if (triggerElementRef.current) {
|
|
42
|
+
triggerElementRef.current.focus();
|
|
43
|
+
}
|
|
31
44
|
};
|
|
32
|
-
}, [
|
|
45
|
+
}, [handleClose]);
|
|
33
46
|
return (React.createElement(DialogContainer, { "aria-live": "polite", id: id, onBottom: onBottom, ref: infoRef, role: "tooltip" },
|
|
34
47
|
info,
|
|
35
|
-
React.createElement(DialogClose, { "aria-label": "St\u00E4ng", onClick:
|
|
48
|
+
React.createElement(DialogClose, { "aria-label": "St\u00E4ng", onClick: handleClose },
|
|
36
49
|
React.createElement(Icons.Cross, { "aria-hidden": "true", color: "white", height: 20, width: 20 }))));
|
|
37
50
|
};
|
|
38
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolTipDialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolTipDialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@citygross/components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.171",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./build/cjs/components/src/index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"react-slick": "^0.30.1",
|
|
75
75
|
"slick-carousel": "^1.8.1"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "1053e6e75192187811c33d54d1d52d7cdf7757b5"
|
|
78
78
|
}
|