import { j as jsxRuntimeExports } from '../../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js';
import { forwardRef } from 'react';
import { Search } from '../../search/search.js';
import { useDataTable } from '../hooks/useDataTable.js';

const TableSearch = forwardRef(({ ...props }, ref) => {
    const { updateTableQuery, tableQuery } = useDataTable();
    const handleSearch = (e) => {
        const value = e.target.value;
        updateTableQuery((query) => {
            return {
                ...query,
                search: value,
            };
        });
    };
    const handleClear = () => {
        updateTableQuery((query) => {
            return {
                ...query,
                search: "",
            };
        });
    };
    return (jsxRuntimeExports.jsx(Search, { ...props, ref: ref, onChange: handleSearch, value: tableQuery?.search, onClear: handleClear }));
});

export { TableSearch };
//# sourceMappingURL=search.js.map
