@@ -6,30 +6,37 @@ export const UploadFileStatus = PropsTypes.oneOf(['error', 'success', 'done', 'u
6
6
// [key: string]: string;
7
7
// }
8
8
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
+ }
29
36
30
37
export const UploadChangeParam = {
31
- file : UploadFile ,
32
- fileList : PropsTypes . arrayOf ( UploadFile ) ,
38
+ file : PropsTypes . custom ( UploadFile ) ,
39
+ fileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
33
40
event : PropsTypes . object ,
34
41
}
35
42
@@ -47,8 +54,8 @@ export const UploadLocale = PropsTypes.shape({
47
54
export const UploadProps = {
48
55
type : PropsTypes . oneOf ( [ 'drag' , 'select' ] ) ,
49
56
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 ) ) ,
52
59
action : PropsTypes . string . isRequired ,
53
60
data : PropsTypes . oneOfType ( [ PropsTypes . object , PropsTypes . func ] ) ,
54
61
headers : PropsTypes . object ,
@@ -72,15 +79,16 @@ export const UploadProps = {
72
79
}
73
80
74
81
export const UploadState = {
75
- fileList : PropsTypes . arrayOf ( UploadFile ) ,
82
+ fileList : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
76
83
dragState : PropsTypes . string ,
77
84
}
78
85
79
86
export const UploadListProps = {
80
87
listType : PropsTypes . oneOf ( [ 'text' , 'picture' , 'picture-card' ] ) ,
81
88
// onPreview: PropsTypes.func,
82
89
// onRemove: PropsTypes.func,
83
- items : PropsTypes . arrayOf ( UploadFile ) ,
90
+ // items: PropsTypes.arrayOf(UploadFile),
91
+ items : PropsTypes . arrayOf ( PropsTypes . custom ( UploadFile ) ) ,
84
92
// items: PropsTypes.any,
85
93
progressAttr : PropsTypes . object ,
86
94
prefixCls : PropsTypes . string ,
0 commit comments