11import type {
2+ DefaultOptionsRule ,
23 Orientation , Position , TabsIconPosition , TabsStyle ,
34} from '@js/common' ;
45import registerComponent from '@js/core/component_registrator' ;
@@ -10,7 +11,8 @@ import $ from '@js/core/renderer';
1011import { BindableTemplate } from '@js/core/templates/bindable_template' ;
1112import { getImageContainer } from '@js/core/utils/icon' ;
1213import { isDefined , isPlainObject } from '@js/core/utils/type' ;
13- import type { Properties } from '@js/ui/tab_panel' ;
14+ import type { DxEvent } from '@js/events' ;
15+ import type { Item , Properties } from '@js/ui/tab_panel' ;
1416import { current as currentTheme , isFluent , isMaterialBased } from '@js/ui/themes' ;
1517import supportUtils from '@ts/core/utils/m_support' ;
1618import type { OptionChanged } from '@ts/core/widget/types' ;
@@ -71,7 +73,7 @@ const STYLING_MODE: Record<TabsStyle, TabsStyle> = {
7173export interface TabPanelProperties extends Properties {
7274 _tabsIndicatorPosition ?: Position | null ;
7375
74- badgeExpr ?: ( data ) => boolean | undefined ;
76+ badgeExpr ?: ( data ) => string | undefined ;
7577
7678 focusedElement ?: dxElementWrapper ;
7779}
@@ -111,26 +113,27 @@ class TabPanel extends MultiView<TabPanelProperties> {
111113 onTitleHold : null ,
112114 // @ts -expect-error ts-error
113115 onTitleRendered : null ,
114- badgeExpr ( data ) { return data ? data . badge : undefined ; } ,
115-
116+ badgeExpr ( data : Item ) : string | undefined {
117+ return data ?. badge ;
118+ } ,
116119 _tabsIndicatorPosition : null ,
117120 } ;
118121 }
119122
120- _defaultOptionsRules ( ) {
123+ _defaultOptionsRules ( ) : DefaultOptionsRule < TabPanelProperties > [ ] {
121124 const themeName = currentTheme ( ) ;
122125
123126 return super . _defaultOptionsRules ( ) . concat ( [
124127 {
125- device ( ) {
128+ device ( ) : boolean {
126129 return devices . real ( ) . deviceType === 'desktop' && ! devices . isSimulator ( ) ;
127130 } ,
128131 options : {
129132 focusStateEnabled : true ,
130133 } ,
131134 } ,
132135 {
133- device ( ) {
136+ device ( ) : boolean {
134137 return ! supportUtils . touch ;
135138 } ,
136139 options : {
@@ -144,15 +147,15 @@ class TabPanel extends MultiView<TabPanelProperties> {
144147 } ,
145148 } ,
146149 {
147- device ( ) {
150+ device ( ) : boolean {
148151 return isFluent ( themeName ) ;
149152 } ,
150153 options : {
151154 stylingMode : STYLING_MODE . secondary ,
152155 } ,
153156 } ,
154157 {
155- device ( ) {
158+ device ( ) : boolean {
156159 return isMaterialBased ( themeName ) ;
157160 } ,
158161 options : {
@@ -169,22 +172,25 @@ class TabPanel extends MultiView<TabPanelProperties> {
169172 this . _toggleTabPanelTabsPositionClass ( ) ;
170173 }
171174
172- _getElementAria ( ) {
175+ // eslint-disable-next-line class-methods-use-this
176+ _getElementAria ( ) : Record < string , string > {
173177 return { role : 'tabpanel' } ;
174178 }
175179
176- _getItemAria ( ) {
180+ // eslint-disable-next-line class-methods-use-this
181+ _getItemAria ( ) : Record < string , string > {
177182 return { role : 'tabpanel' } ;
178183 }
179184
180- _initMarkup ( ) {
185+ _initMarkup ( ) : void {
181186 super . _initMarkup ( ) ;
182187
183188 this . _createTitleActions ( ) ;
184189 this . _renderLayout ( ) ;
185190 }
186191
187- _prepareTabsItemTemplate ( data , $container ) {
192+ // eslint-disable-next-line class-methods-use-this
193+ _prepareTabsItemTemplate ( data : Item , $container : dxElementWrapper ) : void {
188194 const $iconElement = getImageContainer ( data ?. icon ) ;
189195
190196 if ( $iconElement ) {
@@ -205,7 +211,7 @@ class TabPanel extends MultiView<TabPanelProperties> {
205211 }
206212 }
207213
208- _initTemplates ( ) {
214+ _initTemplates ( ) : void {
209215 super . _initTemplates ( ) ;
210216
211217 this . _templateManager . addDefaultTemplates ( {
@@ -273,11 +279,12 @@ class TabPanel extends MultiView<TabPanelProperties> {
273279 this . setAria ( 'controls' , id , $activeTab ) ;
274280 }
275281
276- _getTabsIndicatorPosition ( ) {
282+ _getTabsIndicatorPosition ( ) : Position {
277283 // eslint-disable-next-line @typescript-eslint/naming-convention
278284 const { _tabsIndicatorPosition, tabsPosition } = this . option ( ) ;
279- // @ts -expect-error ts-error
280- return _tabsIndicatorPosition ?? TABS_INDICATOR_POSITION_BY_TABS_POSITION [ tabsPosition ] ;
285+
286+ return _tabsIndicatorPosition
287+ ?? TABS_INDICATOR_POSITION_BY_TABS_POSITION [ tabsPosition ?? TABS_POSITION . top ] ;
281288 }
282289
283290 _tabConfig ( ) : TabsProperties {
@@ -349,7 +356,7 @@ class TabPanel extends MultiView<TabPanelProperties> {
349356 itemTemplateProperty : 'tabTemplate' ,
350357 loopItemFocus : loop ,
351358 selectionRequired : true ,
352- onOptionChanged : function ( args ) {
359+ onOptionChanged : ( args ) : void => {
353360 if ( args . name === 'focusedElement' ) {
354361 if ( args . value ) {
355362 const $value = $ ( args . value ) ;
@@ -359,13 +366,13 @@ class TabPanel extends MultiView<TabPanelProperties> {
359366 this . option ( 'focusedElement' , args . value ) ;
360367 }
361368 }
362- } . bind ( this ) ,
363- onFocusIn : function ( args ) { this . _focusInHandler ( args . event ) ; } . bind ( this ) ,
364- onFocusOut : function ( args ) {
369+ } ,
370+ onFocusIn : ( args ) : void => { this . _focusInHandler ( args . event ) ; } ,
371+ onFocusOut : ( args ) : void => {
365372 if ( ! this . _isFocusOutHandlerExecuting ) {
366373 this . _focusOutHandler ( args . event ) ;
367374 }
368- } . bind ( this ) ,
375+ } ,
369376 orientation : this . _getTabsOrientation ( ) ,
370377 iconPosition,
371378 stylingMode,
@@ -389,9 +396,9 @@ class TabPanel extends MultiView<TabPanelProperties> {
389396 }
390397
391398 _getTabPanelTabsPositionClass ( ) : string {
392- const position = this . option ( 'tabsPosition' ) ;
399+ const { tabsPosition } = this . option ( ) ;
393400
394- switch ( position ) {
401+ switch ( tabsPosition ) {
395402 case TABS_POSITION . right :
396403 return TABPANEL_TABS_POSITION_CLASS . right ;
397404 case TABS_POSITION . bottom :
@@ -421,15 +428,15 @@ class TabPanel extends MultiView<TabPanelProperties> {
421428 this . _setTabsOption ( 'orientation' , orientation ) ;
422429 }
423430
424- _toggleWrapperFocusedClass ( isFocused ) : void {
431+ _toggleWrapperFocusedClass ( isFocused : boolean ) : void {
425432 this . _toggleFocusClass ( isFocused , this . _$wrapper ) ;
426433 }
427434
428- _toggleDisabledFocusedClass ( isFocused ) : void {
435+ _toggleDisabledFocusedClass ( isFocused : boolean ) : void {
429436 this . _focusTarget ( ) . toggleClass ( DISABLED_FOCUSED_TAB_CLASS , isFocused ) ;
430437 }
431438
432- _updateFocusState ( e , isFocused ) : void {
439+ _updateFocusState ( e : DxEvent , isFocused : boolean ) : void {
433440 super . _updateFocusState ( e , isFocused ) ;
434441
435442 const isTabsTarget = e . target === this . _tabs . _focusTarget ( ) . get ( 0 ) ;
@@ -454,32 +461,31 @@ class TabPanel extends MultiView<TabPanelProperties> {
454461 }
455462 }
456463
457- _focusOutHandler ( e ) : void {
464+ _focusOutHandler ( e : DxEvent ) : void {
458465 this . _isFocusOutHandlerExecuting = true ;
459- // @ts -expect-error ts-error
460- super . _focusOutHandler . apply ( this , arguments ) ;
466+ super . _focusOutHandler ( e ) ;
461467
462468 this . _tabs . _focusOutHandler ( e ) ;
463469 this . _isFocusOutHandlerExecuting = false ;
464470 }
465471
466- _setTabsOption ( name , value ) : void {
472+ _setTabsOption ( name : keyof TabsProperties , value : unknown ) : void {
467473 if ( this . _tabs ) {
468474 this . _tabs . option ( name , value ) ;
469475 }
470476 }
471477
472- _postprocessSwipe ( { swipedTabsIndex } ) : void {
473- this . _setTabsOption ( 'selectedIndex' , swipedTabsIndex ) ;
478+ _postprocessSwipe ( args : { swipedTabsIndex : number } ) : void {
479+ this . _setTabsOption ( 'selectedIndex' , args . swipedTabsIndex ) ;
474480 }
475481
476- _visibilityChanged ( visible ) : void {
482+ _visibilityChanged ( visible : boolean ) : void {
477483 if ( visible ) {
478484 this . _tabs . _dimensionChanged ( ) ;
479485 }
480486 }
481487
482- registerKeyHandler ( key , handler ) : void {
488+ registerKeyHandler ( key : string , handler : ( event ? ) => void ) : void {
483489 super . registerKeyHandler ( key , handler ) ;
484490
485491 if ( this . _tabs ) {
@@ -520,8 +526,10 @@ class TabPanel extends MultiView<TabPanelProperties> {
520526 case 'selectedItem' : {
521527 this . _setTabsOption ( fullName , value ) ;
522528 super . _optionChanged ( args ) ;
523- // @ts -expect-error ts-error
524- if ( this . option ( 'focusStateEnabled' ) === true ) {
529+
530+ const { focusStateEnabled } = this . option ( ) ;
531+
532+ if ( focusStateEnabled === true ) {
525533 const selectedIndex = this . option ( 'selectedIndex' ) ;
526534 // @ts -expect-error ts-error
527535 const selectedTabContent = this . _itemElements ( ) . eq ( selectedIndex ) ;
0 commit comments