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 __());
    };
})();
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Icon } from '../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('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.createElement("button", { title: name, onClick: this.handleSelect, className: this.getClassNames(), "data-test-automation-id": "columnTreeViewItem" + index },
            React.createElement("div", { className: "rc-column-tree-view-item-name" },
                name,
                childrenCount),
            React.createElement(Icon, { name: "chevron-right-small" })));
    };
    ColumnItem.propTypes = {
        id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
        name: PropTypes.string.isRequired,
        isSelected: PropTypes.bool,
        isPrimary: PropTypes.bool,
        numChildren: PropTypes.number,
        onSelect: PropTypes.func,
        index: PropTypes.number.isRequired
    };
    ColumnItem.defaultProps = {
        isSelected: false,
        isPrimary: false,
        numChildren: 0,
        onSelect: function (id) { }
    };
    return ColumnItem;
}(PureComponent));
export { ColumnItem };
//# sourceMappingURL=ColumnItem.js.map