mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 19:42:54 +08:00
feat: Upload adds showUploadList.previewIcon
(#32059)
* fix: add upload.showUploadList 'previewIcon' * Update componentsformat/upload/index.zh-CN.md Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
parent
c36d295b84
commit
9d1e0efca1
@ -174,13 +174,13 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
|
|||||||
let clone;
|
let clone;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clone = (new File([originFileObj], originFileObj.name, {
|
clone = new File([originFileObj], originFileObj.name, {
|
||||||
type: originFileObj.type,
|
type: originFileObj.type,
|
||||||
}) as any) as UploadFile;
|
}) as any as UploadFile;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
clone = (new Blob([originFileObj], {
|
clone = new Blob([originFileObj], {
|
||||||
type: originFileObj.type,
|
type: originFileObj.type,
|
||||||
}) as any) as UploadFile;
|
}) as any as UploadFile;
|
||||||
clone.name = originFileObj.name;
|
clone.name = originFileObj.name;
|
||||||
clone.lastModifiedDate = new Date();
|
clone.lastModifiedDate = new Date();
|
||||||
clone.lastModified = new Date().getTime();
|
clone.lastModified = new Date().getTime();
|
||||||
@ -326,7 +326,14 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
|
|||||||
showUploadList ? (
|
showUploadList ? (
|
||||||
<LocaleReceiver componentName="Upload" defaultLocale={defaultLocale.Upload}>
|
<LocaleReceiver componentName="Upload" defaultLocale={defaultLocale.Upload}>
|
||||||
{(locale: UploadLocale) => {
|
{(locale: UploadLocale) => {
|
||||||
const { showRemoveIcon, showPreviewIcon, showDownloadIcon, removeIcon, downloadIcon } =
|
const {
|
||||||
|
showRemoveIcon,
|
||||||
|
showPreviewIcon,
|
||||||
|
showDownloadIcon,
|
||||||
|
removeIcon,
|
||||||
|
previewIcon,
|
||||||
|
downloadIcon,
|
||||||
|
} =
|
||||||
typeof showUploadList === 'boolean' ? ({} as ShowUploadListInterface) : showUploadList;
|
typeof showUploadList === 'boolean' ? ({} as ShowUploadListInterface) : showUploadList;
|
||||||
return (
|
return (
|
||||||
<UploadList
|
<UploadList
|
||||||
@ -340,6 +347,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
|
|||||||
showPreviewIcon={showPreviewIcon}
|
showPreviewIcon={showPreviewIcon}
|
||||||
showDownloadIcon={showDownloadIcon}
|
showDownloadIcon={showDownloadIcon}
|
||||||
removeIcon={removeIcon}
|
removeIcon={removeIcon}
|
||||||
|
previewIcon={previewIcon}
|
||||||
downloadIcon={downloadIcon}
|
downloadIcon={downloadIcon}
|
||||||
iconRender={iconRender}
|
iconRender={iconRender}
|
||||||
locale={{ ...locale, ...propLocale }}
|
locale={{ ...locale, ...propLocale }}
|
||||||
|
@ -30,6 +30,7 @@ export interface ListItemProps {
|
|||||||
showPreviewIcon?: boolean;
|
showPreviewIcon?: boolean;
|
||||||
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
|
previewIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
iconRender: (file: UploadFile) => React.ReactNode;
|
iconRender: (file: UploadFile) => React.ReactNode;
|
||||||
actionIconRender: (
|
actionIconRender: (
|
||||||
customIcon: React.ReactNode,
|
customIcon: React.ReactNode,
|
||||||
@ -62,6 +63,7 @@ const ListItem = React.forwardRef(
|
|||||||
showPreviewIcon,
|
showPreviewIcon,
|
||||||
showRemoveIcon,
|
showRemoveIcon,
|
||||||
showDownloadIcon,
|
showDownloadIcon,
|
||||||
|
previewIcon: customPreviewIcon,
|
||||||
removeIcon: customRemoveIcon,
|
removeIcon: customRemoveIcon,
|
||||||
downloadIcon: customDownloadIcon,
|
downloadIcon: customDownloadIcon,
|
||||||
onPreview,
|
onPreview,
|
||||||
@ -206,7 +208,9 @@ const ListItem = React.forwardRef(
|
|||||||
onClick={e => onPreview(file, e)}
|
onClick={e => onPreview(file, e)}
|
||||||
title={locale.previewFile}
|
title={locale.previewFile}
|
||||||
>
|
>
|
||||||
<EyeOutlined />
|
{typeof customPreviewIcon === 'function'
|
||||||
|
? customPreviewIcon(file)
|
||||||
|
: customPreviewIcon || <EyeOutlined />}
|
||||||
</a>
|
</a>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ const InternalUploadList: React.ForwardRefRenderFunction<unknown, UploadListProp
|
|||||||
showRemoveIcon,
|
showRemoveIcon,
|
||||||
showDownloadIcon,
|
showDownloadIcon,
|
||||||
removeIcon,
|
removeIcon,
|
||||||
|
previewIcon,
|
||||||
downloadIcon,
|
downloadIcon,
|
||||||
progress,
|
progress,
|
||||||
appendAction,
|
appendAction,
|
||||||
@ -210,6 +211,7 @@ const InternalUploadList: React.ForwardRefRenderFunction<unknown, UploadListProp
|
|||||||
showRemoveIcon={showRemoveIcon}
|
showRemoveIcon={showRemoveIcon}
|
||||||
showDownloadIcon={showDownloadIcon}
|
showDownloadIcon={showDownloadIcon}
|
||||||
removeIcon={removeIcon}
|
removeIcon={removeIcon}
|
||||||
|
previewIcon={previewIcon}
|
||||||
downloadIcon={downloadIcon}
|
downloadIcon={downloadIcon}
|
||||||
iconRender={internalIconRender}
|
iconRender={internalIconRender}
|
||||||
actionIconRender={actionIconRender}
|
actionIconRender={actionIconRender}
|
||||||
|
@ -40,7 +40,7 @@ Uploading is the process of publishing information (web pages, text, pictures, v
|
|||||||
| openFileDialogOnClick | Click open file dialog | boolean | true | |
|
| openFileDialogOnClick | Click open file dialog | boolean | true | |
|
||||||
| previewFile | Customize preview file logic | (file: File \| Blob) => Promise<dataURL: string> | - | |
|
| previewFile | Customize preview file logic | (file: File \| Blob) => Promise<dataURL: string> | - | |
|
||||||
| progress | Custom progress bar | [ProgressProps](/components/progress/#API) (support `type="line"` only) | { strokeWidth: 2, showInfo: false } | 4.3.0 |
|
| progress | Custom progress bar | [ProgressProps](/components/progress/#API) (support `type="line"` only) | { strokeWidth: 2, showInfo: false } | 4.3.0 |
|
||||||
| showUploadList | Whether to show default upload list, could be an object to specify `showPreviewIcon`, `showRemoveIcon`, `showDownloadIcon`, `removeIcon` and `downloadIcon` individually | boolean \| { showPreviewIcon?: boolean, showDownloadIcon?: boolean, showRemoveIcon?: boolean, removeIcon?: ReactNode \| (file: UploadFile) => ReactNode, downloadIcon?: ReactNode \| (file: UploadFile) => ReactNode } | true | function: 4.7.0 |
|
| showUploadList | Whether to show default upload list, could be an object to specify `showPreviewIcon`, `showRemoveIcon`, `showDownloadIcon`, `removeIcon` and `downloadIcon` individually | boolean \| { showPreviewIcon?: boolean, showDownloadIcon?: boolean, showRemoveIcon?: boolean, previewIcon?: ReactNode \| (file: UploadFile) => ReactNode, removeIcon?: ReactNode \| (file: UploadFile) => ReactNode, downloadIcon?: ReactNode \| (file: UploadFile) => ReactNode } | true | function: 4.7.0 |
|
||||||
| withCredentials | The ajax upload with cookie sent | boolean | false | |
|
| withCredentials | The ajax upload with cookie sent | boolean | false | |
|
||||||
| onChange | A callback function, can be executed when uploading state is changing, see [onChange](#onChange) | function | - | |
|
| onChange | A callback function, can be executed when uploading state is changing, see [onChange](#onChange) | function | - | |
|
||||||
| onDrop | A callback function executed when files are dragged and dropped into upload area | (event: React.DragEvent) => void | - | 4.16.0 |
|
| onDrop | A callback function executed when files are dragged and dropped into upload area | (event: React.DragEvent) => void | - | 4.16.0 |
|
||||||
|
@ -41,7 +41,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/QaeBt_ZMg/Upload.svg
|
|||||||
| openFileDialogOnClick | 点击打开文件对话框 | boolean | true | |
|
| openFileDialogOnClick | 点击打开文件对话框 | boolean | true | |
|
||||||
| previewFile | 自定义文件预览逻辑 | (file: File \| Blob) => Promise<dataURL: string> | - | |
|
| previewFile | 自定义文件预览逻辑 | (file: File \| Blob) => Promise<dataURL: string> | - | |
|
||||||
| progress | 自定义进度条样式 | [ProgressProps](/components/progress/#API)(仅支持 `type="line"`) | { strokeWidth: 2, showInfo: false } | 4.3.0 |
|
| progress | 自定义进度条样式 | [ProgressProps](/components/progress/#API)(仅支持 `type="line"`) | { strokeWidth: 2, showInfo: false } | 4.3.0 |
|
||||||
| showUploadList | 是否展示文件列表, 可设为一个对象,用于单独设定 `showPreviewIcon`, `showRemoveIcon`, `showDownloadIcon`, `removeIcon` 和 `downloadIcon` | boolean \| { showPreviewIcon?: boolean, showRemoveIcon?: boolean, showDownloadIcon?: boolean, removeIcon?: ReactNode \| (file: UploadFile) => ReactNode, downloadIcon?: ReactNode \| (file: UploadFile) => ReactNode } | true | function: 4.7.0 |
|
| showUploadList | 是否展示文件列表, 可设为一个对象,用于单独设定 `showPreviewIcon`, `showRemoveIcon`, `showDownloadIcon`, `removeIcon` 和 `downloadIcon` | boolean \| { showPreviewIcon?: boolean, showRemoveIcon?: boolean, showDownloadIcon?: boolean, previewIcon?: ReactNode \| (file: UploadFile) => ReactNode, removeIcon?: ReactNode \| (file: UploadFile) => ReactNode, downloadIcon?: ReactNode \| (file: UploadFile) => ReactNode } | true | function: 4.7.0 |
|
||||||
| withCredentials | 上传请求时是否携带 cookie | boolean | false | |
|
| withCredentials | 上传请求时是否携带 cookie | boolean | false | |
|
||||||
| onChange | 上传文件改变时的状态,详见 [onChange](#onChange) | function | - | |
|
| onChange | 上传文件改变时的状态,详见 [onChange](#onChange) | function | - | |
|
||||||
| onDrop | 当文件被拖入上传区域时执行的回调功能 | (event: React.DragEvent) => void | - | 4.16.0 |
|
| onDrop | 当文件被拖入上传区域时执行的回调功能 | (event: React.DragEvent) => void | - | 4.16.0 |
|
||||||
|
@ -52,6 +52,7 @@ export interface ShowUploadListInterface {
|
|||||||
showDownloadIcon?: boolean;
|
showDownloadIcon?: boolean;
|
||||||
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
|
previewIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadLocale {
|
export interface UploadLocale {
|
||||||
@ -145,6 +146,7 @@ export interface UploadListProps<T = any> {
|
|||||||
showPreviewIcon?: boolean;
|
showPreviewIcon?: boolean;
|
||||||
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
|
previewIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
||||||
locale: UploadLocale;
|
locale: UploadLocale;
|
||||||
previewFile?: PreviewFileHandler;
|
previewFile?: PreviewFileHandler;
|
||||||
iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
||||||
|
Loading…
Reference in New Issue
Block a user