"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VariableList = void 0;
var tslib_1 = require("tslib");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var classnames_1 = (0, tslib_1.__importDefault)(require("classnames"));
var GroupedSelection_1 = (0, tslib_1.__importDefault)(require("../GroupedSelection"));
var Tabs_1 = tslib_1.__importStar(require("../Tabs"));
var TreeSelection_1 = (0, tslib_1.__importDefault)(require("../TreeSelection"));
function VariableList(props) {
    var list = props.data, className = props.className, _a = props.tabsMode, tabsMode = _a === void 0 ? 'card' : _a, themePrefix = props.classPrefix, itemClassName = props.itemClassName, selectMode = props.selectMode, onSelect = props.onSelect;
    var classPrefix = "".concat(themePrefix, "FormulaEditor-VariableList");
    var itemRender = props.itemRender && typeof props.itemRender === 'function'
        ? props.itemRender
        : function (option, states) {
            return (react_1.default.createElement("span", { className: (0, classnames_1.default)("".concat(classPrefix, "-item"), itemClassName) },
                react_1.default.createElement("label", null, option.label),
                (option === null || option === void 0 ? void 0 : option.tag) ? (react_1.default.createElement("span", { className: (0, classnames_1.default)("".concat(classPrefix, "-item-tag")) }, option.tag)) : null));
        };
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)(className, { 'is-scrollable': selectMode !== 'tabs' }) }, selectMode === 'tabs' ? (react_1.default.createElement(Tabs_1.default, { tabsMode: tabsMode, className: (0, classnames_1.default)("".concat(classPrefix, "-base ").concat(classPrefix, "-tabs")) }, list.map(function (item, index) { return (react_1.default.createElement(Tabs_1.Tab, { className: (0, classnames_1.default)("".concat(classPrefix, "-tab")), eventKey: index, key: index, title: item.label },
        react_1.default.createElement(VariableList, { className: (0, classnames_1.default)("".concat(classPrefix, "-sub")), itemRender: itemRender, selectMode: item.selectMode, data: item.children, onSelect: onSelect }))); }))) : selectMode === 'tree' ? (react_1.default.createElement(TreeSelection_1.default, { itemRender: itemRender, className: (0, classnames_1.default)("".concat(classPrefix, "-base")), multiple: false, options: list, onChange: function (item) { return onSelect === null || onSelect === void 0 ? void 0 : onSelect(item); } })) : (react_1.default.createElement(GroupedSelection_1.default, { itemRender: itemRender, className: (0, classnames_1.default)("".concat(classPrefix, "-base")), multiple: false, options: list, onChange: function (item) { return onSelect === null || onSelect === void 0 ? void 0 : onSelect(item); } }))));
}
exports.VariableList = VariableList;
//# sourceMappingURL=./components/formula/VariableList.js.map
