DocSpace-buildtools/packages/asc-web-components/drop-down-item/index.js

67 lines
1.4 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import { ReactSVG } from "react-svg";
import { StyledDropdownItem, IconWrapper } from "./styled-drop-down-item";
const DropDownItem = (props) => {
//console.log("DropDownItem render");
const {
isSeparator,
label,
icon,
children,
disabled,
onClick,
className,
} = props;
const onClickAction = (e) => {
onClick && !disabled && onClick(e);
};
return (
<StyledDropdownItem
{...props}
className={className}
onClick={onClickAction}
disabled={disabled}
>
{icon && (
<IconWrapper>
<ReactSVG src={icon} className="drop-down-item_icon" />
</IconWrapper>
)}
{isSeparator ? "\u00A0" : label ? label : children && children}
</StyledDropdownItem>
);
};
2019-06-24 13:18:47 +00:00
DropDownItem.propTypes = {
isSeparator: PropTypes.bool,
isHeader: PropTypes.bool,
tabIndex: PropTypes.number,
label: PropTypes.string,
disabled: PropTypes.bool,
icon: PropTypes.string,
noHover: PropTypes.bool,
onClick: PropTypes.func,
children: PropTypes.any,
className: PropTypes.string,
id: PropTypes.string,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
textOverflow: PropTypes.bool,
2019-06-24 13:18:47 +00:00
};
DropDownItem.defaultProps = {
isSeparator: false,
isHeader: false,
tabIndex: -1,
label: "",
disabled: false,
noHover: false,
textOverflow: false,
2019-06-24 13:18:47 +00:00
};
export default DropDownItem;