'use client'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { cn } from '@/lib/utils'; import { type VariantProps, cva } from 'class-variance-authority'; import { MoreHorizontal } from 'lucide-react'; import Link from 'next/link'; import { type HTMLAttributes, type ReactNode, useState } from 'react'; const dataTableRowActionsVariants = cva('flex items-center space-x-2', { variants: { variant: { default: '', }, }, defaultVariants: { variant: 'default', }, }); interface DataTableColumnCellRenderProps { close: () => void; } interface DataTableColumnCellProps extends Omit, 'children'>, VariantProps { detailUrl?: string; children?: ReactNode | undefined | ((renderProps: DataTableColumnCellRenderProps) => ReactNode); } export function DataTableRowActions({ className, variant = 'default', children, detailUrl, ...props }: DataTableColumnCellProps) { const [isOpen, setIsOpen] = useState(false); if (!children && !detailUrl) { return null; } return (
{detailUrl && ( )} {children && ( {typeof children === 'function' ? children({ close: () => setIsOpen(false) }) : children} )}
); }