File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
2
2
import type { ReactElement } from 'react' ;
3
3
import React , { Component } from 'react' ;
4
- import classNames from 'classnames' ;
4
+ import clsx from 'classnames' ;
5
5
import pickAttrs from 'rc-util/lib/pickAttrs' ;
6
6
import defaultRequest from './request' ;
7
7
import getUid from './uid' ;
@@ -264,9 +264,11 @@ class AjaxUploader extends Component<UploadProps> {
264
264
component : Tag ,
265
265
prefixCls,
266
266
className,
267
+ classNames = { } ,
267
268
disabled,
268
269
id,
269
270
style,
271
+ styles = { } ,
270
272
multiple,
271
273
accept,
272
274
capture,
@@ -277,7 +279,7 @@ class AjaxUploader extends Component<UploadProps> {
277
279
onMouseLeave,
278
280
...otherProps
279
281
} = this . props ;
280
- const cls = classNames ( {
282
+ const cls = clsx ( {
281
283
[ prefixCls ] : true ,
282
284
[ `${ prefixCls } -disabled` ] : disabled ,
283
285
[ className ] : className ,
@@ -307,7 +309,8 @@ class AjaxUploader extends Component<UploadProps> {
307
309
ref = { this . saveFileInput }
308
310
onClick = { e => e . stopPropagation ( ) } // https://github.com/ant-design/ant-design/issues/19948
309
311
key = { this . state . uid }
310
- style = { { display : 'none' } }
312
+ style = { { display : 'none' , ...styles . input } }
313
+ className = { classNames . input }
311
314
accept = { accept }
312
315
{ ...dirProps }
313
316
multiple = { multiple }
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ export interface UploadProps
37
37
onMouseEnter ?: ( e : React . MouseEvent < HTMLDivElement > ) => void ;
38
38
onMouseLeave ?: ( e : React . MouseEvent < HTMLDivElement > ) => void ;
39
39
onClick ?: ( e : React . MouseEvent < HTMLDivElement > | React . KeyboardEvent < HTMLDivElement > ) => void ;
40
+ classNames ?: {
41
+ input ?: string ;
42
+ } ;
43
+ styles ?: {
44
+ input ?: React . CSSProperties ;
45
+ } ;
40
46
}
41
47
42
48
export interface UploadProgressEvent extends Partial < ProgressEvent > {
Original file line number Diff line number Diff line change @@ -850,4 +850,19 @@ describe('uploader', () => {
850
850
851
851
expect ( requests [ 0 ] . url ) . toEqual ( 'bamboo' ) ;
852
852
} ) ;
853
+
854
+ it ( 'input style defaults to display none' , ( ) => {
855
+ const wrapper = mount ( < Uploader /> ) ;
856
+ expect ( wrapper . find ( 'input' ) . props ( ) . style . display ) . toBe ( 'none' ) ;
857
+ } ) ;
858
+
859
+ it ( 'classNames and styles should work' , ( ) => {
860
+ const wrapper = mount (
861
+ < Uploader classNames = { { input : 'bamboo-input' } } styles = { { input : { color : 'red' } } } /> ,
862
+ ) ;
863
+ expect ( wrapper . find ( '.bamboo-input' ) . length ) . toBeTruthy ( ) ;
864
+
865
+ expect ( wrapper . find ( '.bamboo-input' ) . props ( ) . style . color ) . toEqual ( 'red' ) ;
866
+ expect ( wrapper . find ( 'input' ) . props ( ) . style . display ) . toBe ( 'none' ) ;
867
+ } ) ;
853
868
} ) ;
You can’t perform that action at this time.
0 commit comments