From 41ad8666331fa116c956cfdc3fef0c88a9d07781 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:25:56 +0800 Subject: [PATCH] feat(upload-trigger): export slots type (#6599) --- src/upload/index.ts | 1 + src/upload/src/UploadTrigger.tsx | 5 +++++ src/upload/src/interface.ts | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/src/upload/index.ts b/src/upload/index.ts index 5f6e68a2d2b..778746532e3 100644 --- a/src/upload/index.ts +++ b/src/upload/index.ts @@ -3,3 +3,4 @@ export { default as NUpload, uploadProps } from './src/Upload' export { default as NUploadDragger } from './src/UploadDragger' export { default as NUploadFileList } from './src/UploadFileList' export { default as NUploadTrigger } from './src/UploadTrigger' +export type { UploadTriggerSlots } from './src/UploadTrigger' diff --git a/src/upload/src/UploadTrigger.tsx b/src/upload/src/UploadTrigger.tsx index 82134bf3fcc..d391f293e67 100644 --- a/src/upload/src/UploadTrigger.tsx +++ b/src/upload/src/UploadTrigger.tsx @@ -1,3 +1,4 @@ +import type { UploadTriggerDefaultSlotOptions } from './interface' import { computed, defineComponent, h, inject } from 'vue' import { NBaseIcon } from '../../_internal' import { AddIcon } from '../../_internal/icons' @@ -6,6 +7,10 @@ import { uploadInjectionKey } from './interface' import NUploadDragger from './UploadDragger' import { getFilesFromEntries } from './utils' +export interface UploadTriggerSlots { + default?: (options: UploadTriggerDefaultSlotOptions) => any +} + export default defineComponent({ name: 'UploadTrigger', props: { diff --git a/src/upload/src/interface.ts b/src/upload/src/interface.ts index 5c2b8c741d1..d3162b1ec15 100644 --- a/src/upload/src/interface.ts +++ b/src/upload/src/interface.ts @@ -132,3 +132,11 @@ export interface FileAndEntry { entry: FileSystemFileEntry | null source: 'dnd' | 'input' } + +export interface UploadTriggerDefaultSlotOptions { + handleClick: () => void + handleDragOver: (e: DragEvent) => void + handleDragEnter: (e: DragEvent) => void + handleDragLeave: (e: DragEvent) => void + handleDrop: (e: DragEvent) => void +}