"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_rcEditorMention=require("rc-editor-mention"),_rcEditorMention2=_interopRequireDefault(_rcEditorMention),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_shallowequal=require("shallowequal"),_shallowequal2=_interopRequireDefault(_shallowequal),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var Mention=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var n=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onSearchChange=function(e,t){return n.props.onSearchChange?n.props.onSearchChange(e,t):n.defaultSearchChange(e)},n.onChange=function(e){n.props.onChange&&n.props.onChange(e)},n.onFocus=function(e){n.setState({focus:!0}),n.props.onFocus&&n.props.onFocus(e)},n.onBlur=function(e){n.setState({focus:!1}),n.props.onBlur&&n.props.onBlur(e)},n.focus=function(e){e&&n.mentionEle._editor.focus(e)},n.mentionRef=function(e){n.mentionEle=e},n.state={suggestions:e.suggestions,focus:!1},n}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"componentWillReceiveProps",value:function(e){var t=e.suggestions;(0,_shallowequal2.default)(t,this.props.suggestions)||this.setState({suggestions:t})}},{key:"defaultSearchChange",value:function(e){var t=e.toLowerCase(),n=(this.props.suggestions||[]).filter(function(e){return e.type&&e.type===_rcEditorMention.Nav?!e.props.value||-1!==e.props.value.toLowerCase().indexOf(t):-1!==e.toLowerCase().indexOf(t)});this.setState({suggestions:n})}},{key:"render",value:function(){var e,t=this.props,n=t.className,r=void 0===n?"":n,o=t.prefixCls,s=t.loading,i=t.placement,a=this.state,u=a.suggestions,l=a.focus,c=(0,_classnames2.default)(r,(e={},(0,_defineProperty3.default)(e,o+"-active",l),(0,_defineProperty3.default)(e,o+"-placement-top","top"===i),e)),p=s?React.createElement(_icon2.default,{type:"loading"}):this.props.notFoundContent;return React.createElement(_rcEditorMention2.default,(0,_extends3.default)({},this.props,{className:c,ref:this.mentionRef,onSearchChange:this.onSearchChange,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur,suggestions:u,notFoundContent:p}))}}]),t}(React.Component);(exports.default=Mention).getMentions=_rcEditorMention.getMentions,Mention.defaultProps={prefixCls:"dt-mention",notFoundContent:"无匹配结果，轻敲空格完成输入",loading:!1,multiLines:!1,placement:"bottom"},Mention.Nav=_rcEditorMention.Nav,Mention.toString=_rcEditorMention.toString,Mention.toContentState=_rcEditorMention.toEditorState,module.exports=exports.default;