Skip to content

Commit

Permalink
feat: upload support rootClassName (#44060)
Browse files Browse the repository at this point in the history
* feat: upload support rootClassName

* feat: optimize code

* feat: optimize code
  • Loading branch information
kiner-tang committed Aug 7, 2023
1 parent 5e9ef68 commit 9436ece
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions components/upload/Upload.tsx
Expand Up @@ -62,6 +62,7 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
action = '',
accept = '',
supportServerRender = true,
rootClassName,
} = props;

// ===================== Disabled =====================
Expand Down Expand Up @@ -405,11 +406,18 @@ const InternalUpload: React.ForwardRefRenderFunction<UploadRef, UploadProps> = (
);
};

const wrapperCls = classNames(`${prefixCls}-wrapper`, className, hashId, ctxUpload?.className, {
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-picture-card-wrapper`]: listType === 'picture-card',
[`${prefixCls}-picture-circle-wrapper`]: listType === 'picture-circle',
});
const wrapperCls = classNames(
`${prefixCls}-wrapper`,
className,
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 };

Expand Down
2 changes: 1 addition & 1 deletion components/upload/__tests__/demo.test.ts
@@ -1,3 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('upload', { skip: ['crop-image.tsx'], testRootProps: false });
demoTest('upload', { skip: ['crop-image.tsx'] });
1 change: 1 addition & 0 deletions components/upload/interface.ts
Expand Up @@ -109,6 +109,7 @@ export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture'> {
onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
listType?: UploadListType;
className?: string;
rootClassName?: string;
onPreview?: (file: UploadFile<T>) => void;
onDownload?: (file: UploadFile<T>) => void;
onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>;
Expand Down

0 comments on commit 9436ece

Please sign in to comment.