"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormulaPicker = void 0;
var tslib_1 = require("tslib");
var uncontrollable_1 = require("uncontrollable");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var Editor_1 = require("./Editor");
var helper_1 = require("../../utils/helper");
var PickerContainer_1 = (0, tslib_1.__importDefault)(require("../PickerContainer"));
var Editor_2 = (0, tslib_1.__importDefault)(require("./Editor"));
var ResultBox_1 = (0, tslib_1.__importDefault)(require("../ResultBox"));
var icons_1 = require("../icons");
var theme_1 = require("../../theme");
var locale_1 = require("../../locale");
var FormulaPicker = /** @class */ (function (_super) {
    (0, tslib_1.__extends)(FormulaPicker, _super);
    function FormulaPicker() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FormulaPicker.prototype.handleConfirm = function (value) {
        var _a, _b;
        (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value);
    };
    FormulaPicker.prototype.render = function () {
        var _a = this.props, cx = _a.classnames, value = _a.value, __ = _a.translate, disabled = _a.disabled, className = _a.className, onChange = _a.onChange, size = _a.size, borderMode = _a.borderMode, rest = (0, tslib_1.__rest)(_a, ["classnames", "value", "translate", "disabled", "className", "onChange", "size", "borderMode"]);
        return (react_1.default.createElement(PickerContainer_1.default, { showTitle: false, bodyRender: function (_a) {
                var onClose = _a.onClose, value = _a.value, onChange = _a.onChange;
                return react_1.default.createElement(Editor_2.default, (0, tslib_1.__assign)({}, rest, { value: value, onChange: onChange }));
            }, value: value, onConfirm: this.handleConfirm, size: 'md' }, function (_a) {
            var onClick = _a.onClick, isOpened = _a.isOpened;
            return (react_1.default.createElement(ResultBox_1.default, { className: cx('FormulaPicker', className, isOpened ? 'is-active' : ''), allowInput: false, result: Editor_1.FormulaEditor.highlightValue(value, rest.variables, rest.functions), onResultChange: helper_1.noop, onResultClick: onClick, disabled: disabled, borderMode: borderMode },
                react_1.default.createElement("span", { className: cx('FormulaPicker-icon') },
                    react_1.default.createElement(icons_1.Icon, { icon: "pencil", className: "icon" }))));
        }));
    };
    (0, tslib_1.__decorate)([
        helper_1.autobind,
        (0, tslib_1.__metadata)("design:type", Function),
        (0, tslib_1.__metadata)("design:paramtypes", [Object]),
        (0, tslib_1.__metadata)("design:returntype", void 0)
    ], FormulaPicker.prototype, "handleConfirm", null);
    return FormulaPicker;
}(react_1.default.Component));
exports.FormulaPicker = FormulaPicker;
exports.default = (0, theme_1.themeable)((0, locale_1.localeable)((0, uncontrollable_1.uncontrollable)(FormulaPicker, {
    value: 'onChange'
})));
//# sourceMappingURL=./components/formula/Picker.js.map
