Giter VIP home page Giter VIP logo

pagination's Introduction

rc-pagination

React Pagination Component.

NPM version npm download build status Codecov bundle size dumi

Development

npm install
npm start

Examples

Online example: https://pagination-react-component.vercel.app Local example: npm run start then http://localhost:9001

Install

rc-pagination

Usage

import Pagination from 'rc-pagination';

ReactDOM.render(<Pagination />, container);

API

Parameter Description Type Default
disabled disable pagination Bool -
align align of pagination start | center | end undefined
defaultCurrent uncontrolled current page Number 1
current current page Number undefined
total items total count Number 0
defaultPageSize default items per page Number 10
pageSize items per page Number 10
onChange page change callback Function(current, pageSize) -
showSizeChanger show pageSize changer Bool false when total less then totalBoundaryShowSizeChanger, true when otherwise
totalBoundaryShowSizeChanger when total larger than it, showSizeChanger will be true number 50
pageSizeOptions specify the sizeChanger selections Array ['10', '20', '50', '100']
onShowSizeChange pageSize change callback Function(current, size) -
hideOnSinglePage hide on single page Bool false
showPrevNextJumpers show jump-prev, jump-next Bool true
showQuickJumper show quick goto jumper Bool / Object false / {goButton: true}
showTotal show total records and range Function(total, [from, to]) -
className className of pagination String -
simple when set, show simple pager Bool / { readOnly?: boolean; } -
locale to set l10n config Object zh_CN
style the style of pagination Object {}
showLessItems show less page items Bool false
showTitle show page items title Bool true
itemRender custom page item renderer Function(current, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next', element): React.ReactNode | (current, type, element) => element
prevIcon specify the default previous icon ReactNode | (props: PaginationProps) => ReactNode
nextIcon specify the default next icon ReactNode | (props: PaginationProps) => ReactNode
jumpPrevIcon specify the default previous icon ReactNode | (props: PaginationProps) => ReactNode
jumpNextIcon specify the default next icon ReactNode | (props: PaginationProps) => ReactNode

License

rc-pagination is released under the MIT license.

pagination's People

Contributors

afc163 avatar benjycui avatar codesignist avatar coding-ice avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar hengkx avatar heskeybaozi avatar ibigbug avatar li-jia-nan avatar madccc avatar madisvain avatar msgill2017 avatar orkhan-huseyn avatar orzyyyy avatar paranoidjk avatar paunovic-stefan avatar plandem avatar robin-front avatar shaodahong avatar sivaraj-dev avatar wmzhong avatar wxh16144 avatar xrkffgg avatar yesmeck avatar yiminghe avatar yoyo837 avatar yutingzhao1991 avatar zombiej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pagination's Issues

代码有重复的方法

pagiantion.jsx 中 getJumpPrevPage 方法(132行和266行) getJumpNextPage 方法(136行和270行),应该是重复了。

SPAN improper child of UL

https://github.com/react-component/pagination/blob/master/src/Pagination.jsx#L374

It is improper markup to have a span as a child element of an ul.
This content should either precede or follow the actual pagination ul.
Also, with moving it outside of the UL, you could add an option for prepend || append, or make it easy on yourself and just allow the user to provide their own custom styles (such as flexbox) to arrange the pager and the text however they want.

I will attempt to put together a PR for this if you'd like.

Sizer

How can I put sizer on the left side?
Thanks!

Disable interaction

Hi, I suggest there should be a 'disabled' prop which, when set, disables the user interaction since in some cases we might want to temporally block user from doing so.

Pagination with API from backend!

First of All, amazing plugin.

I have seen all of the examples but I couldn't find pagination that could work with API. Let's see an example of Todo from API:

  1. API returns 10 items by clicking on each page.
  2. Total items of API are 400.
  3. We are using Axios API Client with react.

Now, I can't figure out how to use it with Axios and API.

dependency on `babel-runtime`?

Looks like starting v1.8.9, rc-pagination has a dependency on babel-runtime. Is that intentional? If so, I think babel-runtime needs to be added as a peerDependency.

如何控制pagination跳转输入框内的数值?

断点调试下,选择Table的第index页,但是发现_current变化后,input内的value并没有改变。

React.createElement('input', {
        type: 'text',
        value: this.state._current,
        onKeyDown: this._handleKeyDown,
        onKeyUp: this._handleKeyUp,
        onChange: this._handleKeyUp
}),

Centering component

What's the recommended way to center this component in a div? Since it's an unordered list, centering is a little finicky.

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `Options`.

This warning happens since 1.3.7 with the following code. v1.3.5 works.

                        <Pagination locale={Locale} selectComponentClass={Select} showSizeChanger={true} pageSizeOptions={['10', '25', '50', '100']} onShowSizeChange={this._onPageSizeChange} onChange={this._onPageNoChange} current={this.state.pageNo} pageSize={this.state.pageSize} total={this.state.total}/>

Add href in <a> tag to enable indexing by Google

The anchor tag does not include the href attribute.

Seems like, the element isn't a link (:link) unless it has an [href] attribute. A side-effect of this is that an element without [href] won't be indexed by Google.

Is it possible to have a callback for populating the href tag? (something that plays well with react-router)

Thanks!

(Ps: Thanks for the great component.)

Can't put it in the center

Please help, I'm trying to put the pagination component in the center with all the ways I know but i could not.

Support Thai language

What problem does this feature solve?

I need react-component pagination support thai language.

What does the proposed API look like?

I will translate and pull request to complete this issue.

Server Rendering: Component's children should not be mutated.

Hello,

Thank you for putting this together. You are a very awesome person!

I'm getting the following error when using Pagination with server-side rendering

warning.js:36
Warning: Component's children should not be mutated.
    in div (created by Pagination)
    in ul (created by Pagination)
    in Pagination (created by Connect(Pagination))
    in Connect(Pagination) (created by Search)
    in div (created by Search)
    in Search (created by Search)
    in Search (created by Connect(Search))
    in Connect(Search) (created by RouterContext)
    in div (created by SearchLayout)
    in div (created by SearchLayout)
    in div (created by SearchLayout)
    in SearchLayout (created by RouterContext)
    in RouterContext (created by Router)
    in Router (created by AppContainer)
    in div (created by AppContainer)
    in Provider (created by AppContainer)
    in AppContainer

itemRender is not working

Hello guys, thanks for the awesome package. I'm trying to change the next prev icon to text but the problem is it is not working. Here is the code. Please help me out thanks

import React from 'react'
import cn from 'classnames';
import Paginator from 'common_components/Paginator'

function Footer ({handleChangePage, changePageLength}) {
    const textItemRender = (current, type, element) => {
        debugger
        if (type === 'prev') {
            return 'Prev';
        }
        if (type === 'next') {
            return 'Next';
        }
        return element;
    };
    return (
        <div className={cn(styles['footer-container'], 'flex space-between align-center')}>
            <div>
                <Paginator
                    count={15}
                    limit={10}
                    pageNumber={1}
                    total={15}
                    callBack={handleChangePage}
                    itemRender={textItemRender}
                />
            </div>
        </div>
    );
}

export default Footer;

Accessibility Updates

We'd like to make the following accessibility updates to this component

  • Allow customization of the numbered page button titles through the locale
  • have screen readers interpret the Next Page and Previous Page as disabled when they are disabled.
    Would these updates be ok?

Is 'locale' working for all the languages?

Is there a way to change the language to English ('en_US')? I saw that there is an attribute 'locale' to change default language. However, it's not working for me.

Could you please provide an example on how to use 'locale'.

Can't render the css provided by you guys

Hello guys,

I'm trying to use your paginator but the problem is I'm not able to get the css as shown in your example. can you guys help me out maybe there is something I'm not doing right. HEre is my code


import Pagination from 'rc-pagination'
import 'rc-pagination/assets/index.css'


<Pagination className="ant-pagination" defaultCurrent={3} total={450} />

Examples don't build

Followed the README and navigated to http://localhost:3000/examples/ after doing the following:

npm install
npm start

There were errors while building the bundle. You'll see:

Listening at http://localhost:3000
10/20 build modules
webpack: bundle build is now finished.
Hash: d22b205c50dfd7328bfd
Version: webpack 1.15.0
Time: 566ms
       Asset     Size  Chunks             Chunk Names
  default.js  3.59 kB       0  [emitted]  default
   jumper.js   3.6 kB       1  [emitted]  jumper
lessPages.js  3.61 kB       2  [emitted]  lessPages
     more.js  3.59 kB       3  [emitted]  more
showTitle.js  3.61 kB       4  [emitted]  showTitle
showTotal.js  3.61 kB       5  [emitted]  showTotal
   simple.js   3.6 kB       6  [emitted]  simple
    sizer.js   3.6 kB       7  [emitted]  sizer
   stupid.js  3.61 kB       8  [emitted]  stupid
   styles.js  3.61 kB       9  [emitted]  styles
chunk    {0} default.js (default) 28 bytes [rendered]
    [0] multi default 28 bytes {0} [built] [1 error]
chunk    {1} jumper.js (jumper) 28 bytes [rendered]
    [0] multi jumper 28 bytes {1} [built] [1 error]
chunk    {2} lessPages.js (lessPages) 28 bytes [rendered]
    [0] multi lessPages 28 bytes {2} [built] [1 error]
chunk    {3} more.js (more) 28 bytes [rendered]
    [0] multi more 28 bytes {3} [built] [1 error]
chunk    {4} showTitle.js (showTitle) 28 bytes [rendered]
    [0] multi showTitle 28 bytes {4} [built] [1 error]
chunk    {5} showTotal.js (showTotal) 28 bytes [rendered]
    [0] multi showTotal 28 bytes {5} [built] [1 error]
chunk    {6} simple.js (simple) 28 bytes [rendered]
    [0] multi simple 28 bytes {6} [built] [1 error]
chunk    {7} sizer.js (sizer) 28 bytes [rendered]
    [0] multi sizer 28 bytes {7} [built] [1 error]
chunk    {8} stupid.js (stupid) 28 bytes [rendered]
    [0] multi stupid 28 bytes {8} [built] [1 error]
chunk    {9} styles.js (styles) 28 bytes [rendered]
    [0] multi styles 28 bytes {9} [built] [1 error]

All of them have the same error. I've pasted the backtrace for default.js as a reference:

ERROR in ./examples/default.js
Module build failed: Error: Couldn't find preset "latest" relative to directory "/Users/kenko/src"
    at /Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/Users/kenko/src/pagination/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/Users/kenko/src/pagination/node_modules/babel-loader/lib/index.js:46:20)
 @ multi default

From what I can tell, we want to include babel-preset-latest. However, that appears to be deprecated for babel-preset-env.

希望onChange可以增加pageSize参数

Pagination经常要搭配Table使用,最好可以和Table的onChange的方法使用起来尽可能的一致(第一个参数都能得到current和pageSize)。

Table onChange     Function(pagination, filters, sorter)

      Pagination  onChange	 Function(page)

-->Pagination  onChange	 Function(pagination)

Add Finnish locales

What problem does this feature solve?

Adds Finnish locales

What does the proposed API look like?

Proposed api will have locales for Finnish language.

'rc-pagination-jump-next' button won't show.

Hi, great component. I'm having issue trying to show the 3 dotted button that jumps to pages in between range. Like this example here http://react-component.github.io/pagination/examples/jumper.html

I don't want the jumper where you type in page, i want button that skips pages.
It doesn't show for me unless I put a very large number for "total" property. But I want to show if number of pages exceed limited space.

this is what i get https://gyazo.com/6236a3892a5b2ce4899dfc461e39a654

I want it to show like:

1 2 3 . . . 8 9

or something like that. Is it possible? I don't see parameters in documentation to make it show.

Pagination options limit

i need to limit the number of options in the pagination to show only 3 page, is it possible ?! because i can't find it in the doc
for example: if the current page is 5 i need to show only < |4| |5| |6| >

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.