From 26e6ded73cb72a7b15b946b2af05103a16479bc7 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:52:25 +0800 Subject: [PATCH] feat(dialog): add slots type (#6599) --- src/dialog/index.ts | 1 + src/dialog/src/Dialog.tsx | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/dialog/index.ts b/src/dialog/index.ts index a9acb1cbe92..4354d727557 100644 --- a/src/dialog/index.ts +++ b/src/dialog/index.ts @@ -1,5 +1,6 @@ export { useDialog, useDialogReactiveList } from './src/composables' export { NDialog } from './src/Dialog' +export type { DialogSlots } from './src/Dialog' export { dialogProps } from './src/dialogProps' export type { DialogProps } from './src/dialogProps' export { dialogProviderProps, NDialogProvider } from './src/DialogProvider' diff --git a/src/dialog/src/Dialog.tsx b/src/dialog/src/Dialog.tsx index 0a0e12ee9bc..7812bf68e46 100644 --- a/src/dialog/src/Dialog.tsx +++ b/src/dialog/src/Dialog.tsx @@ -1,7 +1,13 @@ import type { ThemeProps } from '../../_mixins' import type { DialogTheme } from '../styles' import { getMargin } from 'seemly' -import { computed, type CSSProperties, defineComponent, h } from 'vue' +import { + computed, + type CSSProperties, + defineComponent, + h, + type SlotsType +} from 'vue' import { NBaseClose, NBaseIcon } from '../../_internal' import { ErrorIcon, @@ -29,6 +35,14 @@ const iconRenderMap = { error: () => } +export interface DialogSlots { + action?: any + default?: any + header?: any + icon?: any + close?: any +} + export const NDialog = defineComponent({ name: 'Dialog', alias: [ @@ -39,6 +53,7 @@ export const NDialog = defineComponent({ ...(useTheme.props as ThemeProps), ...dialogProps }, + slots: Object as SlotsType, setup(props) { const { mergedComponentPropsRef,