import * as React from "react" import { DownloadIcon } from "lucide-react" import { Button, type ButtonProps } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" export type TableExportOption = { key: string label: React.ReactNode description?: React.ReactNode icon?: React.ReactNode disabled?: boolean } export type TableExportMenuProps = Omit & { options?: TableExportOption[] label?: React.ReactNode menuLabel?: React.ReactNode onExport?: (option: TableExportOption) => void renderOption?: (option: TableExportOption) => React.ReactNode } const defaultExportOptions: TableExportOption[] = [ { key: "csv", label: "CSV" }, { key: "xlsx", label: "Excel" }, { key: "pdf", label: "PDF" }, ] function TableExportMenu({ options = defaultExportOptions, label = "Export", menuLabel = "Export as", onExport, renderOption, children, ...props }: TableExportMenuProps) { return ( }> {children ?? label} {menuLabel && {menuLabel}} {options.map((option) => ( onExport?.(option)}> {renderOption?.(option) ?? ( <> {option.icon} {option.label} {option.description && {option.description}} )} ))} ) } export { TableExportMenu }