|
|
@ -4,11 +4,12 @@ import RcUpload from 'rc-upload'; |
|
|
|
import useMergedState from 'rc-util/lib/hooks/useMergedState'; |
|
|
|
import * as React from 'react'; |
|
|
|
import { flushSync } from 'react-dom'; |
|
|
|
import warning from '../_util/warning'; |
|
|
|
import { ConfigContext } from '../config-provider'; |
|
|
|
import DisabledContext from '../config-provider/DisabledContext'; |
|
|
|
import defaultLocale from '../locale/en_US'; |
|
|
|
import { useLocale } from '../locale'; |
|
|
|
import warning from '../_util/warning'; |
|
|
|
import defaultLocale from '../locale/en_US'; |
|
|
|
import UploadList from './UploadList'; |
|
|
|
import type { |
|
|
|
RcFile, |
|
|
|
ShowUploadListInterface, |
|
|
@ -16,16 +17,23 @@ import type { |
|
|
|
UploadFile, |
|
|
|
UploadProps, |
|
|
|
} from './interface'; |
|
|
|
import UploadList from './UploadList'; |
|
|
|
import { file2Obj, getFileItem, removeFileItem, updateFileList } from './utils'; |
|
|
|
|
|
|
|
import useStyle from './style'; |
|
|
|
import { file2Obj, getFileItem, removeFileItem, updateFileList } from './utils'; |
|
|
|
|
|
|
|
export const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`; |
|
|
|
|
|
|
|
export type { UploadProps }; |
|
|
|
|
|
|
|
const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (props, ref) => { |
|
|
|
export interface UploadRef<T = any> { |
|
|
|
onBatchStart: RcUploadProps['onBatchStart']; |
|
|
|
onSuccess: (response: any, file: RcFile, xhr: any) => void; |
|
|
|
onProgress: (e: { percent: number }, file: RcFile) => void; |
|
|
|
onError: (error: Error, response: any, file: RcFile) => void; |
|
|
|
fileList: UploadFile<T>[]; |
|
|
|
upload: RcUpload | null; |
|
|
|
} |
|
|
|
|
|
|
|
const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (props, ref) => { |
|
|
|
const { |
|
|
|
fileList, |
|
|
|
defaultFileList, |
|
|
@ -461,7 +469,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
const Upload = React.forwardRef<unknown, UploadProps>(InternalUpload); |
|
|
|
const Upload = React.forwardRef<UploadRef, UploadProps>(InternalUpload); |
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'production') { |
|
|
|
Upload.displayName = 'Upload'; |
|
|
|