"use strict";

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

var _react = _interopRequireDefault(require("react"));

var Components = _interopRequireWildcard(require("@patternplate/components"));

var _searchResult = _interopRequireDefault(require("./search-result"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

class SearchResultList extends _react.default.Component {
  render() {
    const props = this.props;
    const activeId = this.props.activeItem ? this.props.activeItem.id : undefined;
    const withComponents = props.components.length > 0;
    const withDocs = props.docs.length > 0;
    return _react.default.createElement(Components.Search.SearchResultList, {
      ref: this.props.getListRef
    }, withDocs > 0 && _react.default.createElement(Components.Search.SearchResultListHeading, null, "Docs (", props.docs.length, ")"), props.docs.map(d => _react.default.createElement(_searchResult.default, {
      key: d.id,
      item: d,
      activeId: activeId,
      onActivate: this.props.onActivate,
      onScrollRequest: this.props.onScrollRequest,
      type: "doc"
    })), withComponents > 0 && _react.default.createElement(Components.Search.SearchResultListHeading, {
      navigationEnabled: props.navigationEnabled
    }, "Components (", props.components.length, ")"), props.components.map(c => _react.default.createElement(_searchResult.default, {
      key: c.id,
      item: c,
      activeId: activeId,
      onActivate: this.props.onActivate,
      onScrollRequest: this.props.onScrollRequest,
      type: "pattern"
    })));
  }

}

exports.default = SearchResultList;
//# sourceMappingURL=search-result-list.js.map