"use client";
import { jsx } from 'react/jsx-runtime';
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 (jsx(Search, { ...props, ref: ref, onChange: handleSearch, value: tableQuery?.search, onClear: handleClear }));
});

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