Skip to content

Commit 66b8ecf

Browse files
committed
fix: pageSizeOptions default value
1 parent 8a8592a commit 66b8ecf

File tree

3 files changed

+42
-62
lines changed

3 files changed

+42
-62
lines changed

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,34 @@ ReactDOM.render(<Pagination />, container);
4848

4949
## API
5050

51-
| Parameter | Description | Type | Default |
52-
| ------------------- | ----------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------- |
53-
| disabled | disable pagination | Bool | - |
54-
| defaultCurrent | uncontrolled current page | Number | 1 |
55-
| current | current page | Number | undefined |
56-
| total | items total count | Number | 0 |
57-
| defaultPageSize | default items per page | Number | 10 |
58-
| pageSize | items per page | Number | 10 |
59-
| onChange | page change callback | Function(current, pageSize) | - |
60-
| showSizeChanger | show pageSize changer | Bool | `false` when total less then `totalBoundaryShowSizeChanger`, `true` when otherwise |
61-
| totalBoundaryShowSizeChanger | when total larger than it, `showSizeChanger` will be true | number | 50 |
62-
| pageSizeOptions | specify the sizeChanger selections | Array<String> | ['10', '20', '30', '40'] |
63-
| onShowSizeChange | pageSize change callback | Function(current, size) | - |
64-
| hideOnSinglePage | hide on single page | Bool | false |
65-
| showPrevNextJumpers | show jump-prev, jump-next | Bool | true |
66-
| showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} |
67-
| showTotal | show total records and range | Function(total, [from, to]) | - |
68-
| className | className of pagination | String | - |
69-
| simple | when set, show simple pager | Object | null |
70-
| locale | to set l10n config | Object | [zh_CN](https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js) |
71-
| style | the style of pagination | Object | {} |
72-
| showLessItems | show less page items | Bool | false |
73-
| showTitle | show page items title | Bool | true |
74-
| itemRender | custom page item renderer | Function(current, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next', element): React.ReactNode | `(current, type, element) => element` |
75-
| prevIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
76-
| nextIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
77-
| jumpPrevIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
78-
| jumpNextIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
51+
| Parameter | Description | Type | Default |
52+
| ---------------------------- | --------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------- |
53+
| disabled | disable pagination | Bool | - |
54+
| defaultCurrent | uncontrolled current page | Number | 1 |
55+
| current | current page | Number | undefined |
56+
| total | items total count | Number | 0 |
57+
| defaultPageSize | default items per page | Number | 10 |
58+
| pageSize | items per page | Number | 10 |
59+
| onChange | page change callback | Function(current, pageSize) | - |
60+
| showSizeChanger | show pageSize changer | Bool | `false` when total less then `totalBoundaryShowSizeChanger`, `true` when otherwise |
61+
| totalBoundaryShowSizeChanger | when total larger than it, `showSizeChanger` will be true | number | 50 |
62+
| pageSizeOptions | specify the sizeChanger selections | Array<String> | ['10', '25', '50', '100'] |
63+
| onShowSizeChange | pageSize change callback | Function(current, size) | - |
64+
| hideOnSinglePage | hide on single page | Bool | false |
65+
| showPrevNextJumpers | show jump-prev, jump-next | Bool | true |
66+
| showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} |
67+
| showTotal | show total records and range | Function(total, [from, to]) | - |
68+
| className | className of pagination | String | - |
69+
| simple | when set, show simple pager | Object | null |
70+
| locale | to set l10n config | Object | [zh_CN](https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js) |
71+
| style | the style of pagination | Object | {} |
72+
| showLessItems | show less page items | Bool | false |
73+
| showTitle | show page items title | Bool | true |
74+
| itemRender | custom page item renderer | Function(current, type: 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next', element): React.ReactNode | `(current, type, element) => element` |
75+
| prevIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
76+
| nextIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
77+
| jumpPrevIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
78+
| jumpNextIcon | specifict the default previous icon | ReactNode \| (props: PaginationProps) => ReactNode | |
7979

8080
## License
8181

src/Options.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import KEYCODE from './KeyCode';
44

55
class Options extends React.Component {
66
static defaultProps = {
7-
pageSizeOptions: ['10', '20', '50', '100'],
7+
pageSizeOptions: ['10', '25', '50', '100'],
88
};
99

1010
state = {
@@ -17,19 +17,19 @@ class Options extends React.Component {
1717
return !goInputText || isNaN(goInputText) ? current : Number(goInputText);
1818
}
1919

20-
buildOptionText = value => `${value} ${this.props.locale.items_per_page}`;
20+
buildOptionText = (value) => `${value} ${this.props.locale.items_per_page}`;
2121

22-
changeSize = value => {
22+
changeSize = (value) => {
2323
this.props.changeSize(Number(value));
2424
};
2525

26-
handleChange = e => {
26+
handleChange = (e) => {
2727
this.setState({
2828
goInputText: e.target.value,
2929
});
3030
};
3131

32-
handleBlur = e => {
32+
handleBlur = (e) => {
3333
const { goButton, quickGo, rootPrefixCls } = this.props;
3434
if (goButton) {
3535
return;
@@ -44,7 +44,7 @@ class Options extends React.Component {
4444
quickGo(this.getValidValue());
4545
};
4646

47-
go = e => {
47+
go = (e) => {
4848
const { goInputText } = this.state;
4949
if (goInputText === '') {
5050
return;
@@ -99,7 +99,7 @@ class Options extends React.Component {
9999
dropdownMatchSelectWidth={false}
100100
value={(pageSize || pageSizeOptions[0]).toString()}
101101
onChange={this.changeSize}
102-
getPopupContainer={triggerNode => triggerNode.parentNode}
102+
getPopupContainer={(triggerNode) => triggerNode.parentNode}
103103
>
104104
{options}
105105
</Select>

tests/index.test.js

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ describe('Other props', () => {
213213
});
214214

215215
describe('hideOnSinglePage props', () => {
216-
const itemRender = current => <a href={`#${current}`}>{current}</a>;
216+
const itemRender = (current) => <a href={`#${current}`}>{current}</a>;
217217

218218
it('should hide pager if hideOnSinglePage equals true', () => {
219219
const wrapper = mount(
@@ -261,18 +261,8 @@ describe('Other props', () => {
261261
expect(wrapper.find('.rc-pagination-disabled').exists()).toBe(true);
262262
expect(wrapper.find('input').exists()).toBe(true);
263263
expect(wrapper.find(Select).props().disabled).toBe(true);
264-
expect(
265-
wrapper
266-
.find('input')
267-
.at(0)
268-
.getDOMNode().disabled,
269-
).toBe(true);
270-
expect(
271-
wrapper
272-
.find('button')
273-
.at(0)
274-
.getDOMNode().disabled,
275-
).toBe(true);
264+
expect(wrapper.find('input').at(0).getDOMNode().disabled).toBe(true);
265+
expect(wrapper.find('button').at(0).getDOMNode().disabled).toBe(true);
276266
});
277267
});
278268

@@ -323,7 +313,7 @@ describe('current value on onShowSizeChange when total is 0', () => {
323313
input.simulate('keyDown', { key: 'Enter', keyCode: 13, which: 13 });
324314
expect(onShowSizeChange).toHaveBeenLastCalledWith(
325315
wrapper.state().current,
326-
20,
316+
25,
327317
);
328318
});
329319

@@ -339,17 +329,11 @@ describe('current value on onShowSizeChange when total is 0', () => {
339329

340330
it('size changer show logic', () => {
341331
const wrapper1 = mount(
342-
<Pagination
343-
selectComponentClass={Select}
344-
total={50}
345-
/>,
332+
<Pagination selectComponentClass={Select} total={50} />,
346333
);
347334
expect(wrapper1.exists('.rc-pagination-options-size-changer')).toBe(false);
348335
const wrapper2 = mount(
349-
<Pagination
350-
selectComponentClass={Select}
351-
total={51}
352-
/>,
336+
<Pagination selectComponentClass={Select} total={51} />,
353337
);
354338
expect(wrapper2.exists('.rc-pagination-options-size-changer')).toBe(true);
355339
const wrapper3 = mount(
@@ -361,11 +345,7 @@ describe('current value on onShowSizeChange when total is 0', () => {
361345
);
362346
expect(wrapper3.exists('.rc-pagination-options-size-changer')).toBe(false);
363347
const wrapper4 = mount(
364-
<Pagination
365-
selectComponentClass={Select}
366-
showSizeChanger
367-
total={50}
368-
/>,
348+
<Pagination selectComponentClass={Select} showSizeChanger total={50} />,
369349
);
370350
expect(wrapper4.exists('.rc-pagination-options-size-changer')).toBe(true);
371351
});

0 commit comments

Comments
 (0)