From dac1bf9e0607e7050df5863a6cd633cd3a9cef84 Mon Sep 17 00:00:00 2001 From: makoto abe Date: Thu, 13 Jul 2017 19:16:31 +0900 Subject: [PATCH] Add type definitions for `material-ui-pagination` package. --- types/material-ui-pagination/index.d.ts | 14 ++++ .../material-ui-pagination-tests.tsx | 69 +++++++++++++++++++ types/material-ui-pagination/tsconfig.json | 25 +++++++ types/material-ui-pagination/tslint.json | 1 + 4 files changed, 109 insertions(+) create mode 100644 types/material-ui-pagination/index.d.ts create mode 100644 types/material-ui-pagination/material-ui-pagination-tests.tsx create mode 100644 types/material-ui-pagination/tsconfig.json create mode 100644 types/material-ui-pagination/tslint.json diff --git a/types/material-ui-pagination/index.d.ts b/types/material-ui-pagination/index.d.ts new file mode 100644 index 0000000000..2e8ec8f1df --- /dev/null +++ b/types/material-ui-pagination/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for material-ui-pagination 1.0 +// Project: https://github.com/lo-tp/material-ui-pagination +// Definitions by: m0a +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 +import * as React from 'react'; +export interface PaginationProps { + total: number; + display: number; + current: number; + onChange(value: number): void; +} +declare class Pagination extends React.Component {} +export default Pagination; diff --git a/types/material-ui-pagination/material-ui-pagination-tests.tsx b/types/material-ui-pagination/material-ui-pagination-tests.tsx new file mode 100644 index 0000000000..ccef0701f3 --- /dev/null +++ b/types/material-ui-pagination/material-ui-pagination-tests.tsx @@ -0,0 +1,69 @@ +import * as React from 'react'; +import { Component, PropTypes } from 'react'; +import * as ReactDOM from 'react-dom'; +import Pagination from 'material-ui-pagination'; +import * as ui from 'material-ui'; +import { MuiThemeProvider } from 'material-ui/styles'; +import * as injectTapEventPlugin from 'react-tap-event-plugin'; + +// Needed for onTouchTap +// Check this repo: +// https://github.com/zilverline/react-tap-event-plugin +injectTapEventPlugin(); + +interface PagerState { + pageIndex: number; +} + +class Pager extends React.Component<{}, PagerState> { + constructor() { + super(); + this.state = { + pageIndex: 0 + }; + } + setPageIndex = (pageIndex: number) => { + this.setState({ pageIndex }); + } + render() { + const { pageIndex } = this.state; + const length = 100; + const perPage = 10; + const totalPage = Math.floor(length / perPage); + + let list: JSX.Element[] = []; + for (let i = pageIndex * perPage; i < (pageIndex * perPage + perPage); i++) { + list.push(

{`No.${i}`}

); + } + + return (
+ + + +
+ {list} +
+ + + +
); + } +} + +const Index = () => ( + + + +); + +ReactDOM.render(, document.getElementById('root') as HTMLElement); diff --git a/types/material-ui-pagination/tsconfig.json b/types/material-ui-pagination/tsconfig.json new file mode 100644 index 0000000000..55a79c9ac6 --- /dev/null +++ b/types/material-ui-pagination/tsconfig.json @@ -0,0 +1,25 @@ +{ + "files": [ + "index.d.ts", + "material-ui-pagination-tests.tsx" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "jsx": "react", + "experimentalDecorators": true, + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/material-ui-pagination/tslint.json b/types/material-ui-pagination/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/material-ui-pagination/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }