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*as PropTypes from"prop-types";import classNames from"classnames";import Viewer from"viewerjs";import{findDOMNode}from"react-dom";var Previewimg=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.defaultList=["zoomIn","zoomOut","prev","next","reset"],r.moreList=["zoomIn","zoomOut","oneToOne","reset","prev","play","next","rotateRight","rotateLeft","flipHorizontal","flipVertical"],r.options={zoomIn:!0,zoomOut:!0,oneToOne:!1,reset:!0,prev:!0,play:!1,next:!0,rotateLeft:!1,rotateRight:!1,flipHorizontal:!1,flipVertical:!1},r.state={instance:null,parameter:{src:"src",original:"original",alt:"alt"}},r}return _inherits(t,e),_createClass(t,[{key:"loadViewer",value:function(){var e=this;("more"===this.props.type?this.moreList:this.defaultList).forEach(function(t){e.options[t]=!0}),this.setState({instance:new Viewer(findDOMNode(this),{url:"data-original",toolbar:this.options})})}},{key:"componentDidMount",value:function(){var e=this,t=this.props.listParams||{};Object.keys(t).forEach(function(r){e.state.parameter[r]&&(e.state.parameter[r]=t[r])}),this.setState({parameter:this.state.parameter}),this.loadViewer()}},{key:"render",value:function(){var e=this.props,t=e.list,r=void 0===t?[]:t,i=e.className,a=e.prefixCls,o=classNames(a,i,_defineProperty({},a+"-container",!0)),s=this.state.parameter,l=r.map(function(e,t){var r="string"==typeof e?e:e[s.src],i=e[s.original]?e[s.original]:r,a=e[s.alt]?e[s.alt]:e[s.original]?e[s.original]:r;return React.createElement("li",{key:"img--"+t},React.createElement("img",{src:r,"data-original":i,alt:a}))});return React.createElement("ul",{className:o},l)}}]),t}(React.Component);export default Previewimg;Previewimg.defaultProps={prefixCls:"dt-previewimg",type:"default",list:[],listParams:{src:"src",original:"original",alt:"alt"}},Previewimg.propTypes={className:PropTypes.string,prefixCls:PropTypes.string,type:PropTypes.oneOf(["default","more"]),list:PropTypes.array,listParams:PropTypes.object};