ee12f49cc44305735ce1f316be383fee.json
29.7 KB
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport Dialog from 'rc-dialog';\nimport RotateLeftOutlined from '@ant-design/icons/RotateLeftOutlined';\nimport RotateRightOutlined from '@ant-design/icons/RotateRightOutlined';\nimport ZoomInOutlined from '@ant-design/icons/ZoomInOutlined';\nimport ZoomOutOutlined from '@ant-design/icons/ZoomOutOutlined';\nimport CloseOutlined from '@ant-design/icons/CloseOutlined';\nimport LeftOutlined from '@ant-design/icons/LeftOutlined';\nimport RightOutlined from '@ant-design/icons/RightOutlined';\nimport classnames from 'classnames';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport { getOffset } from \"rc-util/es/Dom/css\";\nimport { warning } from \"rc-util/es/warning\";\nimport useFrameSetState from './hooks/useFrameSetState';\nimport usePreviewIndex from './hooks/usePreviewIndex';\nimport getFixScaleEleTransPosition from './getFixScaleEleTransPosition';\nimport { context } from './PreviewGroup';\nvar useState = React.useState;\nvar initialPosition = {\n x: 0,\n y: 0\n};\n\nvar Preview = function Preview(props) {\n var prefixCls = props.prefixCls,\n src = props.src,\n alt = props.alt,\n onClose = props.onClose,\n afterClose = props.afterClose,\n visible = props.visible,\n restProps = _objectWithoutProperties(props, [\"prefixCls\", \"src\", \"alt\", \"onClose\", \"afterClose\", \"visible\"]);\n\n var _useState = useState(1),\n _useState2 = _slicedToArray(_useState, 2),\n scale = _useState2[0],\n setScale = _useState2[1];\n\n var _useState3 = useState(0),\n _useState4 = _slicedToArray(_useState3, 2),\n rotate = _useState4[0],\n setRotate = _useState4[1];\n\n var _useFrameSetState = useFrameSetState(initialPosition),\n _useFrameSetState2 = _slicedToArray(_useFrameSetState, 2),\n position = _useFrameSetState2[0],\n setPosition = _useFrameSetState2[1];\n\n var imgRef = React.useRef();\n var originPositionRef = React.useRef({\n originX: 0,\n originY: 0,\n deltaX: 0,\n deltaY: 0\n });\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n isMoving = _React$useState2[0],\n setMoving = _React$useState2[1];\n\n var _React$useContext = React.useContext(context),\n previewUrls = _React$useContext.previewUrls;\n\n var urls = previewUrls && previewUrls.length ? previewUrls : [src];\n\n var _usePreviewIndex = usePreviewIndex(src, urls),\n _usePreviewIndex2 = _slicedToArray(_usePreviewIndex, 2),\n index = _usePreviewIndex2[0],\n setIndex = _usePreviewIndex2[1];\n\n var onAfterClose = function onAfterClose() {\n setScale(1);\n setRotate(0);\n setPosition(initialPosition);\n };\n\n var onZoomIn = function onZoomIn() {\n setScale(function (value) {\n return value + 1;\n });\n setPosition(initialPosition);\n };\n\n var onZoomOut = function onZoomOut() {\n if (scale > 1) {\n setScale(function (value) {\n return value - 1;\n });\n }\n\n setPosition(initialPosition);\n };\n\n var onRotateRight = function onRotateRight() {\n setRotate(function (value) {\n return value + 90;\n });\n };\n\n var onRotateLeft = function onRotateLeft() {\n setRotate(function (value) {\n return value - 90;\n });\n };\n\n var onSwitchLeft = function onSwitchLeft(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n\n if (index > 0) {\n onAfterClose();\n setIndex(index - 1);\n }\n };\n\n var onSwitchRight = function onSwitchRight(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n\n if (index < urls.length - 1) {\n onAfterClose();\n setIndex(index + 1);\n }\n };\n\n var wrapClassName = classnames(_defineProperty({}, \"\".concat(prefixCls, \"-moving\"), isMoving));\n var toolClassName = \"\".concat(prefixCls, \"-operations-operation\");\n var iconClassName = \"\".concat(prefixCls, \"-operations-icon\");\n var tools = [{\n Icon: CloseOutlined,\n onClick: onClose,\n type: 'close'\n }, {\n Icon: ZoomInOutlined,\n onClick: onZoomIn,\n type: 'zoomIn'\n }, {\n Icon: ZoomOutOutlined,\n onClick: onZoomOut,\n type: 'zoomOut',\n disabled: scale === 1\n }, {\n Icon: RotateRightOutlined,\n onClick: onRotateRight,\n type: 'rotateRight'\n }, {\n Icon: RotateLeftOutlined,\n onClick: onRotateLeft,\n type: 'rotateLeft'\n }];\n\n var onMouseUp = function onMouseUp() {\n if (visible && isMoving) {\n var width = imgRef.current.offsetWidth * scale;\n var height = imgRef.current.offsetHeight * scale;\n\n var _getOffset = getOffset(imgRef.current),\n left = _getOffset.left,\n top = _getOffset.top;\n\n var isRotate = rotate % 180 !== 0;\n setMoving(false);\n var fixState = getFixScaleEleTransPosition(isRotate ? height : width, isRotate ? width : height, left, top);\n\n if (fixState) {\n setPosition(_objectSpread({}, fixState));\n }\n }\n };\n\n var onMouseDown = function onMouseDown(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n originPositionRef.current.deltaX = event.pageX - position.x;\n originPositionRef.current.deltaY = event.pageY - position.y;\n originPositionRef.current.originX = position.x;\n originPositionRef.current.originY = position.y;\n setMoving(true);\n };\n\n var onMouseMove = function onMouseMove(event) {\n if (visible && isMoving) {\n setPosition({\n x: event.pageX - originPositionRef.current.deltaX,\n y: event.pageY - originPositionRef.current.deltaY\n });\n }\n };\n\n React.useEffect(function () {\n var onTopMouseUpListener;\n var onTopMouseMoveListener;\n var onMouseUpListener = addEventListener(window, 'mouseup', onMouseUp, false);\n var onMouseMoveListener = addEventListener(window, 'mousemove', onMouseMove, false);\n\n try {\n // Resolve if in iframe lost event\n\n /* istanbul ignore next */\n if (window.top !== window.self) {\n onTopMouseUpListener = addEventListener(window.top, 'mouseup', onMouseUp, false);\n onTopMouseMoveListener = addEventListener(window.top, 'mousemove', onMouseMove, false);\n }\n } catch (error) {\n /* istanbul ignore next */\n warning(false, \"[rc-image] \".concat(error));\n }\n\n return function () {\n onMouseUpListener.remove();\n onMouseMoveListener.remove();\n /* istanbul ignore next */\n\n if (onTopMouseUpListener) onTopMouseUpListener.remove();\n /* istanbul ignore next */\n\n if (onTopMouseMoveListener) onTopMouseMoveListener.remove();\n\n if (!visible) {\n setIndex(urls.indexOf(src));\n }\n };\n }, [visible, isMoving]);\n return /*#__PURE__*/React.createElement(Dialog, Object.assign({}, restProps, {\n transitionName: \"zoom\",\n maskTransitionName: \"fade\",\n closable: false,\n keyboard: true,\n prefixCls: prefixCls,\n onClose: onClose,\n afterClose: onAfterClose,\n visible: visible,\n wrapClassName: wrapClassName\n }), /*#__PURE__*/React.createElement(\"ul\", {\n className: \"\".concat(prefixCls, \"-operations\")\n }, tools.map(function (_ref) {\n var Icon = _ref.Icon,\n onClick = _ref.onClick,\n type = _ref.type,\n disabled = _ref.disabled;\n return /*#__PURE__*/React.createElement(\"li\", {\n className: classnames(toolClassName, _defineProperty({}, \"\".concat(prefixCls, \"-operations-operation-disabled\"), !!disabled)),\n onClick: onClick,\n key: type\n }, /*#__PURE__*/React.createElement(Icon, {\n className: iconClassName\n }));\n })), /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-img-wrapper\"),\n style: {\n transform: \"translate3d(\".concat(position.x, \"px, \").concat(position.y, \"px, 0)\")\n }\n }, /*#__PURE__*/React.createElement(\"img\", {\n onMouseDown: onMouseDown,\n ref: imgRef,\n className: \"\".concat(prefixCls, \"-img\"),\n src: urls[index],\n alt: alt,\n style: {\n transform: \"scale3d(\".concat(scale, \", \").concat(scale, \", 1) rotate(\").concat(rotate, \"deg)\")\n }\n })), urls.length > 1 ? /*#__PURE__*/React.createElement(\"div\", {\n className: classnames(\"\".concat(prefixCls, \"-switch-left\"), _defineProperty({}, \"\".concat(prefixCls, \"-switch-left-disabled\"), index <= 0)),\n onClick: onSwitchLeft\n }, /*#__PURE__*/React.createElement(LeftOutlined, null)) : null, urls.length > 1 ? /*#__PURE__*/React.createElement(\"div\", {\n className: classnames(\"\".concat(prefixCls, \"-switch-right\"), _defineProperty({}, \"\".concat(prefixCls, \"-switch-right-disabled\"), index >= urls.length - 1)),\n onClick: onSwitchRight\n }, /*#__PURE__*/React.createElement(RightOutlined, null)) : null);\n};\n\nexport default Preview;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-image/es/Preview.js"],"names":["_objectSpread","_defineProperty","_slicedToArray","_objectWithoutProperties","React","Dialog","RotateLeftOutlined","RotateRightOutlined","ZoomInOutlined","ZoomOutOutlined","CloseOutlined","LeftOutlined","RightOutlined","classnames","addEventListener","getOffset","warning","useFrameSetState","usePreviewIndex","getFixScaleEleTransPosition","context","useState","initialPosition","x","y","Preview","props","prefixCls","src","alt","onClose","afterClose","visible","restProps","_useState","_useState2","scale","setScale","_useState3","_useState4","rotate","setRotate","_useFrameSetState","_useFrameSetState2","position","setPosition","imgRef","useRef","originPositionRef","originX","originY","deltaX","deltaY","_React$useState","_React$useState2","isMoving","setMoving","_React$useContext","useContext","previewUrls","urls","length","_usePreviewIndex","_usePreviewIndex2","index","setIndex","onAfterClose","onZoomIn","value","onZoomOut","onRotateRight","onRotateLeft","onSwitchLeft","event","preventDefault","stopPropagation","onSwitchRight","wrapClassName","concat","toolClassName","iconClassName","tools","Icon","onClick","type","disabled","onMouseUp","width","current","offsetWidth","height","offsetHeight","_getOffset","left","top","isRotate","fixState","onMouseDown","pageX","pageY","onMouseMove","useEffect","onTopMouseUpListener","onTopMouseMoveListener","onMouseUpListener","window","onMouseMoveListener","self","error","remove","indexOf","createElement","Object","assign","transitionName","maskTransitionName","closable","keyboard","className","map","_ref","key","style","transform","ref"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,0CAA1B;AACA,OAAOC,eAAP,MAA4B,2CAA5B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,kBAAP,MAA+B,sCAA/B;AACA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,EAAmC,IAAnC,CAHgF,CAA/B,GAGL,IA5CxC,CAApB;AA6CD,CAxPD;;AA0PA,eAAea,OAAf","sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport Dialog from 'rc-dialog';\nimport RotateLeftOutlined from '@ant-design/icons/RotateLeftOutlined';\nimport RotateRightOutlined from '@ant-design/icons/RotateRightOutlined';\nimport ZoomInOutlined from '@ant-design/icons/ZoomInOutlined';\nimport ZoomOutOutlined from '@ant-design/icons/ZoomOutOutlined';\nimport CloseOutlined from '@ant-design/icons/CloseOutlined';\nimport LeftOutlined from '@ant-design/icons/LeftOutlined';\nimport RightOutlined from '@ant-design/icons/RightOutlined';\nimport classnames from 'classnames';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport { getOffset } from \"rc-util/es/Dom/css\";\nimport { warning } from \"rc-util/es/warning\";\nimport useFrameSetState from './hooks/useFrameSetState';\nimport usePreviewIndex from './hooks/usePreviewIndex';\nimport getFixScaleEleTransPosition from './getFixScaleEleTransPosition';\nimport { context } from './PreviewGroup';\nvar useState = React.useState;\nvar initialPosition = {\n x: 0,\n y: 0\n};\n\nvar Preview = function Preview(props) {\n var prefixCls = props.prefixCls,\n src = props.src,\n alt = props.alt,\n onClose = props.onClose,\n afterClose = props.afterClose,\n visible = props.visible,\n restProps = _objectWithoutProperties(props, [\"prefixCls\", \"src\", \"alt\", \"onClose\", \"afterClose\", \"visible\"]);\n\n var _useState = useState(1),\n _useState2 = _slicedToArray(_useState, 2),\n scale = _useState2[0],\n setScale = _useState2[1];\n\n var _useState3 = useState(0),\n _useState4 = _slicedToArray(_useState3, 2),\n rotate = _useState4[0],\n setRotate = _useState4[1];\n\n var _useFrameSetState = useFrameSetState(initialPosition),\n _useFrameSetState2 = _slicedToArray(_useFrameSetState, 2),\n position = _useFrameSetState2[0],\n setPosition = _useFrameSetState2[1];\n\n var imgRef = React.useRef();\n var originPositionRef = React.useRef({\n originX: 0,\n originY: 0,\n deltaX: 0,\n deltaY: 0\n });\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n isMoving = _React$useState2[0],\n setMoving = _React$useState2[1];\n\n var _React$useContext = React.useContext(context),\n previewUrls = _React$useContext.previewUrls;\n\n var urls = previewUrls && previewUrls.length ? previewUrls : [src];\n\n var _usePreviewIndex = usePreviewIndex(src, urls),\n _usePreviewIndex2 = _slicedToArray(_usePreviewIndex, 2),\n index = _usePreviewIndex2[0],\n setIndex = _usePreviewIndex2[1];\n\n var onAfterClose = function onAfterClose() {\n setScale(1);\n setRotate(0);\n setPosition(initialPosition);\n };\n\n var onZoomIn = function onZoomIn() {\n setScale(function (value) {\n return value + 1;\n });\n setPosition(initialPosition);\n };\n\n var onZoomOut = function onZoomOut() {\n if (scale > 1) {\n setScale(function (value) {\n return value - 1;\n });\n }\n\n setPosition(initialPosition);\n };\n\n var onRotateRight = function onRotateRight() {\n setRotate(function (value) {\n return value + 90;\n });\n };\n\n var onRotateLeft = function onRotateLeft() {\n setRotate(function (value) {\n return value - 90;\n });\n };\n\n var onSwitchLeft = function onSwitchLeft(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n\n if (index > 0) {\n onAfterClose();\n setIndex(index - 1);\n }\n };\n\n var onSwitchRight = function onSwitchRight(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n\n if (index < urls.length - 1) {\n onAfterClose();\n setIndex(index + 1);\n }\n };\n\n var wrapClassName = classnames(_defineProperty({}, \"\".concat(prefixCls, \"-moving\"), isMoving));\n var toolClassName = \"\".concat(prefixCls, \"-operations-operation\");\n var iconClassName = \"\".concat(prefixCls, \"-operations-icon\");\n var tools = [{\n Icon: CloseOutlined,\n onClick: onClose,\n type: 'close'\n }, {\n Icon: ZoomInOutlined,\n onClick: onZoomIn,\n type: 'zoomIn'\n }, {\n Icon: ZoomOutOutlined,\n onClick: onZoomOut,\n type: 'zoomOut',\n disabled: scale === 1\n }, {\n Icon: RotateRightOutlined,\n onClick: onRotateRight,\n type: 'rotateRight'\n }, {\n Icon: RotateLeftOutlined,\n onClick: onRotateLeft,\n type: 'rotateLeft'\n }];\n\n var onMouseUp = function onMouseUp() {\n if (visible && isMoving) {\n var width = imgRef.current.offsetWidth * scale;\n var height = imgRef.current.offsetHeight * scale;\n\n var _getOffset = getOffset(imgRef.current),\n left = _getOffset.left,\n top = _getOffset.top;\n\n var isRotate = rotate % 180 !== 0;\n setMoving(false);\n var fixState = getFixScaleEleTransPosition(isRotate ? height : width, isRotate ? width : height, left, top);\n\n if (fixState) {\n setPosition(_objectSpread({}, fixState));\n }\n }\n };\n\n var onMouseDown = function onMouseDown(event) {\n event.preventDefault(); // Without this mask close will abnormal\n\n event.stopPropagation();\n originPositionRef.current.deltaX = event.pageX - position.x;\n originPositionRef.current.deltaY = event.pageY - position.y;\n originPositionRef.current.originX = position.x;\n originPositionRef.current.originY = position.y;\n setMoving(true);\n };\n\n var onMouseMove = function onMouseMove(event) {\n if (visible && isMoving) {\n setPosition({\n x: event.pageX - originPositionRef.current.deltaX,\n y: event.pageY - originPositionRef.current.deltaY\n });\n }\n };\n\n React.useEffect(function () {\n var onTopMouseUpListener;\n var onTopMouseMoveListener;\n var onMouseUpListener = addEventListener(window, 'mouseup', onMouseUp, false);\n var onMouseMoveListener = addEventListener(window, 'mousemove', onMouseMove, false);\n\n try {\n // Resolve if in iframe lost event\n\n /* istanbul ignore next */\n if (window.top !== window.self) {\n onTopMouseUpListener = addEventListener(window.top, 'mouseup', onMouseUp, false);\n onTopMouseMoveListener = addEventListener(window.top, 'mousemove', onMouseMove, false);\n }\n } catch (error) {\n /* istanbul ignore next */\n warning(false, \"[rc-image] \".concat(error));\n }\n\n return function () {\n onMouseUpListener.remove();\n onMouseMoveListener.remove();\n /* istanbul ignore next */\n\n if (onTopMouseUpListener) onTopMouseUpListener.remove();\n /* istanbul ignore next */\n\n if (onTopMouseMoveListener) onTopMouseMoveListener.remove();\n\n if (!visible) {\n setIndex(urls.indexOf(src));\n }\n };\n }, [visible, isMoving]);\n return /*#__PURE__*/React.createElement(Dialog, Object.assign({}, restProps, {\n transitionName: \"zoom\",\n maskTransitionName: \"fade\",\n closable: false,\n keyboard: true,\n prefixCls: prefixCls,\n onClose: onClose,\n afterClose: onAfterClose,\n visible: visible,\n wrapClassName: wrapClassName\n }), /*#__PURE__*/React.createElement(\"ul\", {\n className: \"\".concat(prefixCls, \"-operations\")\n }, tools.map(function (_ref) {\n var Icon = _ref.Icon,\n onClick = _ref.onClick,\n type = _ref.type,\n disabled = _ref.disabled;\n return /*#__PURE__*/React.createElement(\"li\", {\n className: classnames(toolClassName, _defineProperty({}, \"\".concat(prefixCls, \"-operations-operation-disabled\"), !!disabled)),\n onClick: onClick,\n key: type\n }, /*#__PURE__*/React.createElement(Icon, {\n className: iconClassName\n }));\n })), /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(prefixCls, \"-img-wrapper\"),\n style: {\n transform: \"translate3d(\".concat(position.x, \"px, \").concat(position.y, \"px, 0)\")\n }\n }, /*#__PURE__*/React.createElement(\"img\", {\n onMouseDown: onMouseDown,\n ref: imgRef,\n className: \"\".concat(prefixCls, \"-img\"),\n src: urls[index],\n alt: alt,\n style: {\n transform: \"scale3d(\".concat(scale, \", \").concat(scale, \", 1) rotate(\").concat(rotate, \"deg)\")\n }\n })), urls.length > 1 ? /*#__PURE__*/React.createElement(\"div\", {\n className: classnames(\"\".concat(prefixCls, \"-switch-left\"), _defineProperty({}, \"\".concat(prefixCls, \"-switch-left-disabled\"), index <= 0)),\n onClick: onSwitchLeft\n }, /*#__PURE__*/React.createElement(LeftOutlined, null)) : null, urls.length > 1 ? /*#__PURE__*/React.createElement(\"div\", {\n className: classnames(\"\".concat(prefixCls, \"-switch-right\"), _defineProperty({}, \"\".concat(prefixCls, \"-switch-right-disabled\"), index >= urls.length - 1)),\n onClick: onSwitchRight\n }, /*#__PURE__*/React.createElement(RightOutlined, null)) : null);\n};\n\nexport default Preview;"]},"metadata":{},"sourceType":"module"}