"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.OmitProps = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var React = _interopRequireWildcard(require("react"));

var _type = require("../_util/type");

var _ListItem = _interopRequireDefault(require("./ListItem"));

var OmitProps = (0, _type.tuple)('handleFilter', 'handleClear', 'checkedKeys');
exports.OmitProps = OmitProps;

var ListBody = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(ListBody, _React$Component);

  var _super = (0, _createSuper2["default"])(ListBody);

  function ListBody() {
    var _this;

    (0, _classCallCheck2["default"])(this, ListBody);
    _this = _super.apply(this, arguments);

    _this.onItemSelect = function (item) {
      var _this$props = _this.props,
          onItemSelect = _this$props.onItemSelect,
          selectedKeys = _this$props.selectedKeys;
      var checked = selectedKeys.indexOf(item.key) >= 0;
      onItemSelect(item.key, !checked);
    };

    return _this;
  }

  (0, _createClass2["default"])(ListBody, [{
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props2 = this.props,
          prefixCls = _this$props2.prefixCls,
          onScroll = _this$props2.onScroll,
          filteredRenderItems = _this$props2.filteredRenderItems,
          selectedKeys = _this$props2.selectedKeys,
          globalDisabled = _this$props2.disabled;
      return /*#__PURE__*/React.createElement("ul", {
        className: "".concat(prefixCls, "-content"),
        onScroll: onScroll
      }, filteredRenderItems.map(function (_ref) {
        var renderedEl = _ref.renderedEl,
            renderedText = _ref.renderedText,
            item = _ref.item;
        var disabled = item.disabled;
        var checked = selectedKeys.indexOf(item.key) >= 0;
        return /*#__PURE__*/React.createElement(_ListItem["default"], {
          disabled: globalDisabled || disabled,
          key: item.key,
          item: item,
          renderedText: renderedText,
          renderedEl: renderedEl,
          checked: checked,
          prefixCls: prefixCls,
          onClick: _this2.onItemSelect
        });
      }));
    }
  }]);
  return ListBody;
}(React.Component);

var ListBodyWrapper = function ListBodyWrapper(props) {
  return /*#__PURE__*/React.createElement(ListBody, props);
};

var _default = ListBodyWrapper;
exports["default"] = _default;