From 16e0e8b324b2f0cf2af0271ed3c97cebd9c59831 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 20:22:33 +0800 Subject: [PATCH 01/54] feat(alert): add slots type (#6599) --- src/alert/index.ts | 2 +- src/alert/src/Alert.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/alert/index.ts b/src/alert/index.ts index 0391272d7b5..d3ccb42e19c 100644 --- a/src/alert/index.ts +++ b/src/alert/index.ts @@ -1,2 +1,2 @@ export { alertProps, default as NAlert } from './src/Alert' -export type { AlertProps } from './src/Alert' +export type { AlertProps, AlertSlots } from './src/Alert' diff --git a/src/alert/src/Alert.tsx b/src/alert/src/Alert.tsx index fea59045ac9..5a5cdf74763 100644 --- a/src/alert/src/Alert.tsx +++ b/src/alert/src/Alert.tsx @@ -10,6 +10,7 @@ import { mergeProps, type PropType, ref, + type SlotsType, watchEffect } from 'vue' import { NBaseClose, NBaseIcon, NFadeInExpandTransition } from '../../_internal' @@ -56,10 +57,17 @@ export const alertProps = { export type AlertProps = ExtractPublicPropTypes +export interface AlertSlots { + default?: any + icon?: any + header?: any +} + export default defineComponent({ name: 'Alert', inheritAttrs: false, props: alertProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 19d637f285162a6fc835dfe2bf6e54a167c4953d Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 20:32:48 +0800 Subject: [PATCH 02/54] feat(auto-complete): add slots type (#6599) --- src/auto-complete/index.ts | 1 + src/auto-complete/src/AutoComplete.tsx | 12 +++++++++++- src/auto-complete/src/interface.ts | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/auto-complete/index.ts b/src/auto-complete/index.ts index ae80014a922..34278fd2642 100644 --- a/src/auto-complete/index.ts +++ b/src/auto-complete/index.ts @@ -1,6 +1,7 @@ export { autoCompleteProps, default as NAutoComplete } from './src/AutoComplete' export type { AutoCompleteProps } from './src/AutoComplete' export type { + AutoCompleteDefaultSlotOptions, AutoCompleteGroupOption, AutoCompleteInst, AutoCompleteOption diff --git a/src/auto-complete/src/AutoComplete.tsx b/src/auto-complete/src/AutoComplete.tsx index 506ca0b029b..5d927e03b1f 100644 --- a/src/auto-complete/src/AutoComplete.tsx +++ b/src/auto-complete/src/AutoComplete.tsx @@ -12,6 +12,7 @@ import type { } from '../../select/src/interface' import type { AutoCompleteTheme } from '../styles' import type { + AutoCompleteDefaultSlotOptions, AutoCompleteInst, AutoCompleteOption, AutoCompleteOptions, @@ -33,6 +34,7 @@ import { type InputHTMLAttributes, type PropType, ref, + type SlotsType, toRef, Transition, watchEffect, @@ -114,9 +116,17 @@ export const autoCompleteProps = { export type AutoCompleteProps = ExtractPublicPropTypes +export interface AutoCompleteSlots { + default?: AutoCompleteDefaultSlotOptions + empty?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'AutoComplete', props: autoCompleteProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { @@ -368,7 +378,7 @@ export default defineComponent({ handleFocus: this.handleFocus, handleBlur: this.handleBlur, value: this.mergedValue - }) + } as AutoCompleteDefaultSlotOptions) } const { mergedTheme } = this return ( diff --git a/src/auto-complete/src/interface.ts b/src/auto-complete/src/interface.ts index 0795ebc2f20..f6b2801739f 100644 --- a/src/auto-complete/src/interface.ts +++ b/src/auto-complete/src/interface.ts @@ -22,3 +22,11 @@ export interface AutoCompleteInst { focus: () => void blur: () => void } + +export interface AutoCompleteDefaultSlotOptions { + handleInput: (value: string) => void + handleFocus: (e: FocusEvent) => void + handleBlur: (e: FocusEvent) => void + value: string + theme: string | null +} From f4799d1cd2037beaf571be339bd8882e758e6d2b Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 20:36:23 +0800 Subject: [PATCH 03/54] fix(auto-complete): slots type (#6599) --- src/auto-complete/src/AutoComplete.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto-complete/src/AutoComplete.tsx b/src/auto-complete/src/AutoComplete.tsx index 5d927e03b1f..95871e6f5c0 100644 --- a/src/auto-complete/src/AutoComplete.tsx +++ b/src/auto-complete/src/AutoComplete.tsx @@ -117,7 +117,7 @@ export const autoCompleteProps = { export type AutoCompleteProps = ExtractPublicPropTypes export interface AutoCompleteSlots { - default?: AutoCompleteDefaultSlotOptions + default?: (options: AutoCompleteDefaultSlotOptions) => any empty?: any prefix?: any suffix?: any From 00c775c967fd5c322b16647fdce70367dbafc57b Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 20:39:34 +0800 Subject: [PATCH 04/54] feat(auto-complete): export slots type (#6599) --- src/auto-complete/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto-complete/index.ts b/src/auto-complete/index.ts index 34278fd2642..5784eab1ef9 100644 --- a/src/auto-complete/index.ts +++ b/src/auto-complete/index.ts @@ -1,5 +1,5 @@ export { autoCompleteProps, default as NAutoComplete } from './src/AutoComplete' -export type { AutoCompleteProps } from './src/AutoComplete' +export type { AutoCompleteProps, AutoCompleteSlots } from './src/AutoComplete' export type { AutoCompleteDefaultSlotOptions, AutoCompleteGroupOption, From 6efc1ff1cde12f110612cc95711633a7d6df149d Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 20:42:14 +0800 Subject: [PATCH 05/54] feat(avatar): add slots type (#6599) --- src/avatar/index.ts | 2 +- src/avatar/src/Avatar.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/avatar/index.ts b/src/avatar/index.ts index a57511cdd5a..821f86b69fe 100644 --- a/src/avatar/index.ts +++ b/src/avatar/index.ts @@ -1,2 +1,2 @@ export { avatarProps, default as NAvatar } from './src/Avatar' -export type { AvatarProps } from './src/Avatar' +export type { AvatarProps, AvatarSlots } from './src/Avatar' diff --git a/src/avatar/src/Avatar.tsx b/src/avatar/src/Avatar.tsx index 43d28a85c88..e4071a4f922 100644 --- a/src/avatar/src/Avatar.tsx +++ b/src/avatar/src/Avatar.tsx @@ -12,6 +12,7 @@ import { onMounted, type PropType, ref, + type SlotsType, type VNodeChild, watch, watchEffect @@ -65,9 +66,16 @@ export const avatarProps = { export type AvatarProps = ExtractPublicPropTypes +export interface AvatarSlots { + default: any + placeholder: any + fallback: any +} + export default defineComponent({ name: 'Avatar', props: avatarProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) const hasLoadErrorRef = ref(false) From f4901d6ab722130a9541451856828ef3040b65d2 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:05:23 +0800 Subject: [PATCH 06/54] feat(avatar-group): add slots type (#6599), may not be particularly precise --- src/avatar-group/index.ts | 4 ++++ src/avatar-group/src/AvatarGroup.tsx | 14 +++++++++++++- src/avatar-group/src/interface.ts | 8 ++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/avatar-group/src/interface.ts diff --git a/src/avatar-group/index.ts b/src/avatar-group/index.ts index 5f5357f709f..25c5da24628 100644 --- a/src/avatar-group/index.ts +++ b/src/avatar-group/index.ts @@ -1,2 +1,6 @@ export { avatarGroupProps, default as NAvatarGroup } from './src/AvatarGroup' export type { AvatarGroupOption, AvatarGroupProps } from './src/AvatarGroup' +export type { + AvatarGroupAvatarSlotOptions, + AvatarGroupRestSlotOptions +} from './src/interface' diff --git a/src/avatar-group/src/AvatarGroup.tsx b/src/avatar-group/src/AvatarGroup.tsx index 898e41ab81e..ddd853f842e 100644 --- a/src/avatar-group/src/AvatarGroup.tsx +++ b/src/avatar-group/src/AvatarGroup.tsx @@ -2,13 +2,18 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes } from '../../_utils' import type { Size } from '../../avatar/src/interface' import type { AvatarGroupTheme } from '../styles' +import type { + AvatarGroupAvatarSlotOptions, + AvatarGroupRestSlotOptions +} from './interface' import { computed, type CSSProperties, defineComponent, h, type PropType, - provide + provide, + type SlotsType } from 'vue' import { useConfig, useTheme } from '../../_mixins' import { useRtl } from '../../_mixins/use-rtl' @@ -40,9 +45,16 @@ export const avatarGroupProps = { export type AvatarGroupProps = ExtractPublicPropTypes +export interface AvatarGroupSlots { + avatar?: (info: AvatarGroupAvatarSlotOptions) => any + rest?: (info: AvatarGroupRestSlotOptions) => any + default?: any +} + export default defineComponent({ name: 'AvatarGroup', props: avatarGroupProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, mergedRtlRef } = useConfig(props) const mergedThemeRef = useTheme( diff --git a/src/avatar-group/src/interface.ts b/src/avatar-group/src/interface.ts new file mode 100644 index 00000000000..54a2bd3b1d4 --- /dev/null +++ b/src/avatar-group/src/interface.ts @@ -0,0 +1,8 @@ +export interface AvatarGroupAvatarSlotOptions { + option: Record +} + +export interface AvatarGroupRestSlotOptions { + options: Array + rest: number +} From aa30016f4901a2cff2adc79cb31bd564b6001009 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:19:10 +0800 Subject: [PATCH 07/54] feat(breadcrumb-item): add slots type (#6599) --- src/breadcrumb/src/BreadcrumbItem.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/breadcrumb/src/BreadcrumbItem.tsx b/src/breadcrumb/src/BreadcrumbItem.tsx index 854e3863f70..25d2c248e10 100644 --- a/src/breadcrumb/src/BreadcrumbItem.tsx +++ b/src/breadcrumb/src/BreadcrumbItem.tsx @@ -4,7 +4,8 @@ import { type ExtractPropTypes, h, inject, - type PropType + type PropType, + type SlotsType } from 'vue' import { resolveSlot, warn } from '../../_utils' import { useBrowserLocation } from '../../_utils/composable/use-browser-location' @@ -24,9 +25,15 @@ export type BreadcrumbItemProps = Partial< ExtractPropTypes > +export interface BreadcrumbItemSlots { + default?: any + separator?: any +} + export default defineComponent({ name: 'BreadcrumbItem', props: breadcrumbItemProps, + slots: Object as SlotsType, setup(props, { slots }) { const NBreadcrumb = inject(breadcrumbInjectionKey, null) if (!NBreadcrumb) { From 93fd98544002f2b9c3553347cc25cb7b11b2d06a Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:19:50 +0800 Subject: [PATCH 08/54] feat(breadcrumb-item): export slots type (#6599) --- src/breadcrumb/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/breadcrumb/index.ts b/src/breadcrumb/index.ts index dc228f42973..8e7dc9ade6e 100644 --- a/src/breadcrumb/index.ts +++ b/src/breadcrumb/index.ts @@ -4,4 +4,7 @@ export { breadcrumbItemProps, default as NBreadcrumbItem } from './src/BreadcrumbItem' -export type { BreadcrumbItemProps } from './src/BreadcrumbItem' +export type { + BreadcrumbItemProps, + BreadcrumbItemSlots +} from './src/BreadcrumbItem' From 1ef779c1ac9de16bd12a34d33a1078d1e39a8cc9 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:22:55 +0800 Subject: [PATCH 09/54] feat(button): add slots type (#6599) --- src/button/index.ts | 2 +- src/button/src/Button.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/button/index.ts b/src/button/index.ts index 6985a9ff9f5..0bb775f78b5 100644 --- a/src/button/index.ts +++ b/src/button/index.ts @@ -3,4 +3,4 @@ export { default as NButton, XButton as NxButton } from './src/Button' -export type { ButtonProps } from './src/Button' +export type { ButtonProps, ButtonSlots } from './src/Button' diff --git a/src/button/src/Button.tsx b/src/button/src/Button.tsx index 191c788ea32..06246048ae0 100644 --- a/src/button/src/Button.tsx +++ b/src/button/src/Button.tsx @@ -15,6 +15,7 @@ import { inject, type PropType, ref, + type SlotsType, type VNodeChild, watchEffect } from 'vue' @@ -95,9 +96,15 @@ export const buttonProps = { export type ButtonProps = ExtractPublicPropTypes +export interface ButtonSlots { + default?: any + icon?: any +} + const Button = defineComponent({ name: 'Button', props: buttonProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From f1eb6057c0071662b9876d9a401c7f71641fe17a Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:33:16 +0800 Subject: [PATCH 10/54] feat(calendar): add slots type (#6599) --- src/calendar/src/Calendar.tsx | 15 ++++++++++++++- src/calendar/src/interface.ts | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/calendar/src/Calendar.tsx b/src/calendar/src/Calendar.tsx index e4351875f2b..0fae9d49e5e 100644 --- a/src/calendar/src/Calendar.tsx +++ b/src/calendar/src/Calendar.tsx @@ -1,7 +1,13 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' import type { CalendarTheme } from '../styles' -import type { DateItem, OnPanelChange, OnUpdateValue } from './interface' +import type { + CalendarDefaultSlotOptions, + CalendarHeaderSlotOptions, + DateItem, + OnPanelChange, + OnUpdateValue +} from './interface' import { addMonths, format, @@ -19,6 +25,7 @@ import { h, type PropType, ref, + type SlotsType, toRef } from 'vue' import { NBaseIcon } from '../../_internal' @@ -46,9 +53,15 @@ export const calendarProps = { export type CalendarProps = ExtractPublicPropTypes +export interface CalendarSlots { + default?: (props: CalendarDefaultSlotOptions) => any + header?: (props: CalendarHeaderSlotOptions) => any +} + export default defineComponent({ name: 'Calendar', props: calendarProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) const themeRef = useTheme( diff --git a/src/calendar/src/interface.ts b/src/calendar/src/interface.ts index 864235813d2..07ff430b5c3 100644 --- a/src/calendar/src/interface.ts +++ b/src/calendar/src/interface.ts @@ -7,3 +7,14 @@ export interface DateItem { } export type OnPanelChange = (info: { year: number, month: number }) => void + +export interface CalendarDefaultSlotOptions { + year: number + month: number + date: number +} + +export interface CalendarHeaderSlotOptions { + year: number + month: number +} From afcb2dca92b19ae82e1efcc5e971f6615e491984 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 21:36:26 +0800 Subject: [PATCH 11/54] feat(card): add slots type (#6599) --- src/card/index.ts | 2 +- src/card/src/Card.tsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/card/index.ts b/src/card/index.ts index 22c04a8bfb1..429a3ef13c5 100644 --- a/src/card/index.ts +++ b/src/card/index.ts @@ -1,2 +1,2 @@ export { cardProps, default as NCard } from './src/Card' -export type { CardProps, CardSegmented } from './src/Card' +export type { CardProps, CardSegmented, CardSlots } from './src/Card' diff --git a/src/card/src/Card.tsx b/src/card/src/Card.tsx index 4371600a7fd..ac03fe78d0e 100644 --- a/src/card/src/Card.tsx +++ b/src/card/src/Card.tsx @@ -8,6 +8,7 @@ import { defineComponent, h, type PropType, + type SlotsType, type VNodeChild } from 'vue' import { NBaseClose } from '../../_internal' @@ -71,9 +72,19 @@ export const cardProps = { export type CardProps = ExtractPublicPropTypes +export interface CardSlots { + default?: any + cover?: any + header?: any + 'header-extra'?: any + footer?: any + action?: any +} + export default defineComponent({ name: 'Card', props: cardProps, + slots: Object as SlotsType, setup(props) { const handleCloseClick = (): void => { const { onClose } = props From 14b2a52982a4bdf667050be26d94bd2435911644 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:11:51 +0800 Subject: [PATCH 12/54] feat(carousel): add slots type (#6599) --- src/carousel/index.ts | 8 ++++++-- src/carousel/src/Carousel.tsx | 18 +++++++++++++++++- src/carousel/src/interface.ts | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/carousel/index.ts b/src/carousel/index.ts index 9c271b83dd0..686633df445 100644 --- a/src/carousel/index.ts +++ b/src/carousel/index.ts @@ -1,4 +1,8 @@ export { carouselProps, default as NCarousel } from './src/Carousel' -export type { CarouselProps } from './src/Carousel' +export type { CarouselProps, CarouselSlots } from './src/Carousel' export { default as NCarouselItem } from './src/CarouselItem' -export type { CarouselInst } from './src/interface' +export type { + CarouselArrowSlotOptions, + CarouselDotSlotOptions, + CarouselInst +} from './src/interface' diff --git a/src/carousel/src/Carousel.tsx b/src/carousel/src/Carousel.tsx index 46205c985bc..fa3756b030e 100644 --- a/src/carousel/src/Carousel.tsx +++ b/src/carousel/src/Carousel.tsx @@ -1,9 +1,18 @@ -import type { CSSProperties, PropType, Ref, TransitionProps, VNode } from 'vue' +import type { + CSSProperties, + PropType, + Ref, + SlotsType, + TransitionProps, + VNode +} from 'vue' import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes } from '../../_utils' import type { CarouselTheme } from '../styles' import type { ArrowScopedSlotProps, + CarouselArrowSlotOptions, + CarouselDotSlotOptions, CarouselInst, DotScopedSlotProps, Size @@ -139,12 +148,19 @@ export const carouselProps = { export type CarouselProps = ExtractPublicPropTypes +export interface CarouselSlots { + default?: () => any + arrow?: (info: CarouselArrowSlotOptions) => any + dots?: (info: CarouselDotSlotOptions) => any +} + // only one carousel is allowed to trigger touch globally let globalDragging = false export default defineComponent({ name: 'Carousel', props: carouselProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) // Dom diff --git a/src/carousel/src/interface.ts b/src/carousel/src/interface.ts index c6197512a89..5b9d8d42b09 100644 --- a/src/carousel/src/interface.ts +++ b/src/carousel/src/interface.ts @@ -25,3 +25,17 @@ export interface Size { width: number height: number } + +export interface CarouselArrowSlotOptions { + total: number + currentIndex: number + to: (index: number) => void + prev: () => void + next: () => void +} + +export interface CarouselDotSlotOptions { + total: number + currentIndex: number + to: (index: number) => void +} From b09b168e2cd334f925e89a843986953880995359 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:15:01 +0800 Subject: [PATCH 13/54] feat(cascader): add slots type (#6599) --- src/cascader/index.ts | 2 +- src/cascader/src/Cascader.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cascader/index.ts b/src/cascader/index.ts index a849023bb9b..b2586a11eba 100644 --- a/src/cascader/index.ts +++ b/src/cascader/index.ts @@ -1,3 +1,3 @@ export { cascaderProps, default as NCascader } from './src/Cascader' -export type { CascaderProps } from './src/Cascader' +export type { CascaderProps, CascaderSlots } from './src/Cascader' export type { CascaderInst, CascaderOption } from './src/interface' diff --git a/src/cascader/src/Cascader.tsx b/src/cascader/src/Cascader.tsx index f027dde292b..b4138a989fc 100644 --- a/src/cascader/src/Cascader.tsx +++ b/src/cascader/src/Cascader.tsx @@ -36,6 +36,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, type VNode, type VNodeChild, @@ -193,9 +194,17 @@ export const cascaderProps = { export type CascaderProps = ExtractPublicPropTypes +export interface CascaderSlots { + action?: any + arrow?: any + empty?: any + 'not-found'?: any +} + export default defineComponent({ name: 'Cascader', props: cascaderProps, + slots: Object as SlotsType, setup(props, { slots }) { if (__DEV__) { watchEffect(() => { From e3ab2bba8dc2a1fdc420666c72bc308ea4f4f678 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:22:14 +0800 Subject: [PATCH 14/54] feat(collapse): add slots type (#6599) --- src/collapse/index.ts | 10 ++++++++-- src/collapse/src/Collapse.tsx | 10 +++++++++- src/collapse/src/CollapseItem.tsx | 12 ++++++++++++ src/collapse/src/interface.ts | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/collapse/index.ts b/src/collapse/index.ts index 5897ca13679..97afb1d046d 100644 --- a/src/collapse/index.ts +++ b/src/collapse/index.ts @@ -1,4 +1,10 @@ export { collapseProps, default as NCollapse } from './src/Collapse' -export type { CollapseProps } from './src/Collapse' +export type { CollapseProps, CollapseSlots } from './src/Collapse' export { collapseItemProps, default as NCollapseItem } from './src/CollapseItem' -export type { CollapseItemProps } from './src/CollapseItem' +export type { CollapseItemProps, CollapseItemSlots } from './src/CollapseItem' +export type { + CollapseArrowSlotOptions, + CollapseItemArrowSlotOptions, + CollapseItemHeaderExtraSlotOptions, + CollapseItemHeaderSlotOptions +} from './src/interface' diff --git a/src/collapse/src/Collapse.tsx b/src/collapse/src/Collapse.tsx index 56b4fa5a3df..951fd26f48e 100644 --- a/src/collapse/src/Collapse.tsx +++ b/src/collapse/src/Collapse.tsx @@ -1,6 +1,7 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' import type { + CollapseArrowSlotOptions, HeaderClickInfo, OnItemHeaderClick, OnItemHeaderClickImpl, @@ -18,7 +19,8 @@ import { provide, type Ref, ref, - type Slots + type Slots, + type SlotsType } from 'vue' import { useConfig, useTheme, useThemeClass } from '../../_mixins' import { useRtl } from '../../_mixins/use-rtl' @@ -82,6 +84,11 @@ export const collapseProps = { export type CollapseProps = ExtractPublicPropTypes +export interface CollapseSlots { + default?: any + arrow?: (props: CollapseArrowSlotOptions) => any +} + export interface NCollapseInjection { props: ExtractPropTypes expandedNamesRef: Ref | null> @@ -100,6 +107,7 @@ export const collapseInjectionKey export default defineComponent({ name: 'Collapse', props: collapseProps, + slots: Object as SlotsType, setup(props, { slots }) { const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props) diff --git a/src/collapse/src/CollapseItem.tsx b/src/collapse/src/CollapseItem.tsx index 2b9e51f9221..5d629e5d81a 100644 --- a/src/collapse/src/CollapseItem.tsx +++ b/src/collapse/src/CollapseItem.tsx @@ -1,4 +1,9 @@ import type { ExtractPublicPropTypes } from '../../_utils' +import type { + CollapseItemArrowSlotOptions, + CollapseItemHeaderExtraSlotOptions, + CollapseItemHeaderSlotOptions +} from './interface' import { createId, happensIn } from 'seemly' import { useMemo } from 'vooks' import { computed, defineComponent, h, inject, type PropType, toRef } from 'vue' @@ -26,6 +31,13 @@ export const collapseItemProps = { export type CollapseItemProps = ExtractPublicPropTypes +export interface CollapseItemSlots { + default?: any + header?: (props: CollapseItemHeaderSlotOptions) => any + 'header-extra'?: (props: CollapseItemHeaderExtraSlotOptions) => any + arrow?: (props: CollapseItemArrowSlotOptions) => any +} + export default defineComponent({ name: 'CollapseItem', props: collapseItemProps, diff --git a/src/collapse/src/interface.ts b/src/collapse/src/interface.ts index 7fe3765d773..87cb6c1d5db 100644 --- a/src/collapse/src/interface.ts +++ b/src/collapse/src/interface.ts @@ -36,3 +36,19 @@ export interface HeaderClickInfo { expanded: boolean event: MouseEvent } + +export interface CollapseArrowSlotOptions { + collapsed: boolean +} + +export interface CollapseItemHeaderSlotOptions { + collapsed: boolean +} + +export interface CollapseItemHeaderExtraSlotOptions { + collapsed: boolean +} + +export interface CollapseItemArrowSlotOptions { + collapsed: boolean +} From 5df707c7fc1135229a956a1ac3f228c7551553ec Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:28:41 +0800 Subject: [PATCH 15/54] feat(color-picker): add slots type (#6599) --- src/color-picker/index.ts | 2 +- src/color-picker/src/ColorPicker.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/color-picker/index.ts b/src/color-picker/index.ts index 36d55b94744..72879f656ce 100644 --- a/src/color-picker/index.ts +++ b/src/color-picker/index.ts @@ -1,2 +1,2 @@ export { colorPickerProps, default as NColorPicker } from './src/ColorPicker' -export type { ColorPickerProps } from './src/ColorPicker' +export type { ColorPickerProps, ColorPickerSlots } from './src/ColorPicker' diff --git a/src/color-picker/src/ColorPicker.tsx b/src/color-picker/src/ColorPicker.tsx index f50d9c3fb7f..0efdd2cdea6 100644 --- a/src/color-picker/src/ColorPicker.tsx +++ b/src/color-picker/src/ColorPicker.tsx @@ -43,6 +43,7 @@ import { provide, type Ref, ref, + type SlotsType, toRef, Transition, type VNode, @@ -124,9 +125,16 @@ export const colorPickerProps = { export type ColorPickerProps = ExtractPublicPropTypes +export interface ColorPickerSlots { + default?: any + label?: (color: string | null) => any + action?: any +} + export default defineComponent({ name: 'ColorPicker', props: colorPickerProps, + slots: Object as SlotsType, setup(props, { slots }) { const selfRef = ref(null) let upcomingValue: string | null = null From 4cfb1593ced3b77b463b4c10cb25b1d977732ea9 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:36:13 +0800 Subject: [PATCH 16/54] feat(data-table): add slots type (#6599) --- src/data-table/index.ts | 1 + src/data-table/src/DataTable.tsx | 3 +++ src/data-table/src/interface.ts | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/src/data-table/index.ts b/src/data-table/index.ts index 2de0bb87b1e..498cce14009 100644 --- a/src/data-table/index.ts +++ b/src/data-table/index.ts @@ -21,6 +21,7 @@ export type { RowData as DataTableRowData, RowKey as DataTableRowKey, TableSelectionColumn as DataTableSelectionColumn, + DataTableSlots, SortState as DataTableSortState } from './src/interface' export * from './src/publicTypes' diff --git a/src/data-table/src/DataTable.tsx b/src/data-table/src/DataTable.tsx index 3e7c9942027..9c7cd9fc0e3 100644 --- a/src/data-table/src/DataTable.tsx +++ b/src/data-table/src/DataTable.tsx @@ -1,6 +1,7 @@ import type { CsvOptionsType, DataTableInst, + DataTableSlots, MainTableRef, RowKey } from './interface' @@ -12,6 +13,7 @@ import { h, provide, ref, + type SlotsType, toRef, Transition, watchEffect @@ -42,6 +44,7 @@ export default defineComponent({ name: 'DataTable', alias: ['AdvancedTable'], props: dataTableProps, + slots: Object as SlotsType, setup(props, { slots }) { if (__DEV__) { watchEffect(() => { diff --git a/src/data-table/src/interface.ts b/src/data-table/src/interface.ts index a5b0e1ea362..064280b12d1 100644 --- a/src/data-table/src/interface.ts +++ b/src/data-table/src/interface.ts @@ -178,6 +178,12 @@ export const dataTableProps = { > } as const +export interface DataTableSlots { + default?: any + empty?: any + loading?: any +} + export type FilterOptionValue = string | number export type ColumnKey = string | number export type RowKey = string | number From bbe901d84881e2b7e0e553922cd0c9be0de21c3f Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:46:43 +0800 Subject: [PATCH 17/54] feat(date-picker): add slots type (#6599) --- src/date-picker/index.ts | 1 + src/date-picker/src/DatePicker.tsx | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/date-picker/index.ts b/src/date-picker/index.ts index e68b709cf83..5b7ffca84f8 100644 --- a/src/date-picker/index.ts +++ b/src/date-picker/index.ts @@ -1,3 +1,4 @@ export { default as NDatePicker } from './src/DatePicker' +export type { DatePickerSlots } from './src/DatePicker' export { datePickerProps } from './src/props' export type * from './src/public-types' diff --git a/src/date-picker/src/DatePicker.tsx b/src/date-picker/src/DatePicker.tsx index 7a503337d21..79ed7724c6c 100644 --- a/src/date-picker/src/DatePicker.tsx +++ b/src/date-picker/src/DatePicker.tsx @@ -23,6 +23,7 @@ import { provide, type Ref, ref, + type SlotsType, toRef, Transition, type VNode, @@ -68,9 +69,20 @@ import { export type DatePickerSetupProps = ExtractPropTypes +export interface DatePickerSlots { + 'date-icon'?: any + footer?: any + 'next-month'?: any + 'next-year'?: any + 'prev-month'?: any + 'prev-year'?: any + separator?: any +} + export default defineComponent({ name: 'DatePicker', props: datePickerProps, + slots: Object as SlotsType, setup(props, { slots }) { if (__DEV__) { watchEffect(() => { From 0139b7451af623817f5ad5da40f071fbc65af5dc Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:47:09 +0800 Subject: [PATCH 18/54] feat(descriptions): add slots type (#6599) --- src/descriptions/index.ts | 11 +++++++++-- src/descriptions/src/Descriptions.tsx | 7 +++++++ src/descriptions/src/DescriptionsItem.ts | 13 ++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/descriptions/index.ts b/src/descriptions/index.ts index d7555eaa3b1..7a9f1d4d9fd 100644 --- a/src/descriptions/index.ts +++ b/src/descriptions/index.ts @@ -1,7 +1,14 @@ export { descriptionsProps, default as NDescriptions } from './src/Descriptions' -export type { DescriptionProps, DescriptionsProps } from './src/Descriptions' +export type { + DescriptionProps, + DescriptionsProps, + DescriptionsSlots +} from './src/Descriptions' export { descriptionsItemProps, default as NDescriptionsItem } from './src/DescriptionsItem' -export type { DescriptionItemProps } from './src/DescriptionsItem' +export type { + DescriptionItemProps, + DescriptionItemSlots +} from './src/DescriptionsItem' diff --git a/src/descriptions/src/Descriptions.tsx b/src/descriptions/src/Descriptions.tsx index a7491499045..e21b5b8c88b 100644 --- a/src/descriptions/src/Descriptions.tsx +++ b/src/descriptions/src/Descriptions.tsx @@ -9,6 +9,7 @@ import { defineComponent, h, type PropType, + type SlotsType, type VNode } from 'vue' import { useConfig, useTheme, useThemeClass } from '../../_mixins' @@ -58,9 +59,15 @@ export type DescriptionsProps = ExtractPublicPropTypes /** @deprecated You should use `DescriptionsProps` */ export type DescriptionProps = DescriptionsProps +export interface DescriptionsSlots { + default?: any + header?: any +} + export default defineComponent({ name: 'Descriptions', props: descriptionsProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) const themeRef = useTheme( diff --git a/src/descriptions/src/DescriptionsItem.ts b/src/descriptions/src/DescriptionsItem.ts index 8628264f3ad..abef0751204 100644 --- a/src/descriptions/src/DescriptionsItem.ts +++ b/src/descriptions/src/DescriptionsItem.ts @@ -1,5 +1,10 @@ import type { ExtractPublicPropTypes } from '../../_utils' -import { type CSSProperties, defineComponent, type PropType } from 'vue' +import { + type CSSProperties, + defineComponent, + type PropType, + type SlotsType +} from 'vue' import { DESCRIPTION_ITEM_FLAG } from './utils' export const descriptionsItemProps = { @@ -18,10 +23,16 @@ export type DescriptionItemProps = ExtractPublicPropTypes< typeof descriptionsItemProps > +export interface DescriptionItemSlots { + default?: any + label?: any +} + export default defineComponent({ name: 'DescriptionsItem', [DESCRIPTION_ITEM_FLAG]: true, props: descriptionsItemProps, + slots: Object as SlotsType, render() { return null } From 26e6ded73cb72a7b15b946b2af05103a16479bc7 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:52:25 +0800 Subject: [PATCH 19/54] 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, From f86adc3baa33c9d6a1a95648068142eb73327757 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:55:00 +0800 Subject: [PATCH 20/54] feat(drawer-content): add slots type (#6599) --- src/drawer/index.ts | 5 ++++- src/drawer/src/DrawerContent.tsx | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/drawer/index.ts b/src/drawer/index.ts index c0b32896ef3..0d8dee11138 100644 --- a/src/drawer/index.ts +++ b/src/drawer/index.ts @@ -5,4 +5,7 @@ export { drawerContentProps, default as NDrawerContent } from './src/DrawerContent' -export type { DrawerContentProps } from './src/DrawerContent' +export type { + DrawerContentProps, + DrawerContentSlots +} from './src/DrawerContent' diff --git a/src/drawer/src/DrawerContent.tsx b/src/drawer/src/DrawerContent.tsx index e7f81802b91..19b899dc276 100644 --- a/src/drawer/src/DrawerContent.tsx +++ b/src/drawer/src/DrawerContent.tsx @@ -5,7 +5,8 @@ import { defineComponent, h, inject, - type PropType + type PropType, + type SlotsType } from 'vue' import { NBaseClose, NScrollbar } from '../../_internal' import { throwError } from '../../_utils' @@ -30,9 +31,16 @@ export type DrawerContentProps = ExtractPublicPropTypes< typeof drawerContentProps > +export interface DrawerContentSlots { + default?: any + header?: any + footer?: any +} + export default defineComponent({ name: 'DrawerContent', props: drawerContentProps, + slots: Object as SlotsType, setup() { const NDrawer = inject(drawerInjectionKey, null) if (!NDrawer) { From 373732cf8d3756117935df13597d7ae39ad8a03b Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 22:59:22 +0800 Subject: [PATCH 21/54] feat(dynamic-input): add slots type (#6599) --- src/dynamic-input/index.ts | 6 +++++- src/dynamic-input/src/DynamicInput.tsx | 13 ++++++++++++- src/dynamic-input/src/interface.ts | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/dynamic-input/index.ts b/src/dynamic-input/index.ts index 63739648f96..c8ad2322d59 100644 --- a/src/dynamic-input/index.ts +++ b/src/dynamic-input/index.ts @@ -1,2 +1,6 @@ export { dynamicInputProps, default as NDynamicInput } from './src/DynamicInput' -export type { DynamicInputProps } from './src/DynamicInput' +export type { DynamicInputProps, DynamicInputSlots } from './src/DynamicInput' +export type { + DynamicInputActionSlotOptions, + DynamicInputDefaultSlotOptions +} from './src/interface' diff --git a/src/dynamic-input/src/DynamicInput.tsx b/src/dynamic-input/src/DynamicInput.tsx index 15402d382a4..04c64b8f25a 100644 --- a/src/dynamic-input/src/DynamicInput.tsx +++ b/src/dynamic-input/src/DynamicInput.tsx @@ -2,7 +2,11 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' import type { ButtonProps } from '../../button' import type { DynamicInputTheme } from '../styles' -import type { OnUpdateValue } from './interface' +import type { + DynamicInputActionSlotOptions, + DynamicInputDefaultSlotOptions, + OnUpdateValue +} from './interface' import { createId } from 'seemly' import { useMergedState } from 'vooks' import { @@ -88,6 +92,13 @@ export const dynamicInputProps = { export type DynamicInputProps = ExtractPublicPropTypes +export interface DynamicInputSlots { + action?: (options: DynamicInputActionSlotOptions) => any + default?: (options: DynamicInputDefaultSlotOptions) => any + 'create-button-default'?: any + 'create-button-icon'?: any +} + export default defineComponent({ name: 'DynamicInput', props: dynamicInputProps, diff --git a/src/dynamic-input/src/interface.ts b/src/dynamic-input/src/interface.ts index eafada8916c..d054d07a87c 100644 --- a/src/dynamic-input/src/interface.ts +++ b/src/dynamic-input/src/interface.ts @@ -14,3 +14,16 @@ export const dynamicInputInjectionKey = createInjectionKey('n-dynamic-input') export type OnUpdateValue = (value: T[]) => void + +export interface DynamicInputDefaultSlotOptions { + value: any + index: number +} + +export interface DynamicInputActionSlotOptions { + value: any + index: number + create: (index: number) => void + remove: (index: number) => void + move: (type: 'up' | 'down', index: number) => void +} From e5fab2cb26ddf58267f58961c7ad17aca237e5a2 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:02:47 +0800 Subject: [PATCH 22/54] feat(dynamic-tags): add slots type (#6599) --- src/dynamic-tags/index.ts | 8 ++++++-- src/dynamic-tags/src/DynamicTags.tsx | 10 ++++++++++ src/dynamic-tags/src/interface.ts | 10 ++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/dynamic-tags/index.ts b/src/dynamic-tags/index.ts index 8cfb36317af..acb220d1c1a 100644 --- a/src/dynamic-tags/index.ts +++ b/src/dynamic-tags/index.ts @@ -1,3 +1,7 @@ export { dynamicTagsProps, default as NDynamicTags } from './src/DynamicTags' -export type { DynamicTagsProps } from './src/DynamicTags' -export type { DynamicTagsOption } from './src/interface' +export type { DynamicTagsProps, DynamicTagsSlots } from './src/DynamicTags' +export type { + DynamicTagsInputSlotOptions, + DynamicTagsOption, + DynamicTagsTriggerSlotOptions +} from './src/interface' diff --git a/src/dynamic-tags/src/DynamicTags.tsx b/src/dynamic-tags/src/DynamicTags.tsx index e9056463e88..fa959dc58c5 100644 --- a/src/dynamic-tags/src/DynamicTags.tsx +++ b/src/dynamic-tags/src/DynamicTags.tsx @@ -3,7 +3,9 @@ import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' import type { InputInst, InputProps } from '../../input' import type { DynamicTagsTheme } from '../styles' import type { + DynamicTagsInputSlotOptions, DynamicTagsOption, + DynamicTagsTriggerSlotOptions, OnCreate, OnUpdateValue, OnUpdateValueImpl @@ -17,6 +19,7 @@ import { nextTick, type PropType, ref, + type SlotsType, toRef, type VNodeChild, watchEffect @@ -77,9 +80,16 @@ export const dynamicTagsProps = { export type DynamicTagsProps = ExtractPublicPropTypes +export interface DynamicTagsSlots { + input?: (info: DynamicTagsInputSlotOptions) => any + trigger?: (info: DynamicTagsTriggerSlotOptions) => any + default?: any +} + export default defineComponent({ name: 'DynamicTags', props: dynamicTagsProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { diff --git a/src/dynamic-tags/src/interface.ts b/src/dynamic-tags/src/interface.ts index 014a688434c..250ce128c91 100644 --- a/src/dynamic-tags/src/interface.ts +++ b/src/dynamic-tags/src/interface.ts @@ -17,3 +17,13 @@ export interface DynamicTagsOption { label: string value: string } + +export interface DynamicTagsInputSlotOptions { + submit: (value: any) => void + deactivate: () => void +} + +export interface DynamicTagsTriggerSlotOptions { + activate: () => void + disabled: boolean +} From fa678e35f1786f208f42a3ea4b8ca91d575d43be Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:05:01 +0800 Subject: [PATCH 23/54] feat(ellipsis): add slots type (#6599) --- src/ellipsis/index.ts | 2 +- src/ellipsis/src/Ellipsis.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ellipsis/index.ts b/src/ellipsis/index.ts index f7bd592b968..f61d598af5c 100644 --- a/src/ellipsis/index.ts +++ b/src/ellipsis/index.ts @@ -1,3 +1,3 @@ export { ellipsisProps, default as NEllipsis } from './src/Ellipsis' -export type { EllipsisProps } from './src/Ellipsis' +export type { EllipsisProps, EllipsisSlots } from './src/Ellipsis' export { NPerformantEllipsis } from './src/PerformantEllipsis' diff --git a/src/ellipsis/src/Ellipsis.tsx b/src/ellipsis/src/Ellipsis.tsx index 0ac6ef5b92a..66b0d2a1208 100644 --- a/src/ellipsis/src/Ellipsis.tsx +++ b/src/ellipsis/src/Ellipsis.tsx @@ -10,7 +10,8 @@ import { mergeProps, onDeactivated, type PropType, - ref + ref, + type SlotsType } from 'vue' import { useTheme } from '../../_mixins' import { useMergedClsPrefix } from '../../_mixins/use-config' @@ -38,10 +39,16 @@ export const ellipsisProps = { export type EllipsisProps = ExtractPublicPropTypes +export interface EllipsisSlots { + default?: any + tooltip?: any +} + export default defineComponent({ name: 'Ellipsis', inheritAttrs: false, props: ellipsisProps, + slots: Object as SlotsType, setup(props, { slots, attrs }) { const mergedClsPrefixRef = useMergedClsPrefix() const mergedTheme = useTheme( From acdc030e56fbb3e33aeede4e58094b3ec734971c Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:06:31 +0800 Subject: [PATCH 24/54] feat(empty): add slots type (#6599) --- src/empty/index.ts | 2 +- src/empty/src/Empty.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/empty/index.ts b/src/empty/index.ts index 57951868b68..29125269122 100644 --- a/src/empty/index.ts +++ b/src/empty/index.ts @@ -1,2 +1,2 @@ export { emptyProps, default as NEmpty } from './src/Empty' -export type { EmptyProps } from './src/Empty' +export type { EmptyProps, EmptySlots } from './src/Empty' diff --git a/src/empty/src/Empty.tsx b/src/empty/src/Empty.tsx index ca65c2c74fd..e7e301c24c0 100644 --- a/src/empty/src/Empty.tsx +++ b/src/empty/src/Empty.tsx @@ -6,6 +6,7 @@ import { defineComponent, h, type PropType, + type SlotsType, type VNodeChild } from 'vue' import { NBaseIcon } from '../../_internal/icon' @@ -35,9 +36,16 @@ export const emptyProps = { export type EmptyProps = ExtractPublicPropTypes +export interface EmptySlots { + default?: any + extra?: any + icon?: any +} + export default defineComponent({ name: 'Empty', props: emptyProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled, mergedComponentPropsRef } = useConfig(props) From d12a62ff4c7032d07edfd17733f9a24aa5d39d39 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:08:08 +0800 Subject: [PATCH 25/54] feat(float-button): add slots type (#6599) --- src/float-button/index.ts | 2 +- src/float-button/src/FloatButton.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/float-button/index.ts b/src/float-button/index.ts index d8a36822370..c3f32668493 100644 --- a/src/float-button/index.ts +++ b/src/float-button/index.ts @@ -1,2 +1,2 @@ export { floatButtonProps, default as NFloatButton } from './src/FloatButton' -export type { FloatButtonProps } from './src/FloatButton' +export type { FloatButtonProps, FloatButtonSlots } from './src/FloatButton' diff --git a/src/float-button/src/FloatButton.tsx b/src/float-button/src/FloatButton.tsx index a144a0556a7..4d8f93275e3 100644 --- a/src/float-button/src/FloatButton.tsx +++ b/src/float-button/src/FloatButton.tsx @@ -10,6 +10,7 @@ import { onMounted, type PropType, ref, + type SlotsType, toRef } from 'vue' import { NBaseIcon } from '../../_internal' @@ -65,9 +66,16 @@ export const floatButtonProps = { export type FloatButtonProps = ExtractPublicPropTypes +export interface FloatButtonSlots { + default?: any + description?: any + menu?: any +} + export default defineComponent({ name: 'FloatButton', props: floatButtonProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) From c30d73dd000b4c4044e16a0af8d47eda8a62dc65 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:12:34 +0800 Subject: [PATCH 26/54] feat(image): add slots type (#6599) --- src/image/index.ts | 2 +- src/image/src/Image.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/image/index.ts b/src/image/index.ts index c1b5dc8d4a8..fbc75de545c 100644 --- a/src/image/index.ts +++ b/src/image/index.ts @@ -1,5 +1,5 @@ export { imageProps, default as NImage } from './src/Image' -export type { ImageProps } from './src/Image' +export type { ImageProps, ImageSlots } from './src/Image' export { imageGroupProps, default as NImageGroup } from './src/ImageGroup' export type { ImageGroupProps } from './src/ImageGroup' export type * from './src/public-types' diff --git a/src/image/src/Image.tsx b/src/image/src/Image.tsx index c104e96af12..2022afb5697 100644 --- a/src/image/src/Image.tsx +++ b/src/image/src/Image.tsx @@ -10,6 +10,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, watchEffect } from 'vue' @@ -51,9 +52,16 @@ export const imageProps = { export type ImageProps = ExtractPublicPropTypes +export interface ImageSlots { + placeholder?: any + error?: any + [key: string]: any +} + export default defineComponent({ name: 'Image', props: imageProps, + slots: Object as SlotsType, inheritAttrs: false, setup(props) { const imageRef = ref(null) From 0c1b522c841b8b29236d79b8786242e3783845b0 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:15:11 +0800 Subject: [PATCH 27/54] feat(input): add slots type (#6599) --- src/input/index.ts | 2 +- src/input/src/Input.tsx | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/input/index.ts b/src/input/index.ts index 1de75680d98..b1a46b7a75b 100644 --- a/src/input/index.ts +++ b/src/input/index.ts @@ -1,5 +1,5 @@ export { inputProps, default as NInput } from './src/Input' -export type { InputProps } from './src/Input' +export type { InputProps, InputSlots } from './src/Input' export { inputGroupProps, default as NInputGroup } from './src/InputGroup' export type { InputGroupProps } from './src/InputGroup' export { diff --git a/src/input/src/Input.tsx b/src/input/src/Input.tsx index 2b308294223..c65805a63ad 100644 --- a/src/input/src/Input.tsx +++ b/src/input/src/Input.tsx @@ -23,6 +23,7 @@ import { type PropType, provide, ref, + type SlotsType, type TextareaHTMLAttributes, toRef, type VNode, @@ -170,9 +171,20 @@ export const inputProps = { export type InputProps = ExtractPublicPropTypes +export interface InputSlots { + 'clear-icon'?: any + count?: (props: { value: string }) => any + 'password-invisible-icon'?: any + 'password-visible-icon'?: any + prefix?: any + separator?: any + suffix?: any +} + export default defineComponent({ name: 'Input', props: inputProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 83d9bc5359d6158289741be3f38446d5f623c263 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:16:52 +0800 Subject: [PATCH 28/54] feat(input-number): add slots type (#6599) --- src/input-number/index.ts | 2 +- src/input-number/src/InputNumber.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/input-number/index.ts b/src/input-number/index.ts index 1a62030fef7..8c0a2e2d82c 100644 --- a/src/input-number/index.ts +++ b/src/input-number/index.ts @@ -1,3 +1,3 @@ export { inputNumberProps, default as NInputNumber } from './src/InputNumber' -export type { InputNumberProps } from './src/InputNumber' +export type { InputNumberProps, InputNumberSlots } from './src/InputNumber' export type { InputNumberInst } from './src/interface' diff --git a/src/input-number/src/InputNumber.tsx b/src/input-number/src/InputNumber.tsx index f15ba53fe11..21d858aa7d2 100644 --- a/src/input-number/src/InputNumber.tsx +++ b/src/input-number/src/InputNumber.tsx @@ -14,6 +14,7 @@ import { nextTick, type PropType, ref, + type SlotsType, toRef, type VNode, watch, @@ -110,9 +111,17 @@ export const inputNumberProps = { export type InputNumberProps = ExtractPublicPropTypes +export interface InputNumberSlots { + 'add-icon'?: any + 'minus-icon'?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'InputNumber', props: inputNumberProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 8b0c79d6f61a02caa7cbe2eb08b15fea05049c03 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:19:52 +0800 Subject: [PATCH 29/54] feat(list): add slots type (#6599) --- src/list/index.ts | 3 ++- src/list/src/List.tsx | 9 ++++++++- src/list/src/ListItem.tsx | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/list/index.ts b/src/list/index.ts index f6bb86f9957..08219a55428 100644 --- a/src/list/index.ts +++ b/src/list/index.ts @@ -1,3 +1,4 @@ export { listProps, default as NList } from './src/List' -export type { ListProps } from './src/List' +export type { ListProps, ListSlots } from './src/List' export { default as NListItem } from './src/ListItem' +export type { ListItemSlots } from './src/ListItem' diff --git a/src/list/src/List.tsx b/src/list/src/List.tsx index c3b4624c7dc..fd27ab7a660 100644 --- a/src/list/src/List.tsx +++ b/src/list/src/List.tsx @@ -1,4 +1,4 @@ -import type { CSSProperties, PropType, Ref } from 'vue' +import type { CSSProperties, PropType, Ref, SlotsType } from 'vue' import type { ThemeProps } from '../../_mixins' import type { ListTheme } from '../styles' import { computed, defineComponent, h, provide, toRef } from 'vue' @@ -24,6 +24,12 @@ export const listProps = { export type ListProps = ExtractPublicPropTypes +export interface ListSlots { + default?: any + footer?: any + header?: any +} + interface ListInjection { showDividerRef: Ref mergedClsPrefixRef: Ref @@ -34,6 +40,7 @@ export const listInjectionKey = createInjectionKey('n-list') export default defineComponent({ name: 'List', props: listProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props) diff --git a/src/list/src/ListItem.tsx b/src/list/src/ListItem.tsx index 7706a7273c6..c9802262d22 100644 --- a/src/list/src/ListItem.tsx +++ b/src/list/src/ListItem.tsx @@ -1,9 +1,17 @@ +import type { SlotsType } from 'vue' import { defineComponent, h, inject } from 'vue' import { throwError } from '../../_utils' import { listInjectionKey } from './List' +export interface ListItemSlots { + default?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'ListItem', + slots: Object as SlotsType, setup() { const listInjection = inject(listInjectionKey, null) if (!listInjection) { From bad51fd44f0a52396f5b19e5eb6cf04743918682 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:21:52 +0800 Subject: [PATCH 30/54] feat(mention): add slots type (#6599) --- src/mention/index.ts | 2 +- src/mention/src/Mention.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mention/index.ts b/src/mention/index.ts index be5037eddcf..5d2eac0014b 100644 --- a/src/mention/index.ts +++ b/src/mention/index.ts @@ -1,3 +1,3 @@ export type { MentionInst, MentionOption } from './src/interface' export { mentionProps, default as NMention } from './src/Mention' -export type { MentionProps } from './src/Mention' +export type { MentionProps, MentionSlots } from './src/Mention' diff --git a/src/mention/src/Mention.tsx b/src/mention/src/Mention.tsx index a888ea6dd9e..5dd8a8aa345 100644 --- a/src/mention/src/Mention.tsx +++ b/src/mention/src/Mention.tsx @@ -22,6 +22,7 @@ import { nextTick, type PropType, ref, + type SlotsType, toRef, Transition } from 'vue' @@ -131,9 +132,15 @@ export const mentionProps = { export type MentionProps = ExtractPublicPropTypes +export interface MentionSlots { + default?: any + empty?: any +} + export default defineComponent({ name: 'Mention', props: mentionProps, + slots: Object as SlotsType, setup(props) { const { namespaceRef, From 3304fee3808ff52c18c4166528ce5696d5918d3c Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:24:37 +0800 Subject: [PATCH 31/54] feat(modal): add slots type (#6599) --- src/modal/index.ts | 2 +- src/modal/src/Modal.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modal/index.ts b/src/modal/index.ts index 8bb99f7a288..48c812fbb31 100644 --- a/src/modal/index.ts +++ b/src/modal/index.ts @@ -1,7 +1,7 @@ export { useModal, useModalReactiveList } from './src/composables' export { modalProps, default as NModal } from './src/Modal' -export type { ModalProps } from './src/Modal' +export type { ModalProps, ModalSlots } from './src/Modal' export { modalProviderProps, NModalProvider } from './src/ModalProvider' export type { ModalApiInjection as ModalApi, diff --git a/src/modal/src/Modal.tsx b/src/modal/src/Modal.tsx index ed286d0b8ed..8dc9b35100b 100644 --- a/src/modal/src/Modal.tsx +++ b/src/modal/src/Modal.tsx @@ -1,5 +1,7 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' +import type { CardSlots } from '../../card' +import type { DialogSlots } from '../../dialog' import type { ModalTheme } from '../styles' import { getPreciseEventTarget } from 'seemly' import { zindexable } from 'vdirs' @@ -13,6 +15,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, Transition, withDirectives @@ -100,10 +103,15 @@ export const modalProps = { export type ModalProps = ExtractPublicPropTypes +export interface ModalSlots extends CardSlots, DialogSlots { + default?: any +} + export default defineComponent({ name: 'Modal', inheritAttrs: false, props: modalProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { if (props.onHide) { From c4bf7d11da63c71ee719d99151eae6fdddf438b9 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:26:40 +0800 Subject: [PATCH 32/54] feat(page-header): add slots type (#6599) --- src/page-header/index.ts | 2 +- src/page-header/src/PageHeader.tsx | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/page-header/index.ts b/src/page-header/index.ts index 8d7886675d3..ff40f6d5438 100644 --- a/src/page-header/index.ts +++ b/src/page-header/index.ts @@ -1,2 +1,2 @@ export { default as NPageHeader, pageHeaderProps } from './src/PageHeader' -export type { PageHeaderProps } from './src/PageHeader' +export type { PageHeaderProps, PageHeaderSlots } from './src/PageHeader' diff --git a/src/page-header/src/PageHeader.tsx b/src/page-header/src/PageHeader.tsx index feb82160117..80dc9ee148a 100644 --- a/src/page-header/src/PageHeader.tsx +++ b/src/page-header/src/PageHeader.tsx @@ -1,7 +1,13 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes } from '../../_utils' import type { PageHeaderTheme } from '../styles/light' -import { computed, defineComponent, h, type PropType } from 'vue' +import { + computed, + defineComponent, + h, + type PropType, + type SlotsType +} from 'vue' import { NBaseIcon } from '../../_internal' import { ArrowBackIcon } from '../../_internal/icons' import { useConfig, useTheme, useThemeClass } from '../../_mixins' @@ -19,9 +25,21 @@ export const pageHeaderProps = { export type PageHeaderProps = ExtractPublicPropTypes +export interface PageHeaderSlots { + avatar?: any + header?: any + default?: any + extra?: any + footer?: any + subtitle?: any + title?: any + back?: any +} + export default defineComponent({ name: 'PageHeader', props: pageHeaderProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, mergedRtlRef, inlineThemeDisabled } = useConfig(props) From 56571407ae7f5fdedb34ca207930056b8709dcf4 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:28:46 +0800 Subject: [PATCH 33/54] feat(pagination): add slots type (#6599) --- src/pagination/index.ts | 2 +- src/pagination/src/Pagination.tsx | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pagination/index.ts b/src/pagination/index.ts index c419d1a883d..766c7c9ff9e 100644 --- a/src/pagination/index.ts +++ b/src/pagination/index.ts @@ -4,4 +4,4 @@ export type { PaginationSizeOption } from './src/interface' export { default as NPagination, paginationProps } from './src/Pagination' -export type { PaginationProps } from './src/Pagination' +export type { PaginationProps, PaginationSlots } from './src/Pagination' diff --git a/src/pagination/src/Pagination.tsx b/src/pagination/src/Pagination.tsx index 929aabd2941..567002ebba4 100644 --- a/src/pagination/src/Pagination.tsx +++ b/src/pagination/src/Pagination.tsx @@ -5,6 +5,7 @@ import type { SelectProps } from '../../select' import type { Size as SelectSize } from '../../select/src/interface' import type { PaginationTheme } from '../styles' import type { + PaginationInfo, PaginationRenderLabel, PaginationSizeOption, RenderGoto, @@ -25,6 +26,7 @@ import { nextTick, type PropType, ref, + type SlotsType, toRef, type VNodeChild, watchEffect @@ -123,9 +125,20 @@ export const paginationProps = { export type PaginationProps = ExtractPublicPropTypes +export interface PaginationSlots { + default?: any + goto?: any + label?: any + next?: (info: PaginationInfo) => any + prev?: (info: PaginationInfo) => any + prefix?: (info: PaginationInfo) => any + suffix?: (info: PaginationInfo) => any +} + export default defineComponent({ name: 'Pagination', props: paginationProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From d06255f12e2e6f167ff5693197fd6f993d48bd0f Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:30:40 +0800 Subject: [PATCH 34/54] feat(popconfirm): add slots type (#6599) --- src/popconfirm/index.ts | 2 +- src/popconfirm/src/Popconfirm.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/popconfirm/index.ts b/src/popconfirm/index.ts index 223f6106308..f71f2551dbb 100644 --- a/src/popconfirm/index.ts +++ b/src/popconfirm/index.ts @@ -1,3 +1,3 @@ export type { PopconfirmInst } from './src/interface' export { default as NPopconfirm, popconfirmProps } from './src/Popconfirm' -export type { PopconfirmProps } from './src/Popconfirm' +export type { PopconfirmProps, PopconfirmSlots } from './src/Popconfirm' diff --git a/src/popconfirm/src/Popconfirm.ts b/src/popconfirm/src/Popconfirm.ts index be077d1940f..cc91c434002 100644 --- a/src/popconfirm/src/Popconfirm.ts +++ b/src/popconfirm/src/Popconfirm.ts @@ -11,7 +11,8 @@ import { h, type PropType, provide, - ref + ref, + type SlotsType } from 'vue' import { useConfig, useTheme } from '../../_mixins' import { call, keep, omit } from '../../_utils' @@ -49,9 +50,17 @@ export type PopconfirmProps = ExtractPublicPropTypes export type PopconfirmSetupProps = ExtractPropTypes +export interface PopconfirmSlots { + action?: any + default?: any + icon?: any + [key: string]: any +} + export default defineComponent({ name: 'Popconfirm', props: popconfirmProps, + slots: Object as SlotsType, __popover__: true, setup(props) { const { mergedClsPrefixRef } = useConfig() From 0db42a8aeb7348e9537458c59ed261fa972d0d6d Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:33:05 +0800 Subject: [PATCH 35/54] feat(popover): add slots type (#6599) --- src/popover/index.ts | 2 +- src/popover/src/Popover.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/popover/index.ts b/src/popover/index.ts index 97143a6dc2c..89d9a5d70c3 100644 --- a/src/popover/index.ts +++ b/src/popover/index.ts @@ -1,4 +1,4 @@ export type { PopoverInst, PopoverTrigger } from './src/interface' export { default as NPopover, popoverProps } from './src/Popover' -export type { PopoverProps } from './src/Popover' +export type { PopoverProps, PopoverSlots } from './src/Popover' export type { FollowerPlacement as PopoverPlacement } from 'vueuc' diff --git a/src/popover/src/Popover.tsx b/src/popover/src/Popover.tsx index 62df826a32b..3a08dc5a71b 100644 --- a/src/popover/src/Popover.tsx +++ b/src/popover/src/Popover.tsx @@ -23,6 +23,7 @@ import { provide, type Ref, ref, + type SlotsType, Text, toRef, type VNode, @@ -222,10 +223,19 @@ export const popoverProps = { export type PopoverProps = ExtractPublicPropTypes export type PopoverInternalProps = ExtractInternalPropTypes +export interface PopoverSlots { + trigger?: any + footer?: any + header?: any + default?: any + [key: string]: any +} + export default defineComponent({ name: 'Popover', inheritAttrs: false, props: popoverProps, + slots: Object as SlotsType, __popover__: true, setup(props) { if (__DEV__) { From a0223dcba6d68c7080401fec7d0edaf62165cd3b Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:56:14 +0800 Subject: [PATCH 36/54] feat(popselect): add slots type (#6599) --- src/popselect/index.ts | 2 +- src/popselect/src/Popselect.tsx | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/popselect/index.ts b/src/popselect/index.ts index 8138e463fbe..cf58783d1f1 100644 --- a/src/popselect/index.ts +++ b/src/popselect/index.ts @@ -1,3 +1,3 @@ export type { PopselectInst } from './src/interface' export { default as NPopselect, popselectProps } from './src/Popselect' -export type { PopselectProps } from './src/Popselect' +export type { PopselectProps, PopselectSlots } from './src/Popselect' diff --git a/src/popselect/src/Popselect.tsx b/src/popselect/src/Popselect.tsx index 208ff3ffb90..1f589d7f050 100644 --- a/src/popselect/src/Popselect.tsx +++ b/src/popselect/src/Popselect.tsx @@ -9,7 +9,8 @@ import { h, type PropType, provide, - ref + ref, + type SlotsType } from 'vue' import { useConfig, useTheme } from '../../_mixins' import { createRefSetter, keep, mergeEventHandlers, omit } from '../../_utils' @@ -36,9 +37,17 @@ export const popselectProps = { export type PopselectSetupProps = ExtractPropTypes export type PopselectProps = ExtractPublicPropTypes +export interface PopselectSlots { + default?: any + header?: any + action?: any + empty?: any +} + export default defineComponent({ name: 'Popselect', props: popselectProps, + slots: Object as SlotsType, inheritAttrs: false, __popover__: true, setup(props) { From 6fd2272fe652877808c893582e26dfeb8e8d41b7 Mon Sep 17 00:00:00 2001 From: Naily Date: Sat, 7 Dec 2024 23:58:05 +0800 Subject: [PATCH 37/54] feat(result): add slots type (#6599) --- src/result/index.ts | 2 +- src/result/src/Result.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/result/index.ts b/src/result/index.ts index 4d1459f93e1..124983f5d5e 100644 --- a/src/result/index.ts +++ b/src/result/index.ts @@ -1,2 +1,2 @@ export { default as NResult, resultProps } from './src/Result' -export type { ResultProps } from './src/Result' +export type { ResultProps, ResultSlots } from './src/Result' diff --git a/src/result/src/Result.tsx b/src/result/src/Result.tsx index 7d4bbd507ff..df8679ddab9 100644 --- a/src/result/src/Result.tsx +++ b/src/result/src/Result.tsx @@ -6,7 +6,8 @@ import { type CSSProperties, defineComponent, h, - type PropType + type PropType, + type SlotsType } from 'vue' import { NBaseIcon } from '../../_internal' import { @@ -53,9 +54,16 @@ export const resultProps = { export type ResultProps = ExtractPublicPropTypes +export interface ResultSlots { + default?: any + footer?: any + icon?: any +} + export default defineComponent({ name: 'Result', props: resultProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) const themeRef = useTheme( From 1d6906149f08d581e61b5b2bb14923f249513f4d Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:00:05 +0800 Subject: [PATCH 38/54] feat(select): add slots type (#6599) --- src/select/index.ts | 2 +- src/select/src/Select.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/select/index.ts b/src/select/index.ts index 93ef34d0dad..b038526ddac 100644 --- a/src/select/index.ts +++ b/src/select/index.ts @@ -11,4 +11,4 @@ export type { SelectOption } from './src/interface' export { default as NSelect, selectProps } from './src/Select' -export type { SelectProps } from './src/Select' +export type { SelectProps, SelectSlots } from './src/Select' diff --git a/src/select/src/Select.tsx b/src/select/src/Select.tsx index 4e2b80f5542..5ee1c6799d4 100644 --- a/src/select/src/Select.tsx +++ b/src/select/src/Select.tsx @@ -36,6 +36,7 @@ import { type InputHTMLAttributes, type PropType, ref, + type SlotsType, toRef, Transition, vShow, @@ -217,9 +218,18 @@ export const selectProps = { export type SelectProps = ExtractPublicPropTypes +export interface SelectSlots { + default?: any + header?: any + action?: any + empty?: any + arrow?: any +} + export default defineComponent({ name: 'Select', props: selectProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 040600bbd40dde963d3b2f5f873ebdd64e4829e6 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:01:15 +0800 Subject: [PATCH 39/54] feat(slider): add slots type (#6599) --- src/slider/index.ts | 2 +- src/slider/src/Slider.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/slider/index.ts b/src/slider/index.ts index 9f2368c221a..6bb59e9b2f5 100644 --- a/src/slider/index.ts +++ b/src/slider/index.ts @@ -1,2 +1,2 @@ export { default as NSlider, sliderProps } from './src/Slider' -export type { SliderProps } from './src/Slider' +export type { SliderProps, SliderSlots } from './src/Slider' diff --git a/src/slider/src/Slider.tsx b/src/slider/src/Slider.tsx index 47963d3b391..70a3b3c2acb 100644 --- a/src/slider/src/Slider.tsx +++ b/src/slider/src/Slider.tsx @@ -11,6 +11,7 @@ import { onBeforeUnmount, type PropType, ref, + type SlotsType, toRef, Transition, type VNodeChild, @@ -104,9 +105,15 @@ export const sliderProps = { export type SliderProps = ExtractPublicPropTypes +export interface SliderSlots { + thumb?: any + default?: any +} + export default defineComponent({ name: 'Slider', props: sliderProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, namespaceRef, inlineThemeDisabled } = useConfig(props) From 6e06edf5af844a63bbe58634005a5ac1e9445110 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:02:32 +0800 Subject: [PATCH 40/54] feat(spin): add slots type (#6599) --- src/spin/index.ts | 2 +- src/spin/src/Spin.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spin/index.ts b/src/spin/index.ts index 3585b26f258..d2576a5066a 100644 --- a/src/spin/index.ts +++ b/src/spin/index.ts @@ -1,2 +1,2 @@ export { default as NSpin, spinProps } from './src/Spin' -export type { SpinProps } from './src/Spin' +export type { SpinProps, SpinSlots } from './src/Spin' diff --git a/src/spin/src/Spin.tsx b/src/spin/src/Spin.tsx index 95fb9447459..48573225660 100644 --- a/src/spin/src/Spin.tsx +++ b/src/spin/src/Spin.tsx @@ -9,6 +9,7 @@ import { h, type PropType, ref, + type SlotsType, Transition, watchEffect } from 'vue' @@ -55,9 +56,16 @@ export const spinProps = { export type SpinProps = ExtractPublicPropTypes +export interface SpinSlots { + default?: any + description?: any + icon?: any +} + export default defineComponent({ name: 'Spin', props: spinProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 318ec6fbeb96d2d0b10aaae3cd83d9dce7163834 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:03:53 +0800 Subject: [PATCH 41/54] feat(split): add slots type (#6599) --- src/split/index.ts | 2 +- src/split/src/Split.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/split/index.ts b/src/split/index.ts index e455816fd3d..8f786dde67d 100644 --- a/src/split/index.ts +++ b/src/split/index.ts @@ -1,3 +1,3 @@ export { default as NSplit, splitProps } from './src/Split' -export type { SplitProps } from './src/Split' +export type { SplitProps, SplitSlots } from './src/Split' export type { SplitOnUpdateSize } from './src/types' diff --git a/src/split/src/Split.tsx b/src/split/src/Split.tsx index 6901bb3bb16..c04849f8cca 100644 --- a/src/split/src/Split.tsx +++ b/src/split/src/Split.tsx @@ -9,6 +9,7 @@ import { h, type PropType, ref, + type SlotsType, toRef, watchEffect } from 'vue' @@ -60,9 +61,17 @@ export const splitProps = { export type SplitProps = ExtractPublicPropTypes +export interface SplitSlots { + default?: any + 1?: any + 2?: any + 'resize-trigger'?: any +} + export default defineComponent({ name: 'Split', props: splitProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props) const themeRef = useTheme( From f4220cf8019ae969df94ccde9ab410a19738718d Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:05:13 +0800 Subject: [PATCH 42/54] feat(statistic): add slots type (#6599) --- src/statistic/index.ts | 2 +- src/statistic/src/Statistic.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/statistic/index.ts b/src/statistic/index.ts index 9a603f2bed6..f3816c1fa02 100644 --- a/src/statistic/index.ts +++ b/src/statistic/index.ts @@ -1,2 +1,2 @@ export { default as NStatistic, statisticProps } from './src/Statistic' -export type { StatisticProps } from './src/Statistic' +export type { StatisticProps, StatisticSlots } from './src/Statistic' diff --git a/src/statistic/src/Statistic.tsx b/src/statistic/src/Statistic.tsx index c25c88e8149..ba9f23ac468 100644 --- a/src/statistic/src/Statistic.tsx +++ b/src/statistic/src/Statistic.tsx @@ -1,7 +1,7 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes } from '../../_utils' import type { StatisticTheme } from '../styles' -import { computed, defineComponent, h } from 'vue' +import { computed, defineComponent, h, type SlotsType } from 'vue' import { useConfig, useRtl, useTheme, useThemeClass } from '../../_mixins' import { resolveWrappedSlot } from '../../_utils' import { statisticLight } from '../styles' @@ -16,9 +16,17 @@ export const statisticProps = { export type StatisticProps = ExtractPublicPropTypes +export interface StatisticSlots { + default?: any + label?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'Statistic', props: statisticProps, + slots: Object as SlotsType, setup(props) { const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props) From be2d9d563babe56f642fc14995138f1d5e06f1ef Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:07:39 +0800 Subject: [PATCH 43/54] feat(step): add slots type (#6599) --- src/steps/index.ts | 4 ++-- src/steps/src/Step.tsx | 10 +++++++++- src/steps/src/Steps.tsx | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/steps/index.ts b/src/steps/index.ts index ce2cd6f9cd9..62c5eac810c 100644 --- a/src/steps/index.ts +++ b/src/steps/index.ts @@ -1,4 +1,4 @@ export { default as NStep, stepProps } from './src/Step' -export type { StepProps } from './src/Step' +export type { StepProps, StepSlots } from './src/Step' export { default as NSteps, stepsProps } from './src/Steps' -export type { StepsProps } from './src/Steps' +export type { StepsProps, StepsSlots } from './src/Steps' diff --git a/src/steps/src/Step.tsx b/src/steps/src/Step.tsx index 7cd9816172c..b854b649c7a 100644 --- a/src/steps/src/Step.tsx +++ b/src/steps/src/Step.tsx @@ -5,7 +5,8 @@ import { defineComponent, h, inject, - type PropType + type PropType, + type SlotsType } from 'vue' import { NBaseIcon, NIconSwitchTransition } from '../../_internal' import { @@ -36,9 +37,16 @@ export const stepProps = { export type StepProps = ExtractPublicPropTypes +export interface StepSlots { + default?: any + icon?: any + title?: any +} + export default defineComponent({ name: 'Step', props: stepProps, + slots: Object as SlotsType, setup(props) { const NSteps = inject(stepsInjectionKey, null) diff --git a/src/steps/src/Steps.tsx b/src/steps/src/Steps.tsx index 7d3bfddc43e..5a942d3eeff 100644 --- a/src/steps/src/Steps.tsx +++ b/src/steps/src/Steps.tsx @@ -9,6 +9,7 @@ import { provide, type Ref, type Slots, + type SlotsType, type VNode, type VNodeChild } from 'vue' @@ -60,11 +61,18 @@ export interface StepsInjection { export type StepsProps = ExtractPublicPropTypes +export interface StepsSlots { + default?: any + 'finish-icon'?: any + 'error-icon'?: any +} + export const stepsInjectionKey = createInjectionKey('n-steps') export default defineComponent({ name: 'Steps', props: stepsProps, + slots: Object as SlotsType, setup(props, { slots }) { const { mergedClsPrefixRef, mergedRtlRef } = useConfig(props) const rtlEnabledRef = useRtl('Steps', mergedRtlRef, mergedClsPrefixRef) From 7dd15f014d7e0c2ad1b9ad2ef533f1d7a107d572 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:09:29 +0800 Subject: [PATCH 44/54] feat(switch): add slots type (#6599) --- src/switch/index.ts | 2 +- src/switch/src/Switch.tsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/switch/index.ts b/src/switch/index.ts index 689a634ccb2..7399e4434c4 100644 --- a/src/switch/index.ts +++ b/src/switch/index.ts @@ -1,2 +1,2 @@ export { default as NSwitch, switchProps } from './src/Switch' -export type { SwitchProps } from './src/Switch' +export type { SwitchProps, SwitchSlots } from './src/Switch' diff --git a/src/switch/src/Switch.tsx b/src/switch/src/Switch.tsx index a29f6939b71..72abf4d29c2 100644 --- a/src/switch/src/Switch.tsx +++ b/src/switch/src/Switch.tsx @@ -11,6 +11,7 @@ import { h, type PropType, ref, + type SlotsType, toRef, watchEffect } from 'vue' @@ -74,11 +75,21 @@ export const switchProps = { export type SwitchProps = ExtractPublicPropTypes +export interface SwitchSlots { + default?: any + checked?: any + 'checked-icon'?: any + icon?: any + unchecked?: any + 'unchecked-icon'?: any +} + let supportCssMax: boolean | undefined export default defineComponent({ name: 'Switch', props: switchProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From a27a085e72f2e058a71c434aede8d3224bd4c18b Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:12:05 +0800 Subject: [PATCH 45/54] feat(tabs): add slots type (#6599) --- src/tabs/index.ts | 4 ++-- src/tabs/src/TabPane.tsx | 8 ++++++++ src/tabs/src/Tabs.tsx | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/tabs/index.ts b/src/tabs/index.ts index 10ede91e701..3beb7c17e93 100644 --- a/src/tabs/index.ts +++ b/src/tabs/index.ts @@ -2,6 +2,6 @@ export type { TabsInst } from './src/interface' export { default as NTab, tabProps } from './src/Tab' export type { TabProps } from './src/Tab' export { default as NTabPane, tabPaneProps } from './src/TabPane' -export type { TabPaneProps } from './src/TabPane' +export type { TabPaneProps, TabPaneSlots } from './src/TabPane' export { default as NTabs, tabsProps } from './src/Tabs' -export type { TabsProps } from './src/Tabs' +export type { TabsProps, TabsSlots } from './src/Tabs' diff --git a/src/tabs/src/TabPane.tsx b/src/tabs/src/TabPane.tsx index ecee6123110..9bdeec529b2 100644 --- a/src/tabs/src/TabPane.tsx +++ b/src/tabs/src/TabPane.tsx @@ -5,6 +5,7 @@ import { type HTMLAttributes, inject, type PropType, + type SlotsType, type VNode, type VNodeChild, watchEffect @@ -38,11 +39,18 @@ export const tabPaneProps = { export type TabPaneProps = ExtractPublicPropTypes +export interface TabPaneSlots { + default?: any + prefix?: any + suffix?: any +} + export default defineComponent({ __TAB_PANE__: true, name: 'TabPane', alias: ['TabPanel'], props: tabPaneProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { diff --git a/src/tabs/src/Tabs.tsx b/src/tabs/src/Tabs.tsx index 9555779e155..643f07de4c3 100644 --- a/src/tabs/src/Tabs.tsx +++ b/src/tabs/src/Tabs.tsx @@ -28,6 +28,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, TransitionGroup, type VNode, @@ -114,9 +115,16 @@ export const tabsProps = { export type TabsProps = ExtractPublicPropTypes +export interface TabsSlots { + default?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'Tabs', props: tabsProps, + slots: Object as SlotsType, setup(props, { slots }) { if (__DEV__) { watchEffect(() => { From 968ac466d9045dc05e3e16b6ed49c0bb756e7ea5 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:13:15 +0800 Subject: [PATCH 46/54] feat(tag): add slots type (#6599) --- src/tag/index.ts | 2 +- src/tag/src/Tag.tsx | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tag/index.ts b/src/tag/index.ts index 2df9f3b8aa6..f0a11344eea 100644 --- a/src/tag/index.ts +++ b/src/tag/index.ts @@ -1,2 +1,2 @@ export { default as NTag, tagProps } from './src/Tag' -export type { TagProps } from './src/Tag' +export type { TagProps, TagSlots } from './src/Tag' diff --git a/src/tag/src/Tag.tsx b/src/tag/src/Tag.tsx index 6425c7dbf5d..453445f4b9f 100644 --- a/src/tag/src/Tag.tsx +++ b/src/tag/src/Tag.tsx @@ -11,6 +11,7 @@ import { provide, type Ref, ref, + type SlotsType, toRef, watchEffect } from 'vue' @@ -73,9 +74,16 @@ export const tagInjectionKey = createInjectionKey('n-tag') export type TagProps = ExtractPublicPropTypes +export interface TagSlots { + default?: any + avatar?: any + icon?: any +} + export default defineComponent({ name: 'Tag', props: tagProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 30ffd0a22b62936d826655f0a454c85ffb9e7068 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:14:37 +0800 Subject: [PATCH 47/54] feat(thing): add slots type (#6599) --- src/thing/index.ts | 2 +- src/thing/src/Thing.tsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/thing/index.ts b/src/thing/index.ts index f99ef2d69a0..776f864b5d6 100644 --- a/src/thing/index.ts +++ b/src/thing/index.ts @@ -1,2 +1,2 @@ export { default as NThing, thingProps } from './src/Thing' -export type { ThingProps } from './src/Thing' +export type { ThingProps, ThingSlots } from './src/Thing' diff --git a/src/thing/src/Thing.tsx b/src/thing/src/Thing.tsx index a8e81508505..56b076ebee4 100644 --- a/src/thing/src/Thing.tsx +++ b/src/thing/src/Thing.tsx @@ -7,7 +7,8 @@ import { defineComponent, Fragment, h, - type PropType + type PropType, + type SlotsType } from 'vue' import { useConfig, useRtl, useTheme, useThemeClass } from '../../_mixins' import { thingLight } from '../styles' @@ -28,9 +29,20 @@ export const thingProps = { export type ThingProps = ExtractPublicPropTypes +export interface ThingSlots { + action?: any + avatar?: any + default?: any + description?: any + footer?: any + 'header-extra'?: any + header?: any +} + export default defineComponent({ name: 'Thing', props: thingProps, + slots: Object as SlotsType, setup(props, { slots }) { const { mergedClsPrefixRef, inlineThemeDisabled, mergedRtlRef } = useConfig(props) From 63c92b2f247b23129beb39b7d775be1c9ab88cff Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:16:18 +0800 Subject: [PATCH 48/54] feat(time-picker): add slots type (#6599) --- src/time-picker/src/TimePicker.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/time-picker/src/TimePicker.tsx b/src/time-picker/src/TimePicker.tsx index 35719596b32..f1f4bef0e12 100644 --- a/src/time-picker/src/TimePicker.tsx +++ b/src/time-picker/src/TimePicker.tsx @@ -178,6 +178,11 @@ export const timePickerProps = { export type TimePickerProps = ExtractPublicPropTypes +export interface TimePickerSlots { + default?: any + icon?: any +} + export default defineComponent({ name: 'TimePicker', props: timePickerProps, From b18dc5e40eb9040840accdd8eb243d5d3bb0ca74 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:16:54 +0800 Subject: [PATCH 49/54] feat(time-picker): export slots type (#6599) --- src/time-picker/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/time-picker/index.ts b/src/time-picker/index.ts index db2bb93b143..9d981102e7f 100644 --- a/src/time-picker/index.ts +++ b/src/time-picker/index.ts @@ -1,3 +1,3 @@ export type { TimePickerInst } from './src/interface' export { default as NTimePicker, timePickerProps } from './src/TimePicker' -export type { TimePickerProps } from './src/TimePicker' +export type { TimePickerProps, TimePickerSlots } from './src/TimePicker' From 105c873be0658ded20185280cc743db5e5151ec1 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:18:05 +0800 Subject: [PATCH 50/54] feat(timeline): export slots type (#6599) --- src/timeline/index.ts | 2 +- src/timeline/src/TimelineItem.tsx | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/timeline/index.ts b/src/timeline/index.ts index c3141a87eed..7b967138f76 100644 --- a/src/timeline/index.ts +++ b/src/timeline/index.ts @@ -1,4 +1,4 @@ export { default as NTimeline, timelineProps } from './src/Timeline' export type { TimelineProps } from './src/Timeline' export { default as NTimelineItem, timelineItemProps } from './src/TimelineItem' -export type { TimelineItemProps } from './src/TimelineItem' +export type { TimelineItemProps, TimelineItemSlots } from './src/TimelineItem' diff --git a/src/timeline/src/TimelineItem.tsx b/src/timeline/src/TimelineItem.tsx index 397887096ff..10d0e9aef72 100644 --- a/src/timeline/src/TimelineItem.tsx +++ b/src/timeline/src/TimelineItem.tsx @@ -5,7 +5,8 @@ import { defineComponent, h, inject, - type PropType + type PropType, + type SlotsType } from 'vue' import { useConfig, useThemeClass } from '../../_mixins' import { @@ -37,9 +38,17 @@ export const timelineItemProps = { export type TimelineItemProps = ExtractPublicPropTypes +export interface TimelineItemSlots { + default?: any + icon?: any + footer?: any + header?: any +} + export default defineComponent({ name: 'TimelineItem', props: timelineItemProps, + slots: Object as SlotsType, setup(props) { const NTimeline = inject(timelineInjectionKey) if (!NTimeline) { From 90624f1dbc57c7bde6fa02b1d937b51fdda8f476 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:19:17 +0800 Subject: [PATCH 51/54] feat(tooltip): export slots type (#6599) --- src/tooltip/index.ts | 2 +- src/tooltip/src/Tooltip.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tooltip/index.ts b/src/tooltip/index.ts index f85129fccf7..010be3d1cb2 100644 --- a/src/tooltip/index.ts +++ b/src/tooltip/index.ts @@ -1,2 +1,2 @@ export { default as NTooltip, tooltipProps } from './src/Tooltip' -export type { TooltipInst, TooltipProps } from './src/Tooltip' +export type { TooltipInst, TooltipProps, TooltipSlots } from './src/Tooltip' diff --git a/src/tooltip/src/Tooltip.ts b/src/tooltip/src/Tooltip.ts index 86eeaf78e2c..b5e0f437ad5 100644 --- a/src/tooltip/src/Tooltip.ts +++ b/src/tooltip/src/Tooltip.ts @@ -1,9 +1,9 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes } from '../../_utils' -import type { PopoverInst } from '../../popover' +import type { PopoverInst, PopoverSlots } from '../../popover' import type { TooltipTheme } from '../styles' // Tooltip: popover wearing waistcoat -import { computed, defineComponent, h, ref } from 'vue' +import { computed, defineComponent, h, ref, type SlotsType } from 'vue' import { useConfig, useTheme } from '../../_mixins' import { NPopover } from '../../popover' import { popoverBaseProps } from '../../popover/src/Popover' @@ -18,9 +18,12 @@ export const tooltipProps = { export type TooltipProps = ExtractPublicPropTypes +export interface TooltipSlots extends PopoverSlots {} + export default defineComponent({ name: 'Tooltip', props: tooltipProps, + slots: Object as SlotsType, __popover__: true, setup(props) { const { mergedClsPrefixRef } = useConfig(props) From 45366cba8bee371014ed0312766f699977261046 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:21:23 +0800 Subject: [PATCH 52/54] feat(tree): export slots type (#6599) --- src/tree/index.ts | 2 +- src/tree/src/Tree.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tree/index.ts b/src/tree/index.ts index 7e03fada31d..e6ac0b2f7f7 100644 --- a/src/tree/index.ts +++ b/src/tree/index.ts @@ -7,5 +7,5 @@ export type { TreeOverrideNodeClickBehaviorReturn } from './src/interface' export { default as NTree, treeProps } from './src/Tree' -export type { TreeProps } from './src/Tree' +export type { TreeProps, TreeSlots } from './src/Tree' export { treeGetClickTarget } from './src/utils' diff --git a/src/tree/src/Tree.tsx b/src/tree/src/Tree.tsx index 9ece979404e..bd7e160b9e7 100644 --- a/src/tree/src/Tree.tsx +++ b/src/tree/src/Tree.tsx @@ -46,6 +46,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, type VNode, type VNodeChild, @@ -348,9 +349,15 @@ export const treeProps = { export type TreeProps = ExtractPublicPropTypes +export interface TreeSlots { + default?: any + empty?: any +} + export default defineComponent({ name: 'Tree', props: treeProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From b9f0b9faac9f2328ea67e0f70dfbb00195b3e432 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:23:20 +0800 Subject: [PATCH 53/54] feat(tree-select): export slots type (#6599) --- src/tree-select/index.ts | 2 +- src/tree-select/src/TreeSelect.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tree-select/index.ts b/src/tree-select/index.ts index 67db9c2247e..0c451b087f5 100644 --- a/src/tree-select/index.ts +++ b/src/tree-select/index.ts @@ -12,4 +12,4 @@ export type { TreeSelectRenderTag } from './src/interface' export { default as NTreeSelect, treeSelectProps } from './src/TreeSelect' -export type { TreeSelectProps } from './src/TreeSelect' +export type { TreeSelectProps, TreeSelectSlots } from './src/TreeSelect' diff --git a/src/tree-select/src/TreeSelect.tsx b/src/tree-select/src/TreeSelect.tsx index 533be8c89e5..17c2bb129ea 100644 --- a/src/tree-select/src/TreeSelect.tsx +++ b/src/tree-select/src/TreeSelect.tsx @@ -36,6 +36,7 @@ import { type PropType, provide, ref, + type SlotsType, toRef, Transition, type VNodeChild, @@ -181,9 +182,17 @@ export const treeSelectProps = { export type TreeSelectProps = ExtractPublicPropTypes +export interface TreeSelectSlots { + header?: any + action?: any + arrow?: any + empty?: any +} + export default defineComponent({ name: 'TreeSelect', props: treeSelectProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { From 41ad8666331fa116c956cfdc3fef0c88a9d07781 Mon Sep 17 00:00:00 2001 From: Naily Date: Sun, 8 Dec 2024 00:25:56 +0800 Subject: [PATCH 54/54] 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 +}