feat: add react-tabs-redux types

This commit is contained in:
Anton Bortnikov 2019-03-23 16:49:51 +05:00
parent 7d91d6eb32
commit 26ee14fa13
7 changed files with 134 additions and 0 deletions

15
types/react-tabs-redux/TabContent.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import * as React from 'react';
export interface TabContentProps {
children?: React.ReactNode;
for: string | number;
visibleStyle?: object;
isVisible?: boolean;
renderActiveTabContentOnly?: boolean;
disableInlineStyles?: boolean;
className?: string;
visibleClassName?: string;
style?: object;
}
export declare class TabContent extends React.Component<TabContentProps> {}

19
types/react-tabs-redux/TabLink.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
import * as React from 'react';
export interface TabLinkProps {
to: number | string;
component?: string;
handleSelect?: (tab: string, name: string) => void;
onClick?: (event: Event) => void;
children?: React.ReactNode;
isActive?: boolean;
namespace?: string;
activeStyle?: object;
disableInlineStyles?: boolean;
className?: string;
activeClassName?: string;
style?: object;
default?: boolean;
}
export declare class TabLink extends React.Component<TabLinkProps> {}

14
types/react-tabs-redux/Tabs.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import * as React from 'react';
export interface TabsProps {
name?: string;
onChange?: (selectedTab: string, name: string) => void;
handleSelect?: (tab: string, name: string) => void;
selectedTab?: string;
activeLinkStyle?: object;
visibleTabStyle?: object;
disableInlineStyles?: boolean;
renderActiveTabContentOnly?: boolean;
}
export declare class Tabs extends React.Component<TabsProps> {}

8
types/react-tabs-redux/index.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
// Type definitions for react-tabs-redux 4.0
// Project: https://github.com/patrik-piskay/react-tabs-redux#readme
// Definitions by: Anton Bortnikov <https://github.com/ntnbrtnkv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export {Tabs, TabsProps} from './Tabs';
export {TabLink, TabLinkProps} from './TabLink';
export {TabContent, TabContentProps} from './TabContent';

View File

@ -0,0 +1,44 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {
Tabs,
TabLink,
TabContent,
TabsProps,
TabLinkProps,
TabContentProps
} from 'react-tabs-redux';
interface TestTabsProps extends TabsProps {}
interface TestTabLinkProps extends TabLinkProps {}
interface TestTabContentProps extends TabContentProps {}
class TestApp extends React.Component {
onChange = (selectedTab: string, name: string) => {
console.log(`selectedTab: ${selectedTab}`);
console.log(`namespace: ${name}`);
}
onClick = (event: Event) => {
console.log(`event: ${event.type}`);
}
render() {
return (
<Tabs onChange={this.onChange} renderActiveTabContentOnly>
<TabLink to="tab1" onClick={this.onClick}>Tab1</TabLink>
<TabLink to="tab2" default>Tab2</TabLink>
<TabLink to="tab3" activeStyle={{color: 'blue'}}>Tab3</TabLink>
<TabContent for="tab1" disableInlineStyles>Content1</TabContent>
<TabContent for="tab2" className="test">Content2</TabContent>
<TabContent for="tab3" isVisible={false}>Content3</TabContent>
</Tabs>
);
}
}
ReactDOM.render(
<TestApp/>,
document.getElementById("test-app")
);

View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"jsx": "react",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"Tabs.d.ts",
"TabLink.d.ts",
"TabContent.d.ts",
"react-tabs-redux-tests.tsx"
]
}

View File

@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
}
}