import { MutableRefObject, useRef, useState } from "react"; import { LucideIcon, X } from "lucide-react"; import { IIssueLabel } from "@plane/types"; //ui import { CustomMenu, DragHandle } from "@plane/ui"; //types import { cn } from "@/helpers/common.helper"; import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; //hooks //components import { LabelName } from "./label-name"; //types export interface ICustomMenuItem { CustomIcon: LucideIcon; onClick: (label: IIssueLabel) => void; isVisible: boolean; text: string; key: string; } interface ILabelItemBlock { label: IIssueLabel; isDragging: boolean; customMenuItems: ICustomMenuItem[]; handleLabelDelete: (label: IIssueLabel) => void; isLabelGroup?: boolean; dragHandleRef: MutableRefObject; } export const LabelItemBlock = (props: ILabelItemBlock) => { const { label, isDragging, customMenuItems, handleLabelDelete, isLabelGroup, dragHandleRef } = props; // states const [isMenuActive, setIsMenuActive] = useState(false); // refs const actionSectionRef = useRef(null); useOutsideClickDetector(actionSectionRef, () => setIsMenuActive(false)); return (
{customMenuItems.map( ({ isVisible, onClick, CustomIcon, text, key }) => isVisible && ( onClick(label)}> {text} ) )} {!isLabelGroup && (
)}
); };