'use strict';

var jsxRuntime = require('../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.cjs');
var reactIcons_esm = require('../node_modules/.pnpm/@radix-ui_react-icons@1.3.0_react@18.2.0/node_modules/@radix-ui/react-icons/dist/react-icons.esm.cjs');
var button = require('../button/button.cjs');
var dropdownMenu = require('../dropdown-menu/dropdown-menu.cjs');
var flex = require('../flex/flex.cjs');
var useTable = require('./hooks/useTable.cjs');

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

exports.DataTableFilterOptions = DataTableFilterOptions;
//# sourceMappingURL=DataTableFilterOptions.cjs.map
