1- import React , { Component , createRef , HTMLAttributes , ReactNode } from 'react'
1+ import React , { Component , createRef , HTMLAttributes , ReactNode } from 'react' ;
22
33import { htmlIdGenerator } from '../../../services' ;
44
5- import { EuiTabs , EuiTabsDisplaySizes , EuiTabsSizes } from '../tabs'
5+ import { EuiTabs , EuiTabsDisplaySizes , EuiTabsSizes } from '../tabs' ;
66import { EuiTab } from '../tab' ;
7- import { CommonProps } from '../../common'
7+ import { CommonProps } from '../../common' ;
88
99const makeId = htmlIdGenerator ( ) ;
1010
@@ -24,49 +24,51 @@ interface EuiTabbedContentState {
2424 inFocus : boolean ;
2525}
2626
27- export type EuiTabbedContentProps = CommonProps
28- & HTMLAttributes < HTMLDivElement >
29- & {
30- /**
31- * When tabbing into the tabs, set the focus on `initial` for the first tab,
32- * or `selected` for the currently selected tab. Best use case is for inside of
33- * overlay content like popovers or flyouts.
34- */
35- autoFocus ?: 'initial' | 'selected' ;
36- /**
37- * Choose `default` or alternative `condensed` display styles
38- */
39- display ?: EuiTabsDisplaySizes ;
40- /**
41- * Evenly stretches each tab to fill the horizontal space
42- */
43- expand ?: boolean ;
44- /**
45- * Use this prop to set the initially selected tab while letting the tabbed content component
46- * control selection state internally
47- */
48- initialSelectedTab ?: EuiTabbedContentTabDescriptor ;
49- onTabClick ?: ( selectedTab : EuiTabbedContentTabDescriptor ) => void ;
50- /**
51- * Use this prop if you want to control selection state within the owner component
52- */
53- selectedTab ?: EuiTabbedContentTabDescriptor ;
54- size ?: EuiTabsSizes ;
55- /**
56- * Each tab needs id and content properties, so we can associate it with its panel for accessibility.
57- * The name property is also required to display to the user.
58- */
59- tabs : Array < EuiTabbedContentTabDescriptor >
60- }
27+ export type EuiTabbedContentProps = CommonProps &
28+ HTMLAttributes < HTMLDivElement > & {
29+ /**
30+ * When tabbing into the tabs, set the focus on `initial` for the first tab,
31+ * or `selected` for the currently selected tab. Best use case is for inside of
32+ * overlay content like popovers or flyouts.
33+ */
34+ autoFocus ?: 'initial' | 'selected' ;
35+ /**
36+ * Choose `default` or alternative `condensed` display styles
37+ */
38+ display ?: EuiTabsDisplaySizes ;
39+ /**
40+ * Evenly stretches each tab to fill the horizontal space
41+ */
42+ expand ?: boolean ;
43+ /**
44+ * Use this prop to set the initially selected tab while letting the tabbed content component
45+ * control selection state internally
46+ */
47+ initialSelectedTab ?: EuiTabbedContentTabDescriptor ;
48+ onTabClick ?: ( selectedTab : EuiTabbedContentTabDescriptor ) => void ;
49+ /**
50+ * Use this prop if you want to control selection state within the owner component
51+ */
52+ selectedTab ?: EuiTabbedContentTabDescriptor ;
53+ size ?: EuiTabsSizes ;
54+ /**
55+ * Each tab needs id and content properties, so we can associate it with its panel for accessibility.
56+ * The name property is also required to display to the user.
57+ */
58+ tabs : EuiTabbedContentTabDescriptor [ ] ;
59+ } ;
6160
62- export class EuiTabbedContent extends Component < EuiTabbedContentProps , EuiTabbedContentState > {
61+ export class EuiTabbedContent extends Component <
62+ EuiTabbedContentProps ,
63+ EuiTabbedContentState
64+ > {
6365 static defaultProps = {
6466 autoFocus : 'initial' ,
6567 } ;
6668
6769 private readonly rootId = makeId ( ) ;
6870
69- private readonly divRef = createRef < HTMLDivElement > ( )
71+ private readonly divRef = createRef < HTMLDivElement > ( ) ;
7072
7173 constructor ( props : EuiTabbedContentProps ) {
7274 super ( props ) ;
@@ -91,14 +93,20 @@ export class EuiTabbedContent extends Component<EuiTabbedContentProps, EuiTabbed
9193 // but does add it for focusout. React doesn't support `onFocusOut` so here we are.
9294 if ( this . divRef . current ) {
9395 // Current short-term solution for event listener (see https://github.com/elastic/eui/pull/2717)
94- this . divRef . current . addEventListener ( 'focusout' as 'blur' , this . removeFocus ) ;
96+ this . divRef . current . addEventListener (
97+ 'focusout' as 'blur' ,
98+ this . removeFocus
99+ ) ;
95100 }
96101 }
97102
98103 componentWillUnmount ( ) {
99104 if ( this . divRef . current ) {
100105 // Current short-term solution for event listener (see https://github.com/elastic/eui/pull/2717)
101- this . divRef . current . removeEventListener ( 'focusout' as 'blur' , this . removeFocus ) ;
106+ this . divRef . current . removeEventListener (
107+ 'focusout' as 'blur' ,
108+ this . removeFocus
109+ ) ;
102110 }
103111 }
104112
@@ -157,7 +165,10 @@ export class EuiTabbedContent extends Component<EuiTabbedContentProps, EuiTabbed
157165 // Allow the consumer to control tab selection.
158166 const selectedTab =
159167 externalSelectedTab ||
160- tabs . find ( ( tab : EuiTabbedContentTabDescriptor ) => tab . id === this . state . selectedTabId ) ;
168+ tabs . find (
169+ ( tab : EuiTabbedContentTabDescriptor ) =>
170+ tab . id === this . state . selectedTabId
171+ ) ;
161172
162173 const { content : selectedTabContent , id : selectedTabId } = selectedTab ! ;
163174
0 commit comments