ce957b6c54a13e28b2c2a28894a69159.json
27.2 KB
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport _extends from \"@babel/runtime/helpers/extends\";\nimport * as React from 'react';\nimport CSSMotion, { CSSMotionList } from 'rc-motion';\nimport classNames from 'classnames';\nimport LoadingOutlined from '@ant-design/icons/LoadingOutlined';\nimport PaperClipOutlined from '@ant-design/icons/PaperClipOutlined';\nimport PictureTwoTone from '@ant-design/icons/PictureTwoTone';\nimport FileTwoTone from '@ant-design/icons/FileTwoTone';\nimport { cloneElement, isValidElement } from '../../_util/reactNode';\nimport { previewImage, isImageUrl } from '../utils';\nimport collapseMotion from '../../_util/motion';\nimport { ConfigContext } from '../../config-provider';\nimport Button from '../../button';\nimport useForceUpdate from '../../_util/hooks/useForceUpdate';\nimport ListItem from './ListItem';\n\nvar listItemMotion = _extends({}, collapseMotion);\n\ndelete listItemMotion.onAppearEnd;\ndelete listItemMotion.onEnterEnd;\ndelete listItemMotion.onLeaveEnd;\n\nvar InternalUploadList = function InternalUploadList(_ref, ref) {\n var _classNames;\n\n var listType = _ref.listType,\n previewFile = _ref.previewFile,\n onPreview = _ref.onPreview,\n onDownload = _ref.onDownload,\n onRemove = _ref.onRemove,\n locale = _ref.locale,\n iconRender = _ref.iconRender,\n isImgUrl = _ref.isImageUrl,\n customizePrefixCls = _ref.prefixCls,\n _ref$items = _ref.items,\n items = _ref$items === void 0 ? [] : _ref$items,\n showPreviewIcon = _ref.showPreviewIcon,\n showRemoveIcon = _ref.showRemoveIcon,\n showDownloadIcon = _ref.showDownloadIcon,\n removeIcon = _ref.removeIcon,\n downloadIcon = _ref.downloadIcon,\n progress = _ref.progress,\n appendAction = _ref.appendAction,\n itemRender = _ref.itemRender;\n var forceUpdate = useForceUpdate();\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n motionAppear = _React$useState2[0],\n setMotionAppear = _React$useState2[1]; // ============================= Effect =============================\n\n\n React.useEffect(function () {\n if (listType !== 'picture' && listType !== 'picture-card') {\n return;\n }\n\n (items || []).forEach(function (file) {\n if (typeof document === 'undefined' || typeof window === 'undefined' || !window.FileReader || !window.File || !(file.originFileObj instanceof File || file.originFileObj instanceof Blob) || file.thumbUrl !== undefined) {\n return;\n }\n\n file.thumbUrl = '';\n\n if (previewFile) {\n previewFile(file.originFileObj).then(function (previewDataUrl) {\n // Need append '' to avoid dead loop\n file.thumbUrl = previewDataUrl || '';\n forceUpdate();\n });\n }\n });\n }, [listType, items, previewFile]);\n React.useEffect(function () {\n setMotionAppear(true);\n }, []); // ============================= Events =============================\n\n var onInternalPreview = function onInternalPreview(file, e) {\n if (!onPreview) {\n return;\n }\n\n e.preventDefault();\n return onPreview(file);\n };\n\n var onInternalDownload = function onInternalDownload(file) {\n if (typeof onDownload === 'function') {\n onDownload(file);\n } else if (file.url) {\n window.open(file.url);\n }\n };\n\n var onInternalClose = function onInternalClose(file) {\n if (onRemove) {\n onRemove(file);\n }\n };\n\n var internalIconRender = function internalIconRender(file) {\n if (iconRender) {\n return iconRender(file, listType);\n }\n\n var isLoading = file.status === 'uploading';\n var fileIcon = isImgUrl && isImgUrl(file) ? /*#__PURE__*/React.createElement(PictureTwoTone, null) : /*#__PURE__*/React.createElement(FileTwoTone, null);\n var icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : /*#__PURE__*/React.createElement(PaperClipOutlined, null);\n\n if (listType === 'picture') {\n icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : fileIcon;\n } else if (listType === 'picture-card') {\n icon = isLoading ? locale.uploading : fileIcon;\n }\n\n return icon;\n };\n\n var actionIconRender = function actionIconRender(customIcon, callback, prefixCls, title) {\n var btnProps = {\n type: 'text',\n size: 'small',\n title: title,\n onClick: function onClick(e) {\n callback();\n\n if (isValidElement(customIcon) && customIcon.props.onClick) {\n customIcon.props.onClick(e);\n }\n },\n className: \"\".concat(prefixCls, \"-list-item-card-actions-btn\")\n };\n\n if (isValidElement(customIcon)) {\n var btnIcon = cloneElement(customIcon, _extends(_extends({}, customIcon.props), {\n onClick: function onClick() {}\n }));\n return /*#__PURE__*/React.createElement(Button, _extends({}, btnProps, {\n icon: btnIcon\n }));\n }\n\n return /*#__PURE__*/React.createElement(Button, btnProps, /*#__PURE__*/React.createElement(\"span\", null, customIcon));\n }; // ============================== Ref ===============================\n // Test needs\n\n\n React.useImperativeHandle(ref, function () {\n return {\n handlePreview: onInternalPreview,\n handleDownload: onInternalDownload\n };\n });\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction; // ============================= Render =============================\n\n\n var prefixCls = getPrefixCls('upload', customizePrefixCls);\n var listClassNames = classNames((_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-list\"), true), _defineProperty(_classNames, \"\".concat(prefixCls, \"-list-\").concat(listType), true), _defineProperty(_classNames, \"\".concat(prefixCls, \"-list-rtl\"), direction === 'rtl'), _classNames)); // >>> Motion config\n\n var motionKeyList = _toConsumableArray(items.map(function (file) {\n return {\n key: file.uid,\n file: file\n };\n }));\n\n var animationDirection = listType === 'picture-card' ? 'animate-inline' : 'animate'; // const transitionName = list.length === 0 ? '' : `${prefixCls}-${animationDirection}`;\n\n var motionConfig = {\n motionName: \"\".concat(prefixCls, \"-\").concat(animationDirection),\n keys: motionKeyList,\n motionAppear: motionAppear\n };\n\n if (listType !== 'picture-card') {\n motionConfig = _extends(_extends({}, listItemMotion), motionConfig);\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: listClassNames\n }, /*#__PURE__*/React.createElement(CSSMotionList, _extends({}, motionConfig, {\n component: false\n }), function (_ref2) {\n var key = _ref2.key,\n file = _ref2.file,\n motionClassName = _ref2.className,\n motionStyle = _ref2.style;\n return /*#__PURE__*/React.createElement(ListItem, {\n key: key,\n locale: locale,\n prefixCls: prefixCls,\n className: motionClassName,\n style: motionStyle,\n file: file,\n items: items,\n progress: progress,\n listType: listType,\n isImgUrl: isImgUrl,\n showPreviewIcon: showPreviewIcon,\n showRemoveIcon: showRemoveIcon,\n showDownloadIcon: showDownloadIcon,\n removeIcon: removeIcon,\n downloadIcon: downloadIcon,\n iconRender: internalIconRender,\n actionIconRender: actionIconRender,\n itemRender: itemRender,\n onPreview: onInternalPreview,\n onDownload: onInternalDownload,\n onClose: onInternalClose\n });\n }), appendAction && /*#__PURE__*/React.createElement(CSSMotion, motionConfig, function (_ref3) {\n var motionClassName = _ref3.className,\n motionStyle = _ref3.style;\n return cloneElement(appendAction, function (oriProps) {\n return {\n className: classNames(oriProps.className, motionClassName),\n style: _extends(_extends({}, motionStyle), oriProps.style)\n };\n });\n }));\n};\n\nvar UploadList = /*#__PURE__*/React.forwardRef(InternalUploadList);\nUploadList.displayName = 'UploadList';\nUploadList.defaultProps = {\n listType: 'text',\n progress: {\n strokeWidth: 2,\n showInfo: false\n },\n showRemoveIcon: true,\n showDownloadIcon: false,\n showPreviewIcon: true,\n previewFile: previewImage,\n isImageUrl: isImageUrl\n};\nexport default UploadList;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/upload/UploadList/index.js"],"names":["_toConsumableArray","_defineProperty","_slicedToArray","_extends","React","CSSMotion","CSSMotionList","classNames","LoadingOutlined","PaperClipOutlined","PictureTwoTone","FileTwoTone","cloneElement","isValidElement","previewImage","isImageUrl","collapseMotion","ConfigContext","Button","useForceUpdate","ListItem","listItemMotion","onAppearEnd","onEnterEnd","onLeaveEnd","InternalUploadList","_ref","ref","_classNames","listType","previewFile","onPreview","onDownload","onRemove","locale","iconRender","isImgUrl","customizePrefixCls","prefixCls","_ref$items","items","showPreviewIcon","showRemoveIcon","showDownloadIcon","removeIcon","downloadIcon","progress","appendAction","itemRender","forceUpdate","_React$useState","useState","_React$useState2","motionAppear","setMotionAppear","useEffect","forEach","file","document","window","FileReader","File","originFileObj","Blob","thumbUrl","undefined","then","previewDataUrl","onInternalPreview","e","preventDefault","onInternalDownload","url","open","onInternalClose","internalIconRender","isLoading","status","fileIcon","createElement","icon","uploading","actionIconRender","customIcon","callback","title","btnProps","type","size","onClick","props","className","concat","btnIcon","useImperativeHandle","handlePreview","handleDownload","_React$useContext","useContext","getPrefixCls","direction","listClassNames","motionKeyList","map","key","uid","animationDirection","motionConfig","motionName","keys","component","_ref2","motionClassName","motionStyle","style","onClose","_ref3","oriProps","UploadList","forwardRef","displayName","defaultProps","strokeWidth","showInfo"],"mappings":"AAAA,OAAOA,kBAAP,MAA+B,0CAA/B;AACA,OAAOC,eAAP,MAA4B,uCAA5B;AACA,OAAOC,cAAP,MAA2B,sCAA3B;AACA,OAAOC,QAAP,MAAqB,gCAArB;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,SAAP,IAAoBC,aAApB,QAAyC,WAAzC;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,eAAP,MAA4B,mCAA5B;AACA,OAAOC,iBAAP,MAA8B,qCAA9B;AACA,OAAOC,cAAP,MAA2B,kCAA3B;AACA,OAAOC,WAAP,MAAwB,+BAAxB;AACA,SAASC,YAAT,EAAuBC,cAAvB,QAA6C,uBAA7C;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,UAAzC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,SAASC,aAAT,QAA8B,uBAA9B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,cAAP,MAA2B,kCAA3B;AACA,OAAOC,QAAP,MAAqB,YAArB;;AAEA,IAAIC,cAAc,GAAGlB,QAAQ,CAAC,EAAD,EAAKa,cAAL,CAA7B;;AAEA,OAAOK,cAAc,CAACC,WAAtB;AACA,OAAOD,cAAc,CAACE,UAAtB;AACA,OAAOF,cAAc,CAACG,UAAtB;;AAEA,IAAIC,kBAAkB,GAAG,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,CAA9B;AACA6F,UAAU,CAACE,WAAX,GAAyB,YAAzB;AACAF,UAAU,CAACG,YAAX,GAA0B;AACxB5F,EAAAA,QAAQ,EAAE,MADc;AAExBiB,EAAAA,QAAQ,EAAE;AACR4E,IAAAA,WAAW,EAAE,CADL;AAERC,IAAAA,QAAQ,EAAE;AAFF,GAFc;AAMxBjF,EAAAA,cAAc,EAAE,IANQ;AAOxBC,EAAAA,gBAAgB,EAAE,KAPM;AAQxBF,EAAAA,eAAe,EAAE,IARO;AASxBX,EAAAA,WAAW,EAAEhB,YATW;AAUxBC,EAAAA,UAAU,EAAEA;AAVY,CAA1B;AAYA,eAAeuG,UAAf","sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport _extends from \"@babel/runtime/helpers/extends\";\nimport * as React from 'react';\nimport CSSMotion, { CSSMotionList } from 'rc-motion';\nimport classNames from 'classnames';\nimport LoadingOutlined from '@ant-design/icons/LoadingOutlined';\nimport PaperClipOutlined from '@ant-design/icons/PaperClipOutlined';\nimport PictureTwoTone from '@ant-design/icons/PictureTwoTone';\nimport FileTwoTone from '@ant-design/icons/FileTwoTone';\nimport { cloneElement, isValidElement } from '../../_util/reactNode';\nimport { previewImage, isImageUrl } from '../utils';\nimport collapseMotion from '../../_util/motion';\nimport { ConfigContext } from '../../config-provider';\nimport Button from '../../button';\nimport useForceUpdate from '../../_util/hooks/useForceUpdate';\nimport ListItem from './ListItem';\n\nvar listItemMotion = _extends({}, collapseMotion);\n\ndelete listItemMotion.onAppearEnd;\ndelete listItemMotion.onEnterEnd;\ndelete listItemMotion.onLeaveEnd;\n\nvar InternalUploadList = function InternalUploadList(_ref, ref) {\n var _classNames;\n\n var listType = _ref.listType,\n previewFile = _ref.previewFile,\n onPreview = _ref.onPreview,\n onDownload = _ref.onDownload,\n onRemove = _ref.onRemove,\n locale = _ref.locale,\n iconRender = _ref.iconRender,\n isImgUrl = _ref.isImageUrl,\n customizePrefixCls = _ref.prefixCls,\n _ref$items = _ref.items,\n items = _ref$items === void 0 ? [] : _ref$items,\n showPreviewIcon = _ref.showPreviewIcon,\n showRemoveIcon = _ref.showRemoveIcon,\n showDownloadIcon = _ref.showDownloadIcon,\n removeIcon = _ref.removeIcon,\n downloadIcon = _ref.downloadIcon,\n progress = _ref.progress,\n appendAction = _ref.appendAction,\n itemRender = _ref.itemRender;\n var forceUpdate = useForceUpdate();\n\n var _React$useState = React.useState(false),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n motionAppear = _React$useState2[0],\n setMotionAppear = _React$useState2[1]; // ============================= Effect =============================\n\n\n React.useEffect(function () {\n if (listType !== 'picture' && listType !== 'picture-card') {\n return;\n }\n\n (items || []).forEach(function (file) {\n if (typeof document === 'undefined' || typeof window === 'undefined' || !window.FileReader || !window.File || !(file.originFileObj instanceof File || file.originFileObj instanceof Blob) || file.thumbUrl !== undefined) {\n return;\n }\n\n file.thumbUrl = '';\n\n if (previewFile) {\n previewFile(file.originFileObj).then(function (previewDataUrl) {\n // Need append '' to avoid dead loop\n file.thumbUrl = previewDataUrl || '';\n forceUpdate();\n });\n }\n });\n }, [listType, items, previewFile]);\n React.useEffect(function () {\n setMotionAppear(true);\n }, []); // ============================= Events =============================\n\n var onInternalPreview = function onInternalPreview(file, e) {\n if (!onPreview) {\n return;\n }\n\n e.preventDefault();\n return onPreview(file);\n };\n\n var onInternalDownload = function onInternalDownload(file) {\n if (typeof onDownload === 'function') {\n onDownload(file);\n } else if (file.url) {\n window.open(file.url);\n }\n };\n\n var onInternalClose = function onInternalClose(file) {\n if (onRemove) {\n onRemove(file);\n }\n };\n\n var internalIconRender = function internalIconRender(file) {\n if (iconRender) {\n return iconRender(file, listType);\n }\n\n var isLoading = file.status === 'uploading';\n var fileIcon = isImgUrl && isImgUrl(file) ? /*#__PURE__*/React.createElement(PictureTwoTone, null) : /*#__PURE__*/React.createElement(FileTwoTone, null);\n var icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : /*#__PURE__*/React.createElement(PaperClipOutlined, null);\n\n if (listType === 'picture') {\n icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : fileIcon;\n } else if (listType === 'picture-card') {\n icon = isLoading ? locale.uploading : fileIcon;\n }\n\n return icon;\n };\n\n var actionIconRender = function actionIconRender(customIcon, callback, prefixCls, title) {\n var btnProps = {\n type: 'text',\n size: 'small',\n title: title,\n onClick: function onClick(e) {\n callback();\n\n if (isValidElement(customIcon) && customIcon.props.onClick) {\n customIcon.props.onClick(e);\n }\n },\n className: \"\".concat(prefixCls, \"-list-item-card-actions-btn\")\n };\n\n if (isValidElement(customIcon)) {\n var btnIcon = cloneElement(customIcon, _extends(_extends({}, customIcon.props), {\n onClick: function onClick() {}\n }));\n return /*#__PURE__*/React.createElement(Button, _extends({}, btnProps, {\n icon: btnIcon\n }));\n }\n\n return /*#__PURE__*/React.createElement(Button, btnProps, /*#__PURE__*/React.createElement(\"span\", null, customIcon));\n }; // ============================== Ref ===============================\n // Test needs\n\n\n React.useImperativeHandle(ref, function () {\n return {\n handlePreview: onInternalPreview,\n handleDownload: onInternalDownload\n };\n });\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction; // ============================= Render =============================\n\n\n var prefixCls = getPrefixCls('upload', customizePrefixCls);\n var listClassNames = classNames((_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-list\"), true), _defineProperty(_classNames, \"\".concat(prefixCls, \"-list-\").concat(listType), true), _defineProperty(_classNames, \"\".concat(prefixCls, \"-list-rtl\"), direction === 'rtl'), _classNames)); // >>> Motion config\n\n var motionKeyList = _toConsumableArray(items.map(function (file) {\n return {\n key: file.uid,\n file: file\n };\n }));\n\n var animationDirection = listType === 'picture-card' ? 'animate-inline' : 'animate'; // const transitionName = list.length === 0 ? '' : `${prefixCls}-${animationDirection}`;\n\n var motionConfig = {\n motionName: \"\".concat(prefixCls, \"-\").concat(animationDirection),\n keys: motionKeyList,\n motionAppear: motionAppear\n };\n\n if (listType !== 'picture-card') {\n motionConfig = _extends(_extends({}, listItemMotion), motionConfig);\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: listClassNames\n }, /*#__PURE__*/React.createElement(CSSMotionList, _extends({}, motionConfig, {\n component: false\n }), function (_ref2) {\n var key = _ref2.key,\n file = _ref2.file,\n motionClassName = _ref2.className,\n motionStyle = _ref2.style;\n return /*#__PURE__*/React.createElement(ListItem, {\n key: key,\n locale: locale,\n prefixCls: prefixCls,\n className: motionClassName,\n style: motionStyle,\n file: file,\n items: items,\n progress: progress,\n listType: listType,\n isImgUrl: isImgUrl,\n showPreviewIcon: showPreviewIcon,\n showRemoveIcon: showRemoveIcon,\n showDownloadIcon: showDownloadIcon,\n removeIcon: removeIcon,\n downloadIcon: downloadIcon,\n iconRender: internalIconRender,\n actionIconRender: actionIconRender,\n itemRender: itemRender,\n onPreview: onInternalPreview,\n onDownload: onInternalDownload,\n onClose: onInternalClose\n });\n }), appendAction && /*#__PURE__*/React.createElement(CSSMotion, motionConfig, function (_ref3) {\n var motionClassName = _ref3.className,\n motionStyle = _ref3.style;\n return cloneElement(appendAction, function (oriProps) {\n return {\n className: classNames(oriProps.className, motionClassName),\n style: _extends(_extends({}, motionStyle), oriProps.style)\n };\n });\n }));\n};\n\nvar UploadList = /*#__PURE__*/React.forwardRef(InternalUploadList);\nUploadList.displayName = 'UploadList';\nUploadList.defaultProps = {\n listType: 'text',\n progress: {\n strokeWidth: 2,\n showInfo: false\n },\n showRemoveIcon: true,\n showDownloadIcon: false,\n showPreviewIcon: true,\n previewFile: previewImage,\n isImageUrl: isImageUrl\n};\nexport default UploadList;"]},"metadata":{},"sourceType":"module"}