import DictionaryForm, { ValueType } from "../Dictionary/Dictionary";
import FieldType from "../Types/FieldType";
import React from "react";
const JSONFilter = (props) => {
    const filter = props.filter;
    const filterData = Object.assign({}, props.filterData);
    if (filter.type === FieldType.JSON) {
        return (React.createElement(DictionaryForm, { keys: props.jsonKeys, valueSuggestions: props.jsonValueSuggestions, onKeySelected: props.onJsonKeySelected, isLoadingKeys: props.isLoadingJsonKeys, loadingValueKeys: props.loadingJsonValueKeys, onValueSearch: props.onJsonValueSearch, enableOperators: props.enableOperators, addButtonSuffix: filter.title, keyPlaceholder: "Key", valuePlaceholder: "Value", valueTypes: [ValueType.Text], initialValue: filterData[filter.key] || {}, onChange: (value) => {
                // if no keys in the dictionary, remove the filter
                if (Object.keys(value).length > 0) {
                    filterData[filter.key] = value;
                }
                else {
                    delete filterData[filter.key];
                }
                if (props.onFilterChanged) {
                    props.onFilterChanged(filterData);
                }
            } }));
    }
    return React.createElement(React.Fragment, null);
};
export default JSONFilter;
//# sourceMappingURL=JSONFilter.js.map