mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-22 08:53:29 +08:00
feat: [v6] Retire deprecated api for upload
This commit is contained in:
parent
c4ea4db073
commit
0f5ce7fff9
@ -94,8 +94,6 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
|
||||
'usage',
|
||||
'`value` is not a valid prop, do you mean `fileList`?',
|
||||
);
|
||||
|
||||
warning.deprecated(!('transformFile' in props), 'transformFile', 'beforeUpload');
|
||||
}
|
||||
|
||||
// Control mode will auto fill file uid if not provided
|
||||
@ -154,7 +152,7 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
|
||||
};
|
||||
|
||||
const mergedBeforeUpload = async (file: RcFile, fileListArgs: RcFile[]) => {
|
||||
const { beforeUpload, transformFile } = props;
|
||||
const { beforeUpload } = props;
|
||||
|
||||
let parsedFile: File | Blob | string = file;
|
||||
if (beforeUpload) {
|
||||
@ -179,10 +177,6 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
|
||||
}
|
||||
}
|
||||
|
||||
if (transformFile) {
|
||||
parsedFile = await transformFile(parsedFile as any);
|
||||
}
|
||||
|
||||
return parsedFile as RcFile;
|
||||
};
|
||||
|
||||
|
@ -1285,38 +1285,6 @@ describe('Upload List', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('[deprecated] should support transformFile', (done) => {
|
||||
jest.useRealTimers();
|
||||
// biome-ignore lint/style/useConst: test only
|
||||
let wrapper: ReturnType<typeof render>;
|
||||
let lastFile: UploadFile;
|
||||
|
||||
const handleTransformFile = jest.fn();
|
||||
const onChange: UploadProps['onChange'] = ({ file }) => {
|
||||
if (file.status === 'done') {
|
||||
expect(file).not.toBe(lastFile);
|
||||
expect(handleTransformFile).toHaveBeenCalled();
|
||||
wrapper.unmount();
|
||||
done();
|
||||
}
|
||||
|
||||
lastFile = file;
|
||||
};
|
||||
wrapper = render(
|
||||
<Upload
|
||||
action="http://jsonplaceholder.typicode.com/posts/"
|
||||
transformFile={handleTransformFile}
|
||||
onChange={onChange}
|
||||
customRequest={successRequest}
|
||||
>
|
||||
<button type="button">upload</button>
|
||||
</Upload>,
|
||||
);
|
||||
fireEvent.change(wrapper.container.querySelector('input')!, {
|
||||
target: { files: [{ name: 'foo.png' }] },
|
||||
});
|
||||
});
|
||||
|
||||
it('should render button inside UploadList when listStyle is picture-card', () => {
|
||||
const {
|
||||
container: wrapper,
|
||||
|
@ -83,9 +83,6 @@ export type ItemRender<T = any> = (
|
||||
) => React.ReactNode;
|
||||
|
||||
type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
|
||||
type TransformFileHandler = (
|
||||
file: RcFile,
|
||||
) => string | Blob | File | PromiseLike<string | Blob | File>;
|
||||
type BeforeUploadValueType = void | boolean | string | Blob | File;
|
||||
|
||||
export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture' | 'hasControlInside'> {
|
||||
@ -125,8 +122,6 @@ export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture' | 'h
|
||||
locale?: UploadLocale;
|
||||
id?: string;
|
||||
previewFile?: PreviewFileHandler;
|
||||
/** @deprecated Please use `beforeUpload` directly */
|
||||
transformFile?: TransformFileHandler;
|
||||
iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
||||
isImageUrl?: (file: UploadFile<T>) => boolean;
|
||||
progress?: UploadListProgressProps;
|
||||
|
Loading…
Reference in New Issue
Block a user