1 line
25 KiB
JSON
1 line
25 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport FileTwoTone from \"@ant-design/icons/es/icons/FileTwoTone\";\nimport LoadingOutlined from \"@ant-design/icons/es/icons/LoadingOutlined\";\nimport PaperClipOutlined from \"@ant-design/icons/es/icons/PaperClipOutlined\";\nimport PictureTwoTone from \"@ant-design/icons/es/icons/PictureTwoTone\";\nimport classNames from 'classnames';\nimport CSSMotion, { CSSMotionList } from 'rc-motion';\nimport useForceUpdate from '../../_util/hooks/useForceUpdate';\nimport initCollapseMotion from '../../_util/motion';\nimport { cloneElement } from '../../_util/reactNode';\nimport Button from '../../button';\nimport { ConfigContext } from '../../config-provider';\nimport { isImageUrl, previewImage } from '../utils';\nimport ListItem from './ListItem';\nconst InternalUploadList = (props, ref) => {\n const {\n listType = 'text',\n previewFile = previewImage,\n onPreview,\n onDownload,\n onRemove,\n locale,\n iconRender,\n isImageUrl: isImgUrl = isImageUrl,\n prefixCls: customizePrefixCls,\n items = [],\n showPreviewIcon = true,\n showRemoveIcon = true,\n showDownloadIcon = false,\n removeIcon,\n previewIcon,\n downloadIcon,\n extra,\n progress = {\n size: [-1, 2],\n showInfo: false\n },\n appendAction,\n appendActionVisible = true,\n itemRender,\n disabled\n } = props;\n const forceUpdate = useForceUpdate();\n const [motionAppear, setMotionAppear] = React.useState(false);\n // ============================= Effect =============================\n React.useEffect(() => {\n if (listType !== 'picture' && listType !== 'picture-card' && listType !== 'picture-circle') {\n return;\n }\n (items || []).forEach(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 file.thumbUrl = '';\n if (previewFile) {\n previewFile(file.originFileObj).then(previewDataUrl => {\n // Need append '' to avoid dead loop\n file.thumbUrl = previewDataUrl || '';\n forceUpdate();\n });\n }\n });\n }, [listType, items, previewFile]);\n React.useEffect(() => {\n setMotionAppear(true);\n }, []);\n // ============================= Events =============================\n const onInternalPreview = (file, e) => {\n if (!onPreview) {\n return;\n }\n e === null || e === void 0 ? void 0 : e.preventDefault();\n return onPreview(file);\n };\n const onInternalDownload = file => {\n if (typeof onDownload === 'function') {\n onDownload(file);\n } else if (file.url) {\n window.open(file.url);\n }\n };\n const onInternalClose = file => {\n onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);\n };\n const internalIconRender = file => {\n if (iconRender) {\n return iconRender(file, listType);\n }\n const isLoading = file.status === 'uploading';\n const fileIcon = (isImgUrl === null || isImgUrl === void 0 ? void 0 : isImgUrl(file)) ? /*#__PURE__*/React.createElement(PictureTwoTone, null) : /*#__PURE__*/React.createElement(FileTwoTone, null);\n let icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : /*#__PURE__*/React.createElement(PaperClipOutlined, null);\n if (listType === 'picture') {\n icon = isLoading ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : fileIcon;\n } else if (listType === 'picture-card' || listType === 'picture-circle') {\n icon = isLoading ? locale.uploading : fileIcon;\n }\n return icon;\n };\n const actionIconRender = (customIcon, callback, prefixCls, title, acceptUploadDisabled) => {\n const btnProps = {\n type: 'text',\n size: 'small',\n title,\n onClick: e => {\n var _a, _b;\n
|