@@ -10,7 +10,7 @@ import type {
10
10
OnTabScroll ,
11
11
Tab ,
12
12
} from './interface' ;
13
- import type { CSSProperties , PropType , ExtractPropTypes } from 'vue' ;
13
+ import type { CSSProperties , ExtractPropTypes } from 'vue' ;
14
14
import { defineComponent , computed , onMounted , watchEffect , camelize } from 'vue' ;
15
15
import { flattenChildren , initDefaultProps , isValidElement } from '../../_util/props-util' ;
16
16
import useConfigInject from '../../config-provider/hooks/useConfigInject' ;
@@ -24,6 +24,14 @@ import devWarning from '../../vc-util/devWarning';
24
24
import type { SizeType } from '../../config-provider' ;
25
25
import { useProvideTabs } from './TabContext' ;
26
26
import type { Key } from '../../_util/type' ;
27
+ import {
28
+ arrayType ,
29
+ stringType ,
30
+ someType ,
31
+ functionType ,
32
+ objectType ,
33
+ booleanType ,
34
+ } from '../../_util/type' ;
27
35
import pick from 'lodash-es/pick' ;
28
36
import PropTypes from '../../_util/vue-types' ;
29
37
import type { MouseEventHandler } from '../../_util/EventInterface' ;
@@ -39,36 +47,33 @@ export const tabsProps = () => {
39
47
return {
40
48
prefixCls : { type : String } ,
41
49
id : { type : String } ,
42
-
50
+ popupClassName : String ,
51
+ getPopupContainer : functionType <
52
+ ( ( triggerNode ?: HTMLElement | undefined ) => HTMLElement ) | undefined
53
+ > ( ) ,
43
54
activeKey : { type : [ String , Number ] } ,
44
55
defaultActiveKey : { type : [ String , Number ] } ,
45
- direction : { type : String as PropType < 'ltr' | 'rtl' > } ,
46
- animated : { type : [ Boolean , Object ] as PropType < boolean | AnimatedConfig > } ,
47
- renderTabBar : { type : Function as PropType < RenderTabBar > } ,
56
+ direction : stringType < 'ltr' | 'rtl' > ( ) ,
57
+ animated : someType < boolean | AnimatedConfig > ( [ Boolean , Object ] ) ,
58
+ renderTabBar : functionType < RenderTabBar > ( ) ,
48
59
tabBarGutter : { type : Number } ,
49
- tabBarStyle : { type : Object as PropType < CSSProperties > } ,
50
- tabPosition : { type : String as PropType < TabPosition > } ,
51
- destroyInactiveTabPane : { type : Boolean } ,
60
+ tabBarStyle : objectType < CSSProperties > ( ) ,
61
+ tabPosition : stringType < TabPosition > ( ) ,
62
+ destroyInactiveTabPane : booleanType ( ) ,
52
63
53
64
hideAdd : Boolean ,
54
- type : { type : String as PropType < TabsType > } ,
55
- size : { type : String as PropType < SizeType > } ,
65
+ type : stringType < TabsType > ( ) ,
66
+ size : stringType < SizeType > ( ) ,
56
67
centered : Boolean ,
57
- onEdit : {
58
- type : Function as PropType <
59
- ( e : MouseEvent | KeyboardEvent | Key , action : 'add' | 'remove' ) => void
60
- > ,
61
- } ,
62
- onChange : { type : Function as PropType < ( activeKey : Key ) => void > } ,
63
- onTabClick : {
64
- type : Function as PropType < ( activeKey : Key , e : KeyboardEvent | MouseEvent ) => void > ,
65
- } ,
66
- onTabScroll : { type : Function as PropType < OnTabScroll > } ,
67
- 'onUpdate:activeKey' : { type : Function as PropType < ( activeKey : Key ) => void > } ,
68
+ onEdit : functionType < ( e : MouseEvent | KeyboardEvent | Key , action : 'add' | 'remove' ) => void > ( ) ,
69
+ onChange : functionType < ( activeKey : Key ) => void > ( ) ,
70
+ onTabClick : functionType < ( activeKey : Key , e : KeyboardEvent | MouseEvent ) => void > ( ) ,
71
+ onTabScroll : functionType < OnTabScroll > ( ) ,
72
+ 'onUpdate:activeKey' : functionType < ( activeKey : Key ) => void > ( ) ,
68
73
// Accessibility
69
- locale : { type : Object as PropType < TabsLocale > , default : undefined as TabsLocale } ,
70
- onPrevClick : Function as PropType < MouseEventHandler > ,
71
- onNextClick : Function as PropType < MouseEventHandler > ,
74
+ locale : objectType < TabsLocale > ( ) ,
75
+ onPrevClick : functionType < MouseEventHandler > ( ) ,
76
+ onNextClick : functionType < MouseEventHandler > ( ) ,
72
77
tabBarExtraContent : PropTypes . any ,
73
78
} ;
74
79
} ;
@@ -126,7 +131,7 @@ const InternalTabs = defineComponent({
126
131
tabPane : false ,
127
132
} ,
128
133
} ) ,
129
- tabs : { type : Array as PropType < Tab [ ] > } ,
134
+ tabs : arrayType < Tab [ ] > ( ) ,
130
135
} ,
131
136
slots : [
132
137
'tabBarExtraContent' ,
@@ -154,7 +159,10 @@ const InternalTabs = defineComponent({
154
159
'Tabs' ,
155
160
'`tabBarExtraContent` slot is deprecated. Please use `rightExtra` slot instead.' ,
156
161
) ;
157
- const { prefixCls, direction, size, rootPrefixCls } = useConfigInject ( 'tabs' , props ) ;
162
+ const { prefixCls, direction, size, rootPrefixCls, getPopupContainer } = useConfigInject (
163
+ 'tabs' ,
164
+ props ,
165
+ ) ;
158
166
const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
159
167
const rtl = computed ( ( ) => direction . value === 'rtl' ) ;
160
168
const mergedAnimated = computed < AnimatedConfig > ( ( ) => {
@@ -284,6 +292,8 @@ const InternalTabs = defineComponent({
284
292
onTabClick : onInternalTabClick ,
285
293
onTabScroll,
286
294
style : tabBarStyle ,
295
+ getPopupContainer : getPopupContainer . value ,
296
+ popupClassName : classNames ( props . popupClassName , hashId . value ) ,
287
297
} ;
288
298
289
299
if ( renderTabBar ) {
0 commit comments