import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ColumnItem } from './ColumnItem';
export var ItemType = PropTypes.shape({
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
  name: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
  parentId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
  raw: PropTypes.any
});
export var Column =
/*#__PURE__*/
function (_Component) {
  _inheritsLoose(Column, _Component);

  function Column() {
    var _this;

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _Component.call.apply(_Component, [this].concat(args)) || this;

    _defineProperty(_assertThisInitialized(_this), "renderItem", function (_ref, index) {
      var id = _ref.id,
          name = _ref.name;
      var _this$props = _this.props,
          selectedId = _this$props.selectedId,
          isActive = _this$props.isActive,
          countChildren = _this$props.countChildren,
          onSelect = _this$props.onSelect;
      return React.createElement(ColumnItem, {
        key: id,
        id: id,
        name: name,
        isSelected: id === selectedId,
        isPrimary: id === selectedId && isActive,
        numChildren: countChildren(id),
        onSelect: onSelect,
        index: index
      });
    });

    return _this;
  }

  var _proto = Column.prototype;

  _proto.render = function render() {
    var _this$props2 = this.props,
        items = _this$props2.items,
        index = _this$props2.index;
    return React.createElement("div", {
      className: "rc-column-tree-view-col",
      "data-test-automation-id": "columnTreeViewColumn" + index
    }, React.createElement("div", {
      className: "rc-column-tree-view-col-content"
    }, items.map(this.renderItem)));
  };

  return Column;
}(Component);

_defineProperty(Column, "propTypes", {
  isActive: PropTypes.bool,
  selectedId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
  items: PropTypes.arrayOf(ItemType),
  onSelect: PropTypes.func,
  countChildren: PropTypes.func,
  index: PropTypes.number.isRequired
});

_defineProperty(Column, "defaultProps", {
  isActive: false,
  selectedId: null,
  items: [],
  onSelect: function onSelect(id) {},
  countChildren: function countChildren(id) {
    return 0;
  }
});