text: var _extends=Object.assign||function(a){for(var c,b=1;b<arguments.length;b++)for(var d in c=arguments[b],c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d]);return a},_createClass=function(){function a(b,c){for(var f,d=0;d<c.length;d++)f=c[d],f.enumerable=f.enumerable||!1,f.configurable=!0,'value'in f&&(f.writable=!0),Object.defineProperty(b,f.key,f)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}import PropTypes from'prop-types';import React,{Component}from'react';import SearchBox from'../components/SearchBox';var itemsPropType=PropTypes.arrayOf(PropTypes.shape({value:PropTypes.any,label:PropTypes.string.isRequired,items:function items(){return itemsPropType.apply(void 0,arguments)}})),List=function(a){function b(){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return c.defaultProps={isFromSearch:!1},c.onShowMoreClick=function(){c.setState(function(d){return{extended:!d.extended}})},c.getLimit=function(){var d=c.props,f=d.limitMin,g=d.limitMax,h=c.state.extended;return h?g:f},c.resetQuery=function(){c.setState({query:''})},c.renderItem=function(d,f){var g=d.items&&React.createElement('div',c.props.cx('itemItems'),d.items.slice(0,c.getLimit()).map(function(h){return c.renderItem(h,d)}));return React.createElement('div',_extends({key:d.key||d.label},c.props.cx('item',d.isRefined&&'itemSelected',d.noRefinement&&'itemNoRefinement',g&&'itemParent',g&&d.isRefined&&'itemSelectedParent')),c.props.renderItem(d,f),g)},c.state={extended:!1,query:''},c}return _inherits(b,a),_createClass(b,[{key:'renderShowMore',value:function renderShowMore(){var c=this.props,d=c.showMore,f=c.translate,g=c.cx,h=this.state.extended,j=this.props.limitMin>=this.props.items.length;return d?React.createElement('button',_extends({disabled:j},g('showMore',j&&'showMoreDisabled'),{onClick:this.onShowMoreClick}),f('showMore',h)):null}},{key:'renderSearchBox',value:function renderSearchBox(){var c=this,d=this.props,f=d.cx,g=d.searchForItems,h=d.isFromSearch,j=d.translate,k=d.items,l=d.selectItem,m=0===k.length&&''!==this.state.query?React.createElement('div',f('noResults'),j('noResults')):null;return React.createElement('div',f('SearchBox'),React.createElement(SearchBox,{currentRefinement:this.state.query,refine:function refine(n){c.setState({query:n}),g(n)},focusShortcuts:[],translate:j,onSubmit:function onSubmit(n){n.preventDefault(),n.stopPropagation(),h&&l(k[0],c.resetQuery)}}),m)}},{key:'render',value:function render(){var c=this,d=this.props,f=d.cx,g=d.items,h=d.withSearchBox,j=d.canRefine,k=h?this.renderSearchBox():null;if(0===g.length)return React.createElement('div',f('root',!j&&'noRefinement'),k);var l=this.getLimit();return React.createElement('div',f('root',!this.props.canRefine&&'noRefinement'),k,React.createElement('div',f('items'),g.slice(0,l).map(function(m){return c.renderItem(m,c.resetQuery)})),this.renderShowMore())}}]),b}(Component);List.propTypes={cx:PropTypes.func.isRequired,translate:PropTypes.func,items:itemsPropType,renderItem:PropTypes.func.isRequired,selectItem:PropTypes.func,showMore:PropTypes.bool,limitMin:PropTypes.number,limitMax:PropTypes.number,limit:PropTypes.number,show:PropTypes.func,searchForItems:PropTypes.func,withSearchBox:PropTypes.bool,isFromSearch:PropTypes.bool,canRefine:PropTypes.bool};export default List;