@steroidsjs/core 2.2.43 → 2.2.44
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/package.json
CHANGED
|
@@ -15,6 +15,11 @@ export interface IDropDownProps extends IAbsolutePositioningInputProps {
|
|
|
15
15
|
* @example MyCustomView
|
|
16
16
|
*/
|
|
17
17
|
view?: any;
|
|
18
|
+
/**
|
|
19
|
+
* В каком случае закрывать DropDown. По-умолчанию - `click-away`
|
|
20
|
+
* @example click-any
|
|
21
|
+
*/
|
|
22
|
+
closeMode?: 'click-away' | 'click-any';
|
|
18
23
|
}
|
|
19
24
|
export interface IDropDownViewProps extends IDropDownProps, IAbsolutePositioningOutputProps {
|
|
20
25
|
/**
|
|
@@ -36,15 +36,23 @@ function DropDown(props) {
|
|
|
36
36
|
// Outside click -> close
|
|
37
37
|
var forwardedRef = react_1.useRef(null);
|
|
38
38
|
react_use_1.useClickAway(forwardedRef, function (event) {
|
|
39
|
-
if (
|
|
40
|
-
if (
|
|
41
|
-
props.onClose
|
|
39
|
+
if (props.closeMode === 'click-away') {
|
|
40
|
+
if (isManualControl) {
|
|
41
|
+
if (!childRef.current.contains(event.target) && props.onClose) {
|
|
42
|
+
props.onClose();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
onHide();
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
|
|
49
|
+
});
|
|
50
|
+
// Any click -> close
|
|
51
|
+
react_use_1.useEvent('click', react_1.useCallback(function () {
|
|
52
|
+
if (isComponentExist && isComponentVisible && props.closeMode === 'click-any') {
|
|
45
53
|
onHide();
|
|
46
54
|
}
|
|
47
|
-
});
|
|
55
|
+
}, [isComponentExist, isComponentVisible, onHide, props.closeMode]));
|
|
48
56
|
var calculatePosition = react_1.useCallback(function (componentSize) {
|
|
49
57
|
calculateAbsolutePosition(position, childRef.current, componentSize);
|
|
50
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -68,7 +76,7 @@ function DropDown(props) {
|
|
|
68
76
|
isComponentExist && (
|
|
69
77
|
// TODO Change Portal to global
|
|
70
78
|
React.createElement(TooltipPortalInner_1["default"], null,
|
|
71
|
-
React.createElement(DropDownView, { className: props.className, forwardedRef: forwardedRef, content: props.content, position: position, style: style, calculatePosition: calculatePosition, isComponentVisible: isComponentVisible })))));
|
|
79
|
+
React.createElement(DropDownView, { className: props.className, forwardedRef: forwardedRef, content: props.content, position: position, style: style, calculatePosition: calculatePosition, isComponentVisible: isComponentVisible, onClose: onHide })))));
|
|
72
80
|
}
|
|
73
81
|
DropDown.defaultProps = {
|
|
74
82
|
autoPositioning: false,
|