feat: upload support rootClassName (#44060)

* feat: upload support rootClassName

* feat: optimize code

* feat: optimize code
This commit is contained in:
kiner-tang(文辉) 2023-08-07 18:04:44 +08:00 committed by GitHub
parent 5e9ef6803b
commit 9436ece6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -62,6 +62,7 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
action = '', action = '',
accept = '', accept = '',
supportServerRender = true, supportServerRender = true,
rootClassName,
} = props; } = props;
// ===================== Disabled ===================== // ===================== Disabled =====================
@ -405,11 +406,18 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
); );
}; };
const wrapperCls = classNames(`${prefixCls}-wrapper`, className, hashId, ctxUpload?.className, { const wrapperCls = classNames(
[`${prefixCls}-rtl`]: direction === 'rtl', `${prefixCls}-wrapper`,
[`${prefixCls}-picture-card-wrapper`]: listType === 'picture-card', className,
[`${prefixCls}-picture-circle-wrapper`]: listType === 'picture-circle', rootClassName,
}); hashId,
ctxUpload?.className,
{
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-picture-card-wrapper`]: listType === 'picture-card',
[`${prefixCls}-picture-circle-wrapper`]: listType === 'picture-circle',
},
);
const mergedStyle: React.CSSProperties = { ...ctxUpload?.style, ...style }; const mergedStyle: React.CSSProperties = { ...ctxUpload?.style, ...style };

View File

@ -1,3 +1,3 @@
import demoTest from '../../../tests/shared/demoTest'; import demoTest from '../../../tests/shared/demoTest';
demoTest('upload', { skip: ['crop-image.tsx'], testRootProps: false }); demoTest('upload', { skip: ['crop-image.tsx'] });

View File

@ -109,6 +109,7 @@ export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture'> {
onDrop?: (event: React.DragEvent<HTMLDivElement>) => void; onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
listType?: UploadListType; listType?: UploadListType;
className?: string; className?: string;
rootClassName?: string;
onPreview?: (file: UploadFile<T>) => void; onPreview?: (file: UploadFile<T>) => void;
onDownload?: (file: UploadFile<T>) => void; onDownload?: (file: UploadFile<T>) => void;
onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>; onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>;