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 _extends from"babel-runtime/helpers/extends";var __rest=this&&this.__rest||function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(a=Object.getOwnPropertySymbols(e);s<a.length;s++)t.indexOf(a[s])<0&&(r[a[s]]=e[a[s]])}return r};import*as React from"react";import*as PropTypes from"prop-types";import classNames from"classnames";import{Col}from"../grid";export var Meta=function(e){var t=e.prefixCls,r=void 0===t?"dt-list":t,a=e.className,s=e.avatar,i=e.title,n=e.description,l=__rest(e,["prefixCls","className","avatar","title","description"]),o=classNames(r+"-item-meta",a),m=React.createElement("div",{className:r+"-item-meta-content"},i&&React.createElement("h4",{className:r+"-item-meta-title"},i),n&&React.createElement("div",{className:r+"-item-meta-description"},n));return React.createElement("div",_extends({},l,{className:o}),s&&React.createElement("div",{className:r+"-item-meta-avatar"},s),(i||n)&&m)};function getGrid(e,t){return e[t]&&Math.floor(24/e[t])}var GridColumns=["",1,2,3,4,6,8,12,24],Item=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"render",value:function(){var e=this.context.grid,t=this.props,r=t.prefixCls,a=void 0===r?"dt-list":r,s=t.children,i=t.actions,n=t.extra,l=t.className,o=__rest(t,["prefixCls","children","actions","extra","className"]),m=classNames(a+"-item",l),c=[],p=[];React.Children.forEach(s,function(e){e&&e.type&&e.type===Meta?c.push(e):p.push(e)});var d=classNames(a+"-item-content",_defineProperty({},a+"-item-content-single",c.length<1)),u=p.length>0?React.createElement("div",{className:d},p):null,f=void 0;if(i&&i.length>0){f=React.createElement("ul",{className:a+"-item-action"},i.map(function(e,t){return function(e,t){return React.createElement("li",{key:a+"-item-action-"+t},e,t!==i.length-1&&React.createElement("em",{className:a+"-item-action-split"}))}(e,t)}))}var h=React.createElement("div",{className:a+"-item-extra-wrap"},React.createElement("div",{className:a+"-item-main"},c,u,f),React.createElement("div",{className:a+"-item-extra"},n));return e?React.createElement(Col,{span:getGrid(e,"column"),xs:getGrid(e,"xs"),sm:getGrid(e,"sm"),md:getGrid(e,"md"),lg:getGrid(e,"lg"),xl:getGrid(e,"xl"),xxl:getGrid(e,"xxl")},React.createElement("div",_extends({},o,{className:m}),n&&h,!n&&c,!n&&u,!n&&f)):React.createElement("div",_extends({},o,{className:m}),n&&h,!n&&c,!n&&u,!n&&f)}}]),t}(React.Component);export default Item;Item.Meta=Meta,Item.propTypes={column:PropTypes.oneOf(GridColumns),xs:PropTypes.oneOf(GridColumns),sm:PropTypes.oneOf(GridColumns),md:PropTypes.oneOf(GridColumns),lg:PropTypes.oneOf(GridColumns),xl:PropTypes.oneOf(GridColumns),xxl:PropTypes.oneOf(GridColumns)},Item.contextTypes={grid:PropTypes.any};