"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);exports.default=createTableRow;var _react=require("react"),React=_interopRequireWildcard(_react),_classnames2=require("classnames"),_classnames3=_interopRequireDefault(_classnames2),_omit=require("omit.js"),_omit2=_interopRequireDefault(_omit);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function createTableRow(){var e,r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"tr";function s(e){(0,_classCallCheck3.default)(this,s);var t=(0,_possibleConstructorReturn3.default)(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));t.store=e.store;var r=t.store.getState().selectedRowKeys;return t.state={selected:0<=r.indexOf(e.rowKey)},t}return e=React.Component,(0,_inherits3.default)(s,e),(0,_createClass3.default)(s,[{key:"componentDidMount",value:function(){this.subscribe()}},{key:"componentWillUnmount",value:function(){this.unsubscribe&&this.unsubscribe()}},{key:"subscribe",value:function(){var t=this,e=this.props,r=e.store,s=e.rowKey;this.unsubscribe=r.subscribe(function(){var e=0<=t.store.getState().selectedRowKeys.indexOf(s);e!==t.state.selected&&t.setState({selected:e})})}},{key:"render",value:function(){var e=(0,_omit2.default)(this.props,["prefixCls","rowKey","store"]),t=(0,_classnames3.default)(this.props.className,(0,_defineProperty3.default)({},this.props.prefixCls+"-row-selected",this.state.selected));return React.createElement(r,(0,_extends3.default)({},e,{className:t}),this.props.children)}}]),s}module.exports=exports.default;