"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TermSearch = void 0;
const react_1 = __importDefault(require("react"));
const Input_1 = require("../input/Input");
const Button_1 = require("../button/Button");
const TermSearch = ({ className, termValue, setTermValue, pushTerm, allTerms, type, label, placeholder, labelStyle, name, color, icon, size, iconSize, tipContent, removeFilterItem, }) => {
    const emptyOrWhitespace = /^\s*$/;
    const disabled = emptyOrWhitespace.test(termValue) || allTerms.includes(termValue);
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement("div", { className: className + ' term-input' },
            react_1.default.createElement(Input_1.Input, { type: type, label: label, placeholder: placeholder, labelStyle: labelStyle, name: name, value: termValue, setValue: setTermValue, tipContent: tipContent, onKeyDown: e => e.keyCode === 13 &&
                    !disabled &&
                    pushTerm(termValue) }),
            react_1.default.createElement(Button_1.Button, { primary: true, disabled: disabled, color: color, icon: icon, iconOnly: true, iconSize: iconSize, size: size, onClick: () => pushTerm(termValue), label: "Add Term" })),
        allTerms.length ? (react_1.default.createElement("div", { className: "term-block" },
            react_1.default.createElement("ul", { className: "active-search-terms" }, allTerms.map((term, index) => (react_1.default.createElement("li", { key: index },
                react_1.default.createElement("span", null,
                    term,
                    react_1.default.createElement("span", { onClick: () => removeFilterItem(name, term) }, "\u00D7")))))))) : null));
};
exports.TermSearch = TermSearch;
