"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var map = require("lodash/map");
var React = require("react");
var Grid_1 = require("../Grid");
var PineTypes_1 = require("../PineTypes");
var Select_1 = require("../Select");
var FilterInput = function (props) {
    var PineTypeInput = PineTypes_1.default[props.type].Edit;
    return (React.createElement(PineTypeInput, { schema: props.schema, value: props.value, operator: props.operator, onChange: props.onChange }));
};
var FilterForm = function (props) {
    var handleEditChange = props.handleEditChange, inputModels = props.inputModels, name = props.name, value = props.value, operator = props.operator, schema = props.schema;
    return (React.createElement(Grid_1.Flex, null,
        React.createElement(Select_1.default, { mr: 20, value: name, onChange: function (e) {
                return handleEditChange(e.target.value, 'name');
            } }, map(inputModels, function (_a) {
            var name = _a.name, label = _a.label;
            return (React.createElement("option", { key: name, value: name }, label || name));
        })),
        React.createElement(Select_1.default, { mr: 20, value: operator, onChange: function (e) {
                return handleEditChange(e.target.value, 'operator');
            } }, map(inputModels[name].availableOperators, function (_a) {
            var value = _a.value, label = _a.label;
            return (React.createElement("option", { value: value, key: value }, label));
        })),
        inputModels[name].type !== 'Boolean' && (React.createElement(FilterInput, { operator: operator, schema: schema[name], value: value, onChange: function (value) { return handleEditChange(value, 'value'); }, type: inputModels[name].type, autoFocus: true }))));
};
exports.default = FilterForm;
