import React from "react"; import { ReactSVG } from "react-svg"; import { useTranslation } from "react-i18next"; import RightArrowReactSvgUrl from "PUBLIC_DIR/images/right.arrow.react.svg?url"; import ArrowLeftReactUrl from "PUBLIC_DIR/images/arrow-left.react.svg?url"; import { ToggleButton } from "../toggle-button"; import { Badge } from "../badge"; import { StyledDropdownItem, IconWrapper, WrapperToggle, WrapperBadge, ElementWrapper, } from "./DropDownItem.styled"; import { DropDownItemProps } from "./DropDownItem.types"; const DropDownItem = (props: DropDownItemProps) => { const { isSeparator, isHeader, withHeaderArrow, headerArrowAction, icon, children, disabled, className, fillIcon = true, isSubMenu, isActive, withoutIcon, noHover, isSelected, isActiveDescendant, isBeta, additionalElement, } = props; const { t } = useTranslation(["Settings"]); const { withToggle, checked, onClick, onClickSelectedItem, label, ...rest } = props; const onClickAction = ( e: React.MouseEvent | React.ChangeEvent, ) => { if (onClick && !disabled) onClick(e); if (onClickSelectedItem && isSelected) onClickSelectedItem(); }; const stopPropagation = ( event: React.ChangeEvent | React.MouseEvent, ) => { event.stopPropagation(); }; const onChange = (event: React.ChangeEvent) => { stopPropagation(event); onClickAction(event); }; return ( {isHeader && withHeaderArrow && ( )} {icon && ( {!withoutIcon ? ( (!icon.includes("images/") && !icon.includes(".svg")) || icon.includes("webplugins") ? ( plugin-logo ) : ( ) ) : null} )} {isSeparator ? ( "\u00A0" ) : label ? ( {label} ) : ( children && children )} {isSubMenu && ( )} {withToggle && ( )} {isBeta && ( )} {additionalElement && ( {additionalElement} )} ); }; DropDownItem.defaultProps = { isSeparator: false, isHeader: false, tabIndex: -1, label: "", disabled: false, noHover: false, textOverflow: false, fillIcon: true, isSubMenu: false, isActive: false, withoutIcon: false, height: 32, heightTablet: 36, }; export { DropDownItem };