import React from "react"; import { cn } from "@/src/utils/tailwind"; import { X } from "lucide-react"; import { Button } from "@/src/components/ui/button"; import { Command as CommandPrimitive } from "cmdk"; import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture"; type TagInputProps = React.ComponentPropsWithoutRef< typeof CommandPrimitive.Input > & { selectedTags: string[]; setSelectedTags?: (tags: string[]) => void; allowTagRemoval?: boolean; }; export const TagInput = React.forwardRef< React.ElementRef, TagInputProps >( ( { className, selectedTags, setSelectedTags, allowTagRemoval = false, ...props }, ref, ) => { const capture = usePostHogClientCapture(); const removeTag = (tagToRemove: string) => { if (setSelectedTags && allowTagRemoval) { setSelectedTags(selectedTags.filter((t) => t !== tagToRemove)); capture("tag:remove_tag", { name: tagToRemove, }); } }; return (
{selectedTags.length > 0 && (
{selectedTags.map((tag: string) => ( ))}
)}
); }, ); TagInput.displayName = CommandPrimitive.Input.displayName;