Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing properties to ShowUploadListInterface #26406

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Dragger from './Dragger';
import UploadList from './UploadList';
import {
RcFile,
ShowUploadListInterface,
UploadProps,
UploadFile,
UploadLocale,
Expand Down Expand Up @@ -247,7 +248,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
<LocaleReceiver componentName="Upload" defaultLocale={defaultLocale.Upload}>
{(locale: UploadLocale) => {
const { showRemoveIcon, showPreviewIcon, showDownloadIcon, removeIcon, downloadIcon } =
typeof showUploadList === 'boolean' ? ({} as any) : showUploadList;
typeof showUploadList === 'boolean' ? ({} as ShowUploadListInterface) : showUploadList;
return (
<UploadList
listType={listType}
Expand All @@ -270,7 +271,9 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
);
}}
</LocaleReceiver>
) : button;
) : (
button
);

if (type === 'drag') {
const dragCls = classNames(
Expand Down
17 changes: 17 additions & 0 deletions components/upload/__tests__/type.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,21 @@ describe('Upload.typescript', () => {
);
expect(upload).toBeTruthy();
});

it('showUploadList', () => {
const upload = (
<Upload
showUploadList={{
showPreviewIcon: true,
showRemoveIcon: true,
showDownloadIcon: true,
removeIcon: 'Remove',
downloadIcon: 'Download',
}}
>
<span>click to upload</span>
</Upload>
);
expect(upload).toBeTruthy();
});
});
2 changes: 2 additions & 0 deletions components/upload/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface ShowUploadListInterface {
showRemoveIcon?: boolean;
showPreviewIcon?: boolean;
showDownloadIcon?: boolean;
removeIcon?: React.ReactNode;
downloadIcon?: React.ReactNode;
}

export interface UploadLocale {
Expand Down