@codacy/ui-components 0.64.4 → 0.64.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
-
var _excluded = ["children", "onClick", "disabled", "value", "active"];
|
|
2
|
+
var _excluded = ["children", "onClick", "disabled", "automaticClose", "value", "active"];
|
|
3
3
|
import React, { useCallback } from 'react';
|
|
4
4
|
import { DropdownItemWrapper } from '../Dropdown.styles';
|
|
5
5
|
import { useDropdownContext } from '../Dropdown';
|
|
@@ -8,6 +8,8 @@ export var DropdownItem = function DropdownItem(_ref) {
|
|
|
8
8
|
onClick = _ref.onClick,
|
|
9
9
|
_ref$disabled = _ref.disabled,
|
|
10
10
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
11
|
+
_ref$automaticClose = _ref.automaticClose,
|
|
12
|
+
automaticClose = _ref$automaticClose === void 0 ? true : _ref$automaticClose,
|
|
11
13
|
value = _ref.value,
|
|
12
14
|
active = _ref.active,
|
|
13
15
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -19,8 +21,8 @@ export var DropdownItem = function DropdownItem(_ref) {
|
|
|
19
21
|
if (!!onClick) onClick(value);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
dropdownContext.setOpen(false);
|
|
23
|
-
}, [disabled, dropdownContext, onClick, value]);
|
|
24
|
+
if (automaticClose) dropdownContext.setOpen(false);
|
|
25
|
+
}, [automaticClose, disabled, dropdownContext, onClick, value]);
|
|
24
26
|
var isActive = active === undefined ? !!value && value === dropdownContext.value : active;
|
|
25
27
|
return /*#__PURE__*/React.createElement(DropdownItemWrapper, Object.assign({}, props, {
|
|
26
28
|
onClick: handleClick,
|
|
@@ -54,6 +54,8 @@ export interface DropdownItemProps extends ContainerComponentProps, BoxProps {
|
|
|
54
54
|
value?: DropdownValueType;
|
|
55
55
|
/** Is the item active or selected? */
|
|
56
56
|
active?: boolean;
|
|
57
|
+
/** Close dropdown automatically when interacting with it */
|
|
58
|
+
automaticClose?: boolean;
|
|
57
59
|
/** Click handler */
|
|
58
60
|
onClick?: (value?: DropdownValueType) => void;
|
|
59
61
|
}
|