"use client"; import { MutableRefObject, useRef, useState } from "react"; import { LucideIcon, X } from "lucide-react"; // types import { IIssueLabel } from "@plane/types"; // ui import { CustomMenu, DragHandle } from "@plane/ui"; // helpers import { cn } from "@/helpers/common.helper"; // hooks import useOutsideClickDetector from "@/hooks/use-outside-click-detector"; // components import { LabelName } from "./label-name"; 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 && (
)}
); };