import _extends from"babel-runtime/helpers/extends";import _defineProperty from"babel-runtime/helpers/defineProperty";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import classnames from"classnames";import omit from"omit.js";export default function createTableRow(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"tr";return function(t){function s(e){_classCallCheck(this,s);var t=_possibleConstructorReturn(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));t.store=e.store;var r=t.store.getState().selectedRowKeys;return t.state={selected:r.indexOf(e.rowKey)>=0},t}return _inherits(s,t),_createClass(s,[{key:"componentDidMount",value:function(){this.subscribe()}},{key:"componentWillUnmount",value:function(){this.unsubscribe&&this.unsubscribe()}},{key:"subscribe",value:function(){var e=this,t=this.props,s=t.store,r=t.rowKey;this.unsubscribe=s.subscribe(function(){var t=e.store.getState().selectedRowKeys.indexOf(r)>=0;t!==e.state.selected&&e.setState({selected:t})})}},{key:"render",value:function(){var t=omit(this.props,["prefixCls","rowKey","store"]),s=classnames(this.props.className,_defineProperty({},this.props.prefixCls+"-row-selected",this.state.selected));return React.createElement(e,_extends({},t,{className:s}),this.props.children)}}]),s}(React.Component)};