Skip to content

Commit 49895d0

Browse files
committed
EuiTabs: run ESLint
1 parent 769b0c0 commit 49895d0

4 files changed

Lines changed: 80 additions & 66 deletions

File tree

src/components/tabs/tab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const EuiTab: FunctionComponent<Props> = ({
5454
href={href}
5555
target={target}
5656
rel={secureRel}
57-
{...rest as AnchorHTMLAttributes<HTMLAnchorElement>}>
57+
{...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)}>
5858
<span className="euiTab__content">{children}</span>
5959
</a>
6060
);
@@ -67,7 +67,7 @@ export const EuiTab: FunctionComponent<Props> = ({
6767
type="button"
6868
className={classes}
6969
disabled={disabled}
70-
{...rest as ButtonHTMLAttributes<HTMLButtonElement>}>
70+
{...(rest as ButtonHTMLAttributes<HTMLButtonElement>)}>
7171
<span className="euiTab__content">{children}</span>
7272
</button>
7373
);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export { EuiTabbedContent, EuiTabbedContentTabDescriptor, EuiTabbedContentProps } from './tabbed_content';
1+
export {
2+
EuiTabbedContent,
3+
EuiTabbedContentTabDescriptor,
4+
EuiTabbedContentProps,
5+
} from './tabbed_content';

src/components/tabs/tabbed_content/tabbed_content.tsx

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { Component, createRef, HTMLAttributes, ReactNode } from 'react'
1+
import React, { Component, createRef, HTMLAttributes, ReactNode } from 'react';
22

33
import { htmlIdGenerator } from '../../../services';
44

5-
import { EuiTabs, EuiTabsDisplaySizes, EuiTabsSizes } from '../tabs'
5+
import { EuiTabs, EuiTabsDisplaySizes, EuiTabsSizes } from '../tabs';
66
import { EuiTab } from '../tab';
7-
import { CommonProps } from '../../common'
7+
import { CommonProps } from '../../common';
88

99
const 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

src/components/tabs/tabs.tsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { HTMLAttributes, PropsWithChildren } from 'react'
1+
import React, { HTMLAttributes, PropsWithChildren } from 'react';
22
import classNames from 'classnames';
3-
import { CommonProps, keysOf } from '../common'
3+
import { CommonProps, keysOf } from '../common';
44

55
const displayToClassNameMap = {
66
condensed: 'euiTabs--condensed',
77
default: null,
88
};
99

10-
export const DISPLAYS = keysOf(displayToClassNameMap)
10+
export const DISPLAYS = keysOf(displayToClassNameMap);
1111

1212
export type EuiTabsDisplaySizes = keyof typeof displayToClassNameMap;
1313

@@ -16,24 +16,23 @@ const sizeToClassNameMap = {
1616
m: null,
1717
};
1818

19-
export const SIZES = keysOf(sizeToClassNameMap)
20-
21-
export type EuiTabsSizes = keyof typeof sizeToClassNameMap
22-
23-
export type EuiTabsProps = CommonProps
24-
& HTMLAttributes<HTMLDivElement>
25-
& {
26-
/**
27-
* Choose `default` or alternative `condensed` display styles
28-
*/
29-
display?: EuiTabsDisplaySizes;
30-
/**
31-
* Evenly stretches each tab to fill the
32-
* horizontal space
33-
*/
34-
expand?: boolean;
35-
size?: EuiTabsSizes
36-
}
19+
export const SIZES = keysOf(sizeToClassNameMap);
20+
21+
export type EuiTabsSizes = keyof typeof sizeToClassNameMap;
22+
23+
export type EuiTabsProps = CommonProps &
24+
HTMLAttributes<HTMLDivElement> & {
25+
/**
26+
* Choose `default` or alternative `condensed` display styles
27+
*/
28+
display?: EuiTabsDisplaySizes;
29+
/**
30+
* Evenly stretches each tab to fill the
31+
* horizontal space
32+
*/
33+
expand?: boolean;
34+
size?: EuiTabsSizes;
35+
};
3736

3837
export const EuiTabs = ({
3938
children,

0 commit comments

Comments
 (0)