1
1
import { computed , defineComponent , onBeforeUnmount , onMounted , ref } from 'vue' ;
2
- import type { ExtractPropTypes , PropType , CSSProperties } from 'vue' ;
2
+ import type { ExtractPropTypes , CSSProperties } from 'vue' ;
3
3
import EyeOutlined from '@ant-design/icons-vue/EyeOutlined' ;
4
4
import DeleteOutlined from '@ant-design/icons-vue/DeleteOutlined' ;
5
5
import DownloadOutlined from '@ant-design/icons-vue/DownloadOutlined' ;
@@ -16,36 +16,39 @@ import type {
16
16
import type { VueNode } from '../../_util/type' ;
17
17
import useConfigInject from '../../config-provider/hooks/useConfigInject' ;
18
18
import Transition , { getTransitionProps } from '../../_util/transition' ;
19
+ import { booleanType , stringType , functionType , arrayType , objectType } from '../../_util/type' ;
20
+
19
21
export const listItemProps = ( ) => {
20
22
return {
21
23
prefixCls : String ,
22
- locale : { type : Object as PropType < UploadLocale > , default : undefined as UploadLocale } ,
23
- file : Object as PropType < UploadFile > ,
24
- items : Array as PropType < UploadFile [ ] > ,
25
- listType : String as PropType < UploadListType > ,
26
- isImgUrl : Function as PropType < ( file : UploadFile ) => boolean > ,
24
+ locale : objectType < UploadLocale > ( undefined as UploadLocale ) ,
25
+ file : objectType < UploadFile > ( ) ,
26
+ items : arrayType < UploadFile [ ] > ( ) ,
27
+ listType : stringType < UploadListType > ( ) ,
28
+ isImgUrl : functionType < ( file : UploadFile ) => boolean > ( ) ,
27
29
28
- showRemoveIcon : { type : Boolean , default : undefined } ,
29
- showDownloadIcon : { type : Boolean , default : undefined } ,
30
- showPreviewIcon : { type : Boolean , default : undefined } ,
31
- removeIcon : Function as PropType < ( opt : { file : UploadFile } ) => VueNode > ,
32
- downloadIcon : Function as PropType < ( opt : { file : UploadFile } ) => VueNode > ,
33
- previewIcon : Function as PropType < ( opt : { file : UploadFile } ) => VueNode > ,
30
+ showRemoveIcon : booleanType ( ) ,
31
+ showDownloadIcon : booleanType ( ) ,
32
+ showPreviewIcon : booleanType ( ) ,
33
+ removeIcon : functionType < ( opt : { file : UploadFile } ) => VueNode > ( ) ,
34
+ downloadIcon : functionType < ( opt : { file : UploadFile } ) => VueNode > ( ) ,
35
+ previewIcon : functionType < ( opt : { file : UploadFile } ) => VueNode > ( ) ,
34
36
35
- iconRender : Function as PropType < ( opt : { file : UploadFile } ) => VueNode > ,
36
- actionIconRender : Function as PropType <
37
- ( opt : {
38
- customIcon : VueNode ;
39
- callback : ( ) => void ;
40
- prefixCls : string ;
41
- title ?: string | undefined ;
42
- } ) => VueNode
43
- > ,
44
- itemRender : Function as PropType < ItemRender > ,
45
- onPreview : Function as PropType < ( file : UploadFile , e : Event ) => void > ,
46
- onClose : Function as PropType < ( file : UploadFile ) => void > ,
47
- onDownload : Function as PropType < ( file : UploadFile ) => void > ,
48
- progress : Object as PropType < UploadListProgressProps > ,
37
+ iconRender : functionType < ( opt : { file : UploadFile } ) => VueNode > ( ) ,
38
+ actionIconRender :
39
+ functionType <
40
+ ( opt : {
41
+ customIcon : VueNode ;
42
+ callback : ( ) => void ;
43
+ prefixCls : string ;
44
+ title ?: string | undefined ;
45
+ } ) => VueNode
46
+ > ( ) ,
47
+ itemRender : functionType < ItemRender > ( ) ,
48
+ onPreview : functionType < ( file : UploadFile , e : Event ) => void > ( ) ,
49
+ onClose : functionType < ( file : UploadFile ) => void > ( ) ,
50
+ onDownload : functionType < ( file : UploadFile ) => void > ( ) ,
51
+ progress : objectType < UploadListProgressProps > ( ) ,
49
52
} ;
50
53
} ;
51
54
@@ -93,7 +96,6 @@ export default defineComponent({
93
96
const { class : className , style } = attrs ;
94
97
// This is used for legacy span make scrollHeight the wrong value.
95
98
// We will force these to be `display: block` with non `picture-card`
96
- const spanClassName = `${ prefixCls } -span` ;
97
99
98
100
const iconNode = iconRender ( { file } ) ;
99
101
let icon = < div class = { `${ prefixCls } -text-icon` } > { iconNode } </ div > ;
@@ -162,7 +164,7 @@ export default defineComponent({
162
164
< span
163
165
key = "download-delete"
164
166
class = { [
165
- `${ prefixCls } -list-item-card- actions` ,
167
+ `${ prefixCls } -list-item-actions` ,
166
168
{
167
169
picture : listType === 'picture' ,
168
170
} ,
@@ -231,30 +233,29 @@ export default defineComponent({
231
233
} else {
232
234
message = file . error ?. statusText || file . error ?. message || locale . uploadError ;
233
235
}
234
- const iconAndPreview = (
235
- < span class = { spanClassName } >
236
- { icon }
237
- { preview }
238
- </ span >
239
- ) ;
240
236
241
237
const dom = (
242
238
< div class = { infoUploadingClass } >
243
- < div class = { `${ prefixCls } -list-item-info` } > { iconAndPreview } </ div >
239
+ { icon }
240
+ { preview }
244
241
{ actions }
245
242
{ showProgress . value && (
246
243
< Transition { ...transitionProps . value } >
247
244
< div v-show = { file . status === 'uploading' } class = { `${ prefixCls } -list-item-progress` } >
248
245
{ 'percent' in file ? (
249
- < Progress { ...progressProps } type = "line" percent = { file . percent } />
246
+ < Progress
247
+ { ...( progressProps as UploadListProgressProps ) }
248
+ type = "line"
249
+ percent = { file . percent }
250
+ />
250
251
) : null }
251
252
</ div >
252
253
</ Transition >
253
254
) }
254
255
</ div >
255
256
) ;
256
257
const listContainerNameClass = {
257
- [ `${ prefixCls } -list-${ listType } -container` ] : true ,
258
+ [ `${ prefixCls } -list-item -container` ] : true ,
258
259
[ `${ className } ` ] : ! ! className ,
259
260
} ;
260
261
const item =
0 commit comments