@codacy/ui-components 0.65.93 → 0.65.94
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.
|
@@ -12,7 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _Dropdown = require("../Dropdown.styles");
|
|
13
13
|
var _Dropdown2 = require("../Dropdown");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
var _excluded = ["children", "onClick", "disabled", "automaticClose", "value", "active"];
|
|
15
|
+
var _excluded = ["children", "onClick", "disabled", "automaticClose", "value", "href", "active"];
|
|
16
16
|
var DropdownItem = exports.DropdownItem = function DropdownItem(_ref) {
|
|
17
17
|
var children = _ref.children,
|
|
18
18
|
onClick = _ref.onClick,
|
|
@@ -21,17 +21,19 @@ var DropdownItem = exports.DropdownItem = function DropdownItem(_ref) {
|
|
|
21
21
|
_ref$automaticClose = _ref.automaticClose,
|
|
22
22
|
automaticClose = _ref$automaticClose === void 0 ? true : _ref$automaticClose,
|
|
23
23
|
value = _ref.value,
|
|
24
|
+
href = _ref.href,
|
|
24
25
|
active = _ref.active,
|
|
25
26
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
26
27
|
var dropdownContext = (0, _Dropdown2.useDropdownContext)();
|
|
27
28
|
var handleClick = (0, _react.useCallback)(function (event) {
|
|
29
|
+
if (href) window.open(href, '_blank');
|
|
28
30
|
if (event) event.stopPropagation();
|
|
29
31
|
if (!disabled) {
|
|
30
32
|
if (!!value) dropdownContext.setValue(value);
|
|
31
33
|
if (!!onClick) onClick(value);
|
|
32
34
|
}
|
|
33
35
|
if (automaticClose) dropdownContext.setOpen(false);
|
|
34
|
-
}, [automaticClose, disabled, dropdownContext, onClick, value]);
|
|
36
|
+
}, [automaticClose, disabled, dropdownContext, onClick, value, href]);
|
|
35
37
|
var isActive = active === undefined ? !!value && value === dropdownContext.value : active;
|
|
36
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dropdown.DropdownItemWrapper, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
|
|
37
39
|
onClick: handleClick,
|
|
@@ -52,6 +52,8 @@ export interface DropdownItemProps extends ContainerComponentProps, BoxProps {
|
|
|
52
52
|
disabled?: boolean;
|
|
53
53
|
/** Inner value of the item */
|
|
54
54
|
value?: DropdownValueType;
|
|
55
|
+
/** link of the item */
|
|
56
|
+
href?: string;
|
|
55
57
|
/** Is the item active or selected? */
|
|
56
58
|
active?: boolean;
|
|
57
59
|
/** Close dropdown automatically when interacting with it */
|