import { j as jsxRuntimeExports } from '../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js';
import { PlusIcon } from '../node_modules/.pnpm/@radix-ui_react-icons@1.3.0_react@18.2.0/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js';
import { Button } from '../button/button.js';
import { DropdownMenu } from '../dropdown-menu/dropdown-menu.js';
import { Flex } from '../flex/flex.js';
import { useTable } from './hooks/useTable.js';

function DataTableFilterOptions({ children, ...props }) {
    const { table, filteredColumns, addFilterColumn, isLoading } = useTable();
    const availableColumns = table
        .getAllColumns()
        .filter((column) => typeof column.accessorFn !== "undefined" &&
        column.getCanHide() &&
        column.getCanFilter())
        .filter((column) => !filteredColumns.includes(column.id));
    return (jsxRuntimeExports.jsxs(DropdownMenu, { children: [jsxRuntimeExports.jsx(DropdownMenu.Trigger, { asChild: true, disabled: isLoading, children: jsxRuntimeExports.jsx(Button, { variant: "ghost", ...props, children: children || (jsxRuntimeExports.jsxs(Flex, { gap: "small", align: "center", justify: "center", children: [jsxRuntimeExports.jsx(PlusIcon, { width: 12, height: "12" }), " Filter"] })) }) }), availableColumns.length ? (jsxRuntimeExports.jsxs(DropdownMenu.Content, { align: "end", className: "w-[150px]", children: [jsxRuntimeExports.jsx(DropdownMenu.Label, { children: "Filter column" }), jsxRuntimeExports.jsx(DropdownMenu.Separator, {}), availableColumns.map((column) => {
                        const columnHeader = column?.columnDef?.header;
                        const columnName = (typeof columnHeader === "string" && columnHeader) || column.id;
                        return (jsxRuntimeExports.jsx(DropdownMenu.Item, { onSelect: () => addFilterColumn(column.id), children: columnName }, column.id));
                    })] })) : null] }));
}

export { DataTableFilterOptions };
//# sourceMappingURL=DataTableFilterOptions.js.map
