dtd
Version:
根据数梦工场视觉规范打造的组件库,感谢react-components和ant design
1 lines • 5.52 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_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),_reactDom=require("react-dom"),ReactDOM=_interopRequireWildcard(_reactDom),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_rcAnimate=require("rc-animate"),_rcAnimate2=_interopRequireDefault(_rcAnimate),_PureRenderMixin=require("rc-util/lib/PureRenderMixin"),_PureRenderMixin2=_interopRequireDefault(_PureRenderMixin),_checkbox=require("../checkbox"),_checkbox2=_interopRequireDefault(_checkbox),_search=require("./search"),_search2=_interopRequireDefault(_search),_item=require("./item"),_item2=_interopRequireDefault(_item),_triggerEvent=require("../_util/triggerEvent"),_triggerEvent2=_interopRequireDefault(_triggerEvent);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 noop(){}function isRenderResultPlainObject(e){return e&&!React.isValidElement(e)&&"[object Object]"===Object.prototype.toString.call(e)}var TransferList=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var l=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return l.handleSelect=function(t){var e=l.props.checkedKeys.some(function(e){return e===t.key});l.props.handleSelect(t,!e)},l.handleFilter=function(e){l.props.handleFilter(e),e.target.value&&(l.triggerScrollTimer=window.setTimeout(function(){var e=ReactDOM.findDOMNode(l).querySelectorAll(".dt-transfer-list-content")[0];e&&(0,_triggerEvent2.default)(e,"scroll")},0))},l.handleClear=function(){l.props.handleClear()},l.matchFilter=function(e,t){var r=l.props,n=r.filter,a=r.filterOption;return a?a(n,t):0<=e.indexOf(n)},l.renderItem=function(e){var t=l.props.render,r=(void 0===t?noop:t)(e),n=isRenderResultPlainObject(r);return{renderedText:n?r.value:r,renderedEl:n?r.label:r}},l.state={mounted:!1},l}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"componentDidMount",value:function(){var e=this;this.timer=window.setTimeout(function(){e.setState({mounted:!0})},0)}},{key:"componentWillUnmount",value:function(){clearTimeout(this.timer),clearTimeout(this.triggerScrollTimer)}},{key:"shouldComponentUpdate",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return _PureRenderMixin2.default.shouldComponentUpdate.apply(this,t)}},{key:"getCheckStatus",value:function(e){var t=this.props.checkedKeys;return 0===t.length?"none":e.every(function(e){return 0<=t.indexOf(e.key)})?"all":"part"}},{key:"render",value:function(){var l=this,e=this.props,i=e.prefixCls,t=e.dataSource,r=e.titleText,o=e.checkedKeys,s=e.lazy,n=e.body,a=void 0===n?noop:n,c=e.footer,u=void 0===c?noop:c,d=e.showSearch,p=e.style,h=e.filter,_=e.searchPlaceholder,f=e.notFoundContent,m=e.itemUnit,R=e.itemsUnit,v=e.onScroll,b=u((0,_extends3.default)({},this.props)),y=a((0,_extends3.default)({},this.props)),C=(0,_classnames2.default)(i,(0,_defineProperty3.default)({},i+"-with-footer",!!b)),q=[],x=[],g=t.map(function(e){var t=l.renderItem(e),r=t.renderedText,n=t.renderedEl;if(h&&h.trim()&&!l.matchFilter(r,e))return null;x.push(e),e.disabled||q.push(e);var a=0<=o.indexOf(e.key);return React.createElement(_item2.default,{key:e.key,item:e,lazy:s,renderedText:r,renderedEl:n,checked:a,prefixCls:i,onClick:l.handleSelect})}),k=1<t.length?R:m,E=d?React.createElement("div",{className:i+"-body-search-wrapper"},React.createElement(_search2.default,{prefixCls:i+"-search",onChange:this.handleFilter,handleClear:this.handleClear,placeholder:_,value:h})):null,D=y||React.createElement("div",{className:d?i+"-body "+i+"-body-with-search":i+"-body"},E,React.createElement(_rcAnimate2.default,{component:"ul",componentProps:{onScroll:v},className:i+"-content",transitionName:this.state.mounted?i+"-content-item-highlight":"",transitionLeave:!1},g),React.createElement("div",{className:i+"-body-not-found"},f)),P=b?React.createElement("div",{className:i+"-footer"},b):null,S=this.getCheckStatus(q),O="all"===S,T=React.createElement(_checkbox2.default,{checked:O,indeterminate:"part"===S,onChange:function(){return l.props.handleSelectAll(q,O)}});return React.createElement("div",{className:C,style:p},React.createElement("div",{className:i+"-header"},T,React.createElement("span",{className:i+"-header-selected"},React.createElement("span",null,(0<o.length?o.length+"/":"")+x.length," ",k),React.createElement("span",{className:i+"-header-title"},r))),D,P)}}]),t}(React.Component);(exports.default=TransferList).defaultProps={dataSource:[],titleText:"",showSearch:!1,render:noop,lazy:{}},module.exports=exports.default;
;