import { useRef, useState } from "react"; import { DraggableProvidedDragHandleProps } from "@hello-pangea/dnd"; import { LucideIcon, X } from "lucide-react"; import { IIssueLabel } from "@plane/types"; //ui import { CustomMenu } from "@plane/ui"; //types import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; //hooks //components import { DragHandle } from "./drag-handle"; 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[]; dragHandleProps: DraggableProvidedDragHandleProps; handleLabelDelete: (label: IIssueLabel) => void; isLabelGroup?: boolean; } export const LabelItemBlock = (props: ILabelItemBlock) => { const { label, isDragging, customMenuItems, dragHandleProps, handleLabelDelete, isLabelGroup } = 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 && (
)}
); };