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 11/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
22import type { ReactElement } from 'react' ;
33import React , { Component } from 'react' ;
4- import classNames from 'classnames' ;
4+ import clsx from 'classnames' ;
55import pickAttrs from 'rc-util/lib/pickAttrs' ;
66import defaultRequest from './request' ;
77import getUid from './uid' ;
@@ -264,9 +264,11 @@ class AjaxUploader extends Component<UploadProps> {
264264 component : Tag ,
265265 prefixCls,
266266 className,
267+ classNames = { } ,
267268 disabled,
268269 id,
269270 style,
271+ styles = { } ,
270272 multiple,
271273 accept,
272274 capture,
@@ -277,7 +279,7 @@ class AjaxUploader extends Component<UploadProps> {
277279 onMouseLeave,
278280 ...otherProps
279281 } = this . props ;
280- const cls = classNames ( {
282+ const cls = clsx ( {
281283 [ prefixCls ] : true ,
282284 [ `${ prefixCls } -disabled` ] : disabled ,
283285 [ className ] : className ,
@@ -307,7 +309,8 @@ class AjaxUploader extends Component<UploadProps> {
307309 ref = { this . saveFileInput }
308310 onClick = { e => e . stopPropagation ( ) } // https://github.com/ant-design/ant-design/issues/19948
309311 key = { this . state . uid }
310- style = { { display : 'none' } }
312+ style = { { display : 'none' , ...styles . input } }
313+ className = { classNames . input }
311314 accept = { accept }
312315 { ...dirProps }
313316 multiple = { multiple }
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ export interface UploadProps
3737 onMouseEnter ?: ( e : React . MouseEvent < HTMLDivElement > ) => void ;
3838 onMouseLeave ?: ( e : React . MouseEvent < HTMLDivElement > ) => void ;
3939 onClick ?: ( e : React . MouseEvent < HTMLDivElement > | React . KeyboardEvent < HTMLDivElement > ) => void ;
40+ classNames ?: {
41+ input ?: string ;
42+ } ;
43+ styles ?: {
44+ input ?: React . CSSProperties ;
45+ } ;
4046}
4147
4248export interface UploadProgressEvent extends Partial < ProgressEvent > {
Original file line number Diff line number Diff line change @@ -850,4 +850,19 @@ describe('uploader', () => {
850850
851851 expect ( requests [ 0 ] . url ) . toEqual ( 'bamboo' ) ;
852852 } ) ;
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+ } ) ;
853868} ) ;
You can’t perform that action at this time.
0 commit comments