@@ -6,30 +6,37 @@ export const UploadFileStatus = PropsTypes.oneOf(['error', 'success', 'done', 'u
66// [key: string]: string;
77// }
88
9- export const UploadFile = PropsTypes . shape ( {
10- uid : PropsTypes . oneOfType ( [
11- PropsTypes . string ,
12- PropsTypes . number ,
13- ] ) ,
14- size : PropsTypes . number ,
15- name : PropsTypes . string ,
16- filename : PropsTypes . string ,
17- lastModified : PropsTypes . number ,
18- lastModifiedDate : PropsTypes . any ,
19- url : PropsTypes . string ,
20- status : UploadFileStatus ,
21- percent : PropsTypes . number ,
22- thumbUrl : PropsTypes . string ,
23- originFileObj : PropsTypes . any ,
24- response : PropsTypes . any ,
25- error : PropsTypes . any ,
26- linkProps : PropsTypes . any ,
27- type : PropsTypes . string ,
28- } ) . loose
9+ // export const UploadFile = PropsTypes.shape({
10+ // uid: PropsTypes.oneOfType([
11+ // PropsTypes.string,
12+ // PropsTypes.number,
13+ // ]),
14+ // size: PropsTypes.number,
15+ // name: PropsTypes.string,
16+ // filename: PropsTypes.string,
17+ // lastModified: PropsTypes.number,
18+ // lastModifiedDate: PropsTypes.any,
19+ // url: PropsTypes.string,
20+ // status: UploadFileStatus,
21+ // percent: PropsTypes.number,
22+ // thumbUrl: PropsTypes.string,
23+ // originFileObj: PropsTypes.any,
24+ // response: PropsTypes.any,
25+ // error: PropsTypes.any,
26+ // linkProps: PropsTypes.any,
27+ // type: PropsTypes.string,
28+ // }).loose
29+
30+ function UploadFile ( { uid, name } ) {
31+ if ( ! uid && uid !== 0 ) return false
32+ if ( ! [ 'string' , 'number' ] . includes ( typeof uid ) ) return false
33+ if ( ! name && typeof name !== 'string' ) return false
34+ return true
35+ }
2936
3037export const UploadChangeParam = {
31- file : UploadFile ,
32- fileList : PropsTypes . arrayOf ( UploadFile ) ,
38+ file : PropsTypes . custom ( UploadFile ) ,
39+ fileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
3340 event : PropsTypes . object ,
3441}
3542
@@ -47,8 +54,8 @@ export const UploadLocale = PropsTypes.shape({
4754export const UploadProps = {
4855 type : PropsTypes . oneOf ( [ 'drag' , 'select' ] ) ,
4956 name : PropsTypes . string ,
50- defaultFileList : PropsTypes . arrayOf ( UploadFile ) ,
51- fileList : PropsTypes . arrayOf ( UploadFile ) ,
57+ defaultFileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
58+ fileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
5259 action : PropsTypes . string . isRequired ,
5360 data : PropsTypes . oneOfType ( [ PropsTypes . object , PropsTypes . func ] ) ,
5461 headers : PropsTypes . object ,
@@ -72,15 +79,16 @@ export const UploadProps = {
7279}
7380
7481export const UploadState = {
75- fileList : PropsTypes . arrayOf ( UploadFile ) ,
82+ fileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
7683 dragState : PropsTypes . string ,
7784}
7885
7986export const UploadListProps = {
8087 listType : PropsTypes . oneOf ( [ 'text' , 'picture' , 'picture-card' ] ) ,
8188 // onPreview: PropsTypes.func,
8289 // onRemove: PropsTypes.func,
83- items : PropsTypes . arrayOf ( UploadFile ) ,
90+ // items: PropsTypes.arrayOf(UploadFile),
91+ items : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
8492 // items: PropsTypes.any,
8593 progressAttr : PropsTypes . object ,
8694 prefixCls : PropsTypes . string ,
0 commit comments