1 line
32 KiB
JSON
1 line
32 KiB
JSON
|
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"fallback\", \"src\", \"imgRef\"],\n _excluded2 = [\"prefixCls\", \"src\", \"alt\", \"imageInfo\", \"fallback\", \"movable\", \"onClose\", \"visible\", \"icons\", \"rootClassName\", \"closeIcon\", \"getContainer\", \"current\", \"count\", \"countRender\", \"scaleStep\", \"minScale\", \"maxScale\", \"transitionName\", \"maskTransitionName\", \"imageRender\", \"imgCommonProps\", \"toolbarRender\", \"onTransform\", \"onChange\"];\nimport classnames from 'classnames';\nimport Dialog from 'rc-dialog';\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport KeyCode from \"rc-util/es/KeyCode\";\nimport React, { useContext, useEffect, useRef, useState } from 'react';\nimport Operations from \"./Operations\";\nimport { PreviewGroupContext } from \"./context\";\nimport useImageTransform from \"./hooks/useImageTransform\";\nimport useMouseEvent from \"./hooks/useMouseEvent\";\nimport useStatus from \"./hooks/useStatus\";\nimport useTouchEvent from \"./hooks/useTouchEvent\";\nimport { BASE_SCALE_RATIO } from \"./previewConfig\";\nvar PreviewImage = function PreviewImage(_ref) {\n var fallback = _ref.fallback,\n src = _ref.src,\n imgRef = _ref.imgRef,\n props = _objectWithoutProperties(_ref, _excluded);\n var _useStatus = useStatus({\n src: src,\n fallback: fallback\n }),\n _useStatus2 = _slicedToArray(_useStatus, 2),\n getImgRef = _useStatus2[0],\n srcAndOnload = _useStatus2[1];\n return /*#__PURE__*/React.createElement(\"img\", _extends({\n ref: function ref(_ref2) {\n imgRef.current = _ref2;\n getImgRef(_ref2);\n }\n }, props, srcAndOnload));\n};\nvar Preview = function Preview(props) {\n var prefixCls = props.prefixCls,\n src = props.src,\n alt = props.alt,\n imageInfo = props.imageInfo,\n fallback = props.fallback,\n _props$movable = props.movable,\n movable = _props$movable === void 0 ? true : _props$movable,\n onClose = props.onClose,\n visible = props.visible,\n _props$icons = props.icons,\n icons = _props$icons === void 0 ? {} : _props$icons,\n rootClassName = props.rootClassName,\n closeIcon = props.closeIcon,\n getContainer = props.getContainer,\n _props$current = props.current,\n current = _props$current === void 0 ? 0 : _props$current,\n _props$count = props.count,\n count = _props$count === void 0 ? 1 : _props$count,\n countRender = props.countRender,\n _props$scaleStep = props.scaleStep,\n scaleStep = _props$scaleStep === void 0 ? 0.5 : _props$scaleStep,\n _props$minScale = props.minScale,\n minScale = _props$minScale === void 0 ? 1 : _props$minScale,\n _props$maxScale = props.maxScale,\n maxScale = _props$maxScale === void 0 ? 50 : _props$maxScale,\n _props$transitionName = props.transitionName,\n transitionName = _props$transitionName === void 0 ? 'zoom' : _props$transitionName,\n _props$maskTransition = props.maskTransitionName,\n maskTransitionName = _props$maskTransition === void 0 ? 'fade' : _props$maskTransition,\n imageRender = props.imageRender,\n imgCommonProps = props.imgCommonProps,\n toolbarRender = props.toolbarRender,\n onTransform = props.onTransform,\n onChange = props.onChange,\n restProps = _objectWithoutProperties(props, _excluded2);\n var imgRef = useRef();\n var groupContext = useContext(PreviewGroupContext);\n var showLeftOrRightSwitches = groupContext && count > 1;\n var showOperationsProgress = groupContext && count >= 1;\n var _useState = useState(true),\n _useState2 = _slicedToArray(_useState, 2),\n enableTransition = _useState2[0],\n setEnableTransition = _useState2[1];\n var _useImageTransform =
|