Skip to content

Commit 0cb15ff

Browse files
committed
feat: Add typescript typings to repo
1 parent 58caf6a commit 0cb15ff

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

index.d.ts

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { FunctionComponent, HTMLProps } from 'react';
2+
3+
export interface TabsProps
4+
extends Omit<HTMLProps<HTMLDivElement>, 'className' | 'onSelect' | 'ref'> {
5+
className?: string | string[] | { [name: string]: boolean } | undefined;
6+
defaultFocus?: boolean | undefined;
7+
defaultIndex?: number | undefined;
8+
direction?: 'rtl' | 'ltr' | undefined;
9+
disabledTabClassName?: string | undefined;
10+
disableUpDownKeys?: boolean | undefined;
11+
domRef?: ((node?: HTMLElement) => void) | undefined;
12+
environment?: Window | undefined;
13+
focusTabOnClick?: boolean | undefined;
14+
forceRenderTabPanel?: boolean | undefined;
15+
onSelect?:
16+
| ((index: number, last: number, event: Event) => boolean | void)
17+
| undefined;
18+
selectedIndex?: number | undefined;
19+
selectedTabClassName?: string | undefined;
20+
selectedTabPanelClassName?: string | undefined;
21+
}
22+
23+
export interface TabListProps
24+
extends Omit<HTMLProps<HTMLUListElement>, 'className'> {
25+
className?: string | string[] | { [name: string]: boolean } | undefined;
26+
}
27+
28+
export interface TabProps
29+
extends Omit<HTMLProps<HTMLLIElement>, 'className' | 'tabIndex'> {
30+
className?: string | string[] | { [name: string]: boolean } | undefined;
31+
disabled?: boolean | undefined;
32+
disabledClassName?: string | undefined;
33+
selectedClassName?: string | undefined;
34+
tabIndex?: string | undefined;
35+
}
36+
37+
export interface TabPanelProps
38+
extends Omit<HTMLProps<HTMLDivElement>, 'className'> {
39+
className?: string | string[] | { [name: string]: boolean } | undefined;
40+
forceRender?: boolean | undefined;
41+
selectedClassName?: string | undefined;
42+
}
43+
44+
export const Tabs: FunctionComponent<TabsProps>;
45+
export const TabList: FunctionComponent<TabListProps>;
46+
export const Tab: FunctionComponent<TabProps>;
47+
export const TabPanel: FunctionComponent<TabPanelProps>;
48+
49+
export declare function resetIdCounter(): void;

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "An accessible and easy tab component for ReactJS",
55
"main": "lib/index.js",
66
"module": "esm/index.js",
7+
"typings": "index.d.ts",
78
"scripts": {
89
"clean:commonjs": "rimraf lib",
910
"clean:umd": "rimraf dist",
@@ -36,7 +37,8 @@
3637
"esm",
3738
"lib",
3839
"style",
39-
"src"
40+
"src",
41+
"index.d.ts"
4042
],
4143
"homepage": "https://github.com/reactjs/react-tabs",
4244
"keywords": [

src/components/Tab.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const propTypes = {
2525
PropTypes.object,
2626
]),
2727
disabled: PropTypes.bool,
28-
tabIndex: PropTypes.string,
2928
disabledClassName: PropTypes.string,
3029
focus: PropTypes.bool, // private
3130
id: PropTypes.string, // private
3231
panelId: PropTypes.string, // private
3332
selected: PropTypes.bool, // private
3433
selectedClassName: PropTypes.string,
35-
tabRef: PropTypes.func,
34+
tabIndex: PropTypes.string,
35+
tabRef: PropTypes.func, // private
3636
};
3737

3838
const Tab = (props) => {

src/components/Tabs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ const MODE_CONTROLLED = 0;
1212
const MODE_UNCONTROLLED = 1;
1313
const propTypes = {
1414
children: childrenPropType,
15-
direction: PropTypes.oneOf(['rtl', 'ltr']),
1615
className: PropTypes.oneOfType([
1716
PropTypes.string,
1817
PropTypes.array,
1918
PropTypes.object,
2019
]),
2120
defaultFocus: PropTypes.bool,
2221
defaultIndex: PropTypes.number,
22+
direction: PropTypes.oneOf(['rtl', 'ltr']),
2323
disabledTabClassName: PropTypes.string,
2424
disableUpDownKeys: PropTypes.bool,
2525
domRef: PropTypes.func,
26+
environment: PropTypes.object,
2627
focusTabOnClick: PropTypes.bool,
2728
forceRenderTabPanel: PropTypes.bool,
2829
onSelect: onSelectPropType,
2930
selectedIndex: selectedIndexPropType,
3031
selectedTabClassName: PropTypes.string,
3132
selectedTabPanelClassName: PropTypes.string,
32-
environment: PropTypes.object,
3333
};
3434
const defaultProps = {
3535
defaultFocus: false,

0 commit comments

Comments
 (0)