11<script setup lang="ts">
22import { CloudUploadOutlined , LinkOutlined } from ' @ant-design/icons-vue' ;
33import { App , Button , Flex } from ' ant-design-vue' ;
4- import { Attachments , Sender } from ' ant-design-x-vue' ;
5- import { computed , ref , h } from ' vue' ;
4+ import { Attachments , AttachmentsProps , Sender , SenderProps } from ' ant-design-x-vue' ;
5+ import { ref , h } from ' vue' ;
66
77defineOptions ({ name: ' AXSenderPasteImageSetup' });
88
9+ type GetFunction <T > = T extends (... args : any []) => any ? T : never ;
10+ type PlaceholderType = Parameters <GetFunction <AttachmentsProps [' placeholder' ]>>[0 ];
11+ type PastFile = SenderProps [' onPasteFile' ];
12+ type FileChange = AttachmentsProps [' onChange' ];
13+
914const open = ref (false );
1015const items = ref ([]);
1116const text = ref (' ' );
1217
1318const attachmentsRef = ref (null );
1419const senderRef = ref <InstanceType <typeof Sender >>(null );
1520
16- const placeholder = (type ) =>
21+ const placeholder = (type : PlaceholderType ) =>
1722 type === ' drop'
1823 ? {
1924 title: ' Drop file here' ,
@@ -26,7 +31,7 @@ const placeholder = (type) =>
2631
2732const getDropContainer = () => senderRef .value ?.nativeElement ;
2833
29- const pastFile = (_ , files ) => {
34+ const pastFile: PastFile = (_ , files ) => {
3035 console .log (" past" )
3136 for (const file of files ) {
3237 attachmentsRef .value ?.upload (file );
@@ -36,10 +41,10 @@ const pastFile = (_, files) => {
3641
3742const submit = () => {
3843 items .value = [];
39- text .value = ' ' ;
44+ text .value = ' ' ;
4045}
4146
42- const fileChange = ({ fileList }) => items .value = fileList
47+ const fileChange: FileChange = ({ fileList }) => items .value = fileList
4348 </script >
4449<template >
4550 <App >
0 commit comments