"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuickSearchInput = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_redux_1 = require("react-redux");
const QuickSearchRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/QuickSearchRedux"));
const AdaptableFormControlTextClear_1 = require("../Components/Forms/AdaptableFormControlTextClear");
const useQuickSearchDebounced_1 = require("./useQuickSearchDebounced");
const AdaptableContext_1 = require("../AdaptableContext");
const QuickSearchInput = (props) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const QuickSearchText = (0, react_redux_1.useSelector)((state) => state.QuickSearch.QuickSearchText);
    const dispatch = (0, react_redux_1.useDispatch)();
    const onRunQuickSearch = react_1.default.useCallback((newQuickSearchText) => dispatch(QuickSearchRedux.QuickSearchRun(newQuickSearchText)), []);
    const [searchText, search] = (0, useQuickSearchDebounced_1.useQuickSearchDebounced)({
        QuickSearchText,
        onRunQuickSearch,
    });
    return (react_1.default.createElement(AdaptableFormControlTextClear_1.AdaptableFormControlTextClear, { type: "text", autoFocus: props.autoFocus, placeholder: adaptable.api.optionsApi.getQuickSearchOptions().quickSearchPlaceholder, className: props.className, value: searchText, OnTextChange: search, style: { height: '100%' }, inputStyle: { width: props.width ?? '10rem' } }));
};
exports.QuickSearchInput = QuickSearchInput;
