mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
type: update type unknown with UploadRef (#42985)
* type: update type unknown with UploadRef * type: fix type
This commit is contained in:
parent
ad8dd24cc8
commit
1d1f4efcf4
@ -1,12 +1,15 @@
|
||||
import * as React from 'react';
|
||||
import type { UploadProps } from './interface';
|
||||
import type { UploadRef } from './Upload';
|
||||
import Upload from './Upload';
|
||||
import type { UploadProps } from './interface';
|
||||
|
||||
export type DraggerProps = UploadProps & { height?: number };
|
||||
|
||||
const Dragger = React.forwardRef<unknown, DraggerProps>(({ style, height, ...restProps }, ref) => (
|
||||
<Upload ref={ref} {...restProps} type="drag" style={{ ...style, height }} />
|
||||
));
|
||||
const Dragger = React.forwardRef<UploadRef, DraggerProps>(
|
||||
({ style, height, ...restProps }, ref) => (
|
||||
<Upload ref={ref} {...restProps} type="drag" style={{ ...style, height }} />
|
||||
),
|
||||
);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Dragger.displayName = 'Dragger';
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user