"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var classnames_1 = __importDefault(require("classnames"));
var Icon_1 = require("../Icon");
var ColumnItem = /** @class */ (function (_super) {
    __extends(ColumnItem, _super);
    function ColumnItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.getClassNames = function () {
            var _a = _this.props, isSelected = _a.isSelected, isPrimary = _a.isPrimary;
            return classnames_1.default('rc-column-tree-view-item', {
                'rc-column-tree-view-item-selected': isSelected,
                'rc-column-tree-view-item-selected-active': isSelected && isPrimary
            });
        };
        _this.handleSelect = function () {
            var _a = _this.props, id = _a.id, onSelect = _a.onSelect;
            onSelect(id);
        };
        return _this;
    }
    ColumnItem.prototype.render = function () {
        var _a = this.props, name = _a.name, numChildren = _a.numChildren, index = _a.index;
        var childrenCount = numChildren > 0 ? " (" + numChildren + ")" : null;
        return (react_1.default.createElement("button", { title: name, onClick: this.handleSelect, className: this.getClassNames(), "data-test-automation-id": "columnTreeViewItem" + index },
            react_1.default.createElement("div", { className: "rc-column-tree-view-item-name" },
                name,
                childrenCount),
            react_1.default.createElement(Icon_1.Icon, { name: "chevron-right-small" })));
    };
    ColumnItem.propTypes = {
        id: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]).isRequired,
        name: prop_types_1.default.string.isRequired,
        isSelected: prop_types_1.default.bool,
        isPrimary: prop_types_1.default.bool,
        numChildren: prop_types_1.default.number,
        onSelect: prop_types_1.default.func,
        index: prop_types_1.default.number.isRequired
    };
    ColumnItem.defaultProps = {
        isSelected: false,
        isPrimary: false,
        numChildren: 0,
        onSelect: function (id) { }
    };
    return ColumnItem;
}(react_1.PureComponent));
exports.ColumnItem = ColumnItem;
//# sourceMappingURL=ColumnItem.js.map