From 9b8b697b902638e8bc8a4b88b3e557d3b048dfdb Mon Sep 17 00:00:00 2001 From: yasupeke Date: Thu, 9 Aug 2018 21:30:43 +0900 Subject: [PATCH] update react-paginate --- types/react-paginate/index.d.ts | 13 +- types/react-paginate/react-paginate-tests.tsx | 4 +- types/react-paginate/tsconfig.json | 12 +- types/react-paginate/v4/index.d.ts | 125 ++++++++++++++++++ .../v4/react-paginate-tests.tsx | 33 +++++ types/react-paginate/v4/tsconfig.json | 30 +++++ types/react-paginate/v4/tslint.json | 1 + 7 files changed, 202 insertions(+), 16 deletions(-) create mode 100644 types/react-paginate/v4/index.d.ts create mode 100644 types/react-paginate/v4/react-paginate-tests.tsx create mode 100644 types/react-paginate/v4/tsconfig.json create mode 100644 types/react-paginate/v4/tslint.json diff --git a/types/react-paginate/index.d.ts b/types/react-paginate/index.d.ts index 83d8c476c9..0e0daa376a 100644 --- a/types/react-paginate/index.d.ts +++ b/types/react-paginate/index.d.ts @@ -1,11 +1,8 @@ -// Type definitions for react-paginate 4.3 +// Type definitions for react-paginate 5.2 // Project: https://github.com/AdeleD/react-paginate -// Definitions by: Simon Hartcher -// Wouter Hardeman -// pegel03 -// Simon Archer +// Definitions by: Yasunori Ohoka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.9 import * as React from 'react'; @@ -48,7 +45,7 @@ interface ReactPaginateProps { /** * The method to call when a page is clicked. Exposes the current page object as an argument. */ - onPageChange?(selectedItem: {selected: number}): void; + onPageChange?(selectedItem: { selected: number }): void; /** * The initial page selected. @@ -122,4 +119,4 @@ interface ReactPaginateProps { } declare const ReactPaginate: React.ComponentClass; -export = ReactPaginate; +export default ReactPaginate; diff --git a/types/react-paginate/react-paginate-tests.tsx b/types/react-paginate/react-paginate-tests.tsx index 92d8659c0c..a98e8702a4 100644 --- a/types/react-paginate/react-paginate-tests.tsx +++ b/types/react-paginate/react-paginate-tests.tsx @@ -1,5 +1,5 @@ -import * as React from "react"; -import ReactPaginate = require("react-paginate"); +import * as React from 'react'; +import ReactPaginate from 'react-paginate'; class Test extends React.Component { render() { diff --git a/types/react-paginate/tsconfig.json b/types/react-paginate/tsconfig.json index 5653cee275..5c49c56d9e 100644 --- a/types/react-paginate/tsconfig.json +++ b/types/react-paginate/tsconfig.json @@ -1,8 +1,4 @@ { - "files": [ - "index.d.ts", - "react-paginate-tests.tsx" - ], "compilerOptions": { "module": "commonjs", "lib": [ @@ -21,5 +17,9 @@ "noEmit": true, "forceConsistentCasingInFileNames": true, "jsx": "react" - } -} \ No newline at end of file + }, + "files": [ + "index.d.ts", + "react-paginate-tests.tsx" + ] + } diff --git a/types/react-paginate/v4/index.d.ts b/types/react-paginate/v4/index.d.ts new file mode 100644 index 0000000000..736455f60f --- /dev/null +++ b/types/react-paginate/v4/index.d.ts @@ -0,0 +1,125 @@ +// Type definitions for react-paginate 4.3 +// Project: https://github.com/AdeleD/react-paginate +// Definitions by: Simon Hartcher +// Wouter Hardeman +// pegel03 +// Simon Archer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +interface ReactPaginateProps { + /** + * The total number of pages. + */ + pageCount: number; + + /** + * The range of pages displayed. + */ + pageRangeDisplayed: number; + + /** + * The number of pages to display for margins. + */ + marginPagesDisplayed: number; + + /** + * Label for the `previous` button. + */ + previousLabel?: string | JSX.Element; + + /** + * Label for the `next` button. + */ + nextLabel?: string | JSX.Element; + + /** + * Label for ellipsis. + */ + breakLabel?: string | JSX.Element; + + /** + * The classname on tag `li` of the ellipsis element. + */ + breakClassName?: string | JSX.Element; + + /** + * The method to call when a page is clicked. Exposes the current page object as an argument. + */ + onPageChange?(selectedItem: { selected: number }): void; + + /** + * The initial page selected. + */ + initialPage?: number; + + /** + * To override selected page with parent prop. + */ + forcePage?: number; + + /** + * Disable onPageChange callback with initial page. Default: false + */ + disableInitialCallback?: boolean; + + /** + * The classname of the pagination container. + */ + containerClassName?: string; + + /** + * The classname on tag `li` of each page element. + */ + pageClassName?: string; + + /** + * The classname on tag `a` of each page element. + */ + pageLinkClassName?: string; + + /** + * The classname for the active page. + */ + activeClassName?: string; + + /** + * The classname on tag `li` of the `previous` button. + */ + previousClassName?: string; + + /** + * The classname on tag `li` of the `next` button. + */ + nextClassName?: string; + + /** + * The classname on tag `a` of the `previous` button. + */ + previousLinkClassName?: string; + + /** + * The classname on tag `a` of the `next` button. + */ + nextLinkClassName?: string; + + /** + * The classname for disabled `previous` and `next` buttons. + */ + disabledClassName?: string; + + /** + * The method is called to generate the href attribute value on tag a of each page element. + */ + hrefBuilder?(pageIndex: number): void; + + /** + * Extra context to add to the aria-label HTML attribute. + */ + extraAriaContext?: string; +} + +declare const ReactPaginate: React.ComponentClass; +export = ReactPaginate; diff --git a/types/react-paginate/v4/react-paginate-tests.tsx b/types/react-paginate/v4/react-paginate-tests.tsx new file mode 100644 index 0000000000..130db0248c --- /dev/null +++ b/types/react-paginate/v4/react-paginate-tests.tsx @@ -0,0 +1,33 @@ +import * as React from 'react'; +import ReactPaginate = require('react-paginate'); + +class Test extends React.Component { + render() { + return ( + null} + initialPage={2} + forcePage={3} + disableInitialCallback={false} + containerClassName={'container'} + pageClassName={'page-li'} + pageLinkClassName={'page-a'} + activeClassName={'active'} + previousClassName={'previous-li'} + nextClassName={'next-li'} + previousLinkClassName={'previous-a'} + nextLinkClassName={'next-a'} + disabledClassName={'disabled'} + hrefBuilder={(pageIndex: number) => null} + extraAriaContext={'aria'} + /> + ); + } +} diff --git a/types/react-paginate/v4/tsconfig.json b/types/react-paginate/v4/tsconfig.json new file mode 100644 index 0000000000..d6ee7a0357 --- /dev/null +++ b/types/react-paginate/v4/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "react-paginate": [ + "react-paginate/v4" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-paginate-tests.tsx" + ] +} diff --git a/types/react-paginate/v4/tslint.json b/types/react-paginate/v4/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-paginate/v4/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }