@@ -20,11 +20,11 @@ export type TabProps = {
20
20
disabled ?: boolean ;
21
21
selected ?: boolean ;
22
22
selectedClassName ?: string ;
23
+ tabId ?: string ;
23
24
24
25
/** @deprecated Internal use only */
25
26
_extraClass ?: QwikIntrinsicElements [ 'div' ] [ 'class' ] ;
26
27
/** @deprecated Internal use only */
27
- _tabId ?: string ;
28
28
} & QwikIntrinsicElements [ 'button' ] ;
29
29
30
30
export const preventedKeys = [
@@ -39,28 +39,28 @@ export const preventedKeys = [
39
39
] ;
40
40
41
41
export const Tab = component$ (
42
- ( { selectedClassName, _extraClass, _tabId , ...props } : TabProps ) => {
42
+ ( { selectedClassName, _extraClass, tabId , ...props } : TabProps ) => {
43
43
const contextService = useContext ( tabsContextId ) ;
44
44
45
45
const elementRefSig = useSignal < HTMLElement | undefined > ( ) ;
46
46
47
- const fullTabElementId = contextService . tabsPrefix + TAB_ID_PREFIX + _tabId ! ;
48
- const fullPanelElementId = contextService . tabsPrefix + TAB_PANEL_ID_PREFIX + _tabId ! ;
47
+ const fullTabElementId = contextService . tabsPrefix + TAB_ID_PREFIX + tabId ! ;
48
+ const fullPanelElementId = contextService . tabsPrefix + TAB_PANEL_ID_PREFIX + tabId ! ;
49
49
50
50
const selectedClassNameSig = useComputed$ ( ( ) => {
51
51
return selectedClassName || contextService . selectedClassName ;
52
52
} ) ;
53
53
54
54
const isSelectedSig = useComputed$ ( ( ) => {
55
- return contextService . selectedTabIdSig . value === _tabId ;
55
+ return contextService . selectedTabIdSig . value === tabId ;
56
56
} ) ;
57
57
58
58
useVisibleTask$ ( function preventDefaultOnKeysVisibleTask ( { cleanup } ) {
59
59
function handler ( event : KeyboardEvent ) {
60
60
if ( preventedKeys . includes ( event . key as KeyCode ) ) {
61
61
event . preventDefault ( ) ;
62
62
}
63
- contextService . onTabKeyDown$ ( event . key as KeyCode , _tabId ! ) ;
63
+ contextService . onTabKeyDown$ ( event . key as KeyCode , tabId ! ) ;
64
64
}
65
65
// TODO put the listener on TabList
66
66
elementRefSig . value ?. addEventListener ( 'keydown' , handler ) ;
@@ -70,7 +70,7 @@ export const Tab = component$(
70
70
} ) ;
71
71
72
72
const selectIfAutomatic$ = $ ( ( ) => {
73
- contextService . selectIfAutomatic$ ( _tabId ! ) ;
73
+ contextService . selectIfAutomatic$ ( tabId ! ) ;
74
74
} ) ;
75
75
76
76
const classNamesSig = useComputed$ ( ( ) => [
@@ -96,7 +96,7 @@ export const Tab = component$(
96
96
( props . class as Signal < string > ) ?. value ?? ( props . class as string ) ,
97
97
classNamesSig . value
98
98
] }
99
- onClick$ = { [ $ ( ( ) => contextService . selectTab$ ( _tabId ! ) ) , props . onClick$ ] }
99
+ onClick$ = { [ $ ( ( ) => contextService . selectTab$ ( tabId ! ) ) , props . onClick$ ] }
100
100
>
101
101
< Slot />
102
102
</ button >
0 commit comments