Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/examples/jumper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ const App = () => (
total={450}
disabled
/>
<h3>仅输入数字</h3>
<PaginationWithSizeChanger
showQuickJumper={{ inputType: 'number' }}
showSizeChanger
defaultPageSize={20}
defaultCurrent={5}
onShowSizeChange={onShowSizeChange}
onChange={onChange}
total={450}
/>
<h3>单页默认隐藏</h3>
<PaginationWithSizeChanger
showQuickJumper
Expand Down
11 changes: 10 additions & 1 deletion docs/examples/jumperWithGoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class App extends React.Component {
<p> customize node </p>
<PaginationWithSizeChanger
showSizeChanger
showQuickJumper={{ goButton: <button type="button">确定</button> }}
showQuickJumper={{
goButton: <button type="button">确定</button>,
}}
defaultPageSize={20}
defaultCurrent={5}
onShowSizeChange={this.onShowSizeChange}
Expand All @@ -36,6 +38,13 @@ class App extends React.Component {
defaultCurrent={1}
total={50}
/>
<p> input only numbers</p>
<Pagination
simple
showQuickJumper={{ goButton: true, inputType: 'number' }}
defaultCurrent={1}
total={50}
/>
</>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface OptionsProps {
buildOptionText?: (value: number | string) => string;
showSizeChanger: boolean;
sizeChangerRender?: SizeChangerRender;
inputType?: 'text' | 'number';
}

const defaultPageSizeOptions = [10, 20, 50, 100];
Expand All @@ -44,6 +45,7 @@ const Options: React.FC<OptionsProps> = (props) => {
buildOptionText,
showSizeChanger,
sizeChangerRender,
inputType = 'text',
} = props;

const [goInputText, setGoInputText] = React.useState('');
Expand Down Expand Up @@ -158,7 +160,7 @@ const Options: React.FC<OptionsProps> = (props) => {
{locale.jump_to}
<input
disabled={disabled}
type="text"
type={inputType}
value={goInputText}
onChange={handleChange}
onKeyUp={go}
Expand Down
2 changes: 2 additions & 0 deletions src/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
const prevPage = current - 1 > 0 ? current - 1 : 0;
const nextPage = current + 1 < allPages ? current + 1 : allPages;
const goButton = showQuickJumper && (showQuickJumper as any).goButton;
const inputType = showQuickJumper && (showQuickJumper as any).inputType;

// ================== Simple ==================
// FIXME: ts type
Expand Down Expand Up @@ -596,6 +597,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
selectPrefixCls={selectPrefixCls}
changeSize={changePageSize}
pageSize={pageSize}
inputType={inputType}
pageSizeOptions={pageSizeOptions}
quickGo={shouldDisplayQuickJumper ? handleChange : null}
goButton={gotoButton}
Expand Down
7 changes: 6 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export interface PaginationLocale {

type SemanticName = 'item';

type QuickJumperOptions = {
goButton?: boolean | React.ReactNode;
inputType?: 'text' | 'number';
};

export interface PaginationData {
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
classNames?: Partial<Record<SemanticName, string>>;
Expand All @@ -41,7 +46,7 @@ export interface PaginationData {
sizeChangerRender?: SizeChangerRender;
showLessItems: boolean;
showPrevNextJumpers: boolean;
showQuickJumper: boolean | object;
showQuickJumper: boolean | QuickJumperOptions;
showTitle: boolean;
simple: boolean | { readOnly?: boolean };
disabled: boolean;
Expand Down
259 changes: 259 additions & 0 deletions tests/__snapshots__/demo.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,191 @@ exports[`Example jumper 1`] = `
</div>
</li>
</ul>
<h3>
仅输入数字
</h3>
<ul
class="rc-pagination"
>
<li
aria-disabled="false"
class="rc-pagination-prev"
tabindex="0"
title="上一页"
>
<button
aria-label="prev page"
class="rc-pagination-item-link"
type="button"
/>
</li>
<li
class="rc-pagination-item rc-pagination-item-1"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="rc-pagination-jump-prev"
tabindex="0"
title="向前 5 页"
>
<button
aria-label="prev page"
class="rc-pagination-item-link"
type="button"
/>
</li>
<li
class="rc-pagination-item rc-pagination-item-3 rc-pagination-item-after-jump-prev"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="rc-pagination-item rc-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="rc-pagination-item rc-pagination-item-5 rc-pagination-item-active"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
class="rc-pagination-item rc-pagination-item-6"
tabindex="0"
title="6"
>
<a
rel="nofollow"
>
6
</a>
</li>
<li
class="rc-pagination-item rc-pagination-item-7 rc-pagination-item-before-jump-next"
tabindex="0"
title="7"
>
<a
rel="nofollow"
>
7
</a>
</li>
<li
class="rc-pagination-jump-next"
tabindex="0"
title="向后 5 页"
>
<button
aria-label="next page"
class="rc-pagination-item-link"
type="button"
/>
</li>
<li
class="rc-pagination-item rc-pagination-item-23"
tabindex="0"
title="23"
>
<a
rel="nofollow"
>
23
</a>
</li>
<li
aria-disabled="false"
class="rc-pagination-next"
tabindex="0"
title="下一页"
>
<button
aria-label="next page"
class="rc-pagination-item-link"
type="button"
/>
</li>
<li
class="rc-pagination-options"
>
<div
aria-label="页码"
class="rc-select rc-pagination-options-size-changer rc-select-single"
>
<div
class="rc-select-selector"
>
<span
class="rc-select-selection-wrap"
>
<span
class="rc-select-selection-search"
>
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="页码"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="rc-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
readonly=""
role="combobox"
style="opacity: 0;"
type="search"
unselectable="on"
value=""
/>
</span>
<span
class="rc-select-selection-item"
title="20 条/页"
>
20 条/页
</span>
</span>
</div>
</div>
<div
class="rc-pagination-options-quick-jumper"
>
跳至
<input
aria-label="页"
type="number"
value=""
/>
</div>
</li>
</ul>
<h3>
单页默认隐藏
</h3>
Expand Down Expand Up @@ -2322,6 +2507,80 @@ exports[`Example jumperWithGoButton 1`] = `
</div>
</li>
</ul>
<p>
input only numbers
</p>
<ul
class="rc-pagination rc-pagination-simple"
>
<li
aria-disabled="true"
class="rc-pagination-prev rc-pagination-disabled"
title="上一页"
>
<button
aria-label="prev page"
class="rc-pagination-item-link"
disabled=""
type="button"
/>
</li>
<li
class="rc-pagination-simple-pager"
title="1/5"
>
<input
aria-label="跳至"
size="3"
type="text"
value="1"
/>
<span
class="rc-pagination-slash"
>
/
</span>
5
</li>
<li
aria-disabled="false"
class="rc-pagination-next"
title="下一页"
>
<button
aria-label="next page"
class="rc-pagination-item-link"
type="button"
/>
</li>
<li
class="rc-pagination-options"
>
<div
class="rc-pagination-options-quick-jumper"
>
跳至
<input
aria-label="页"
type="number"
value=""
/>
<span>
<li
class="rc-pagination-simple-pager"
title="跳至1/5"
>
<button
type="button"
>
确定
</button>
</li>
</span>
</div>
</li>
</ul>
</div>
`;

Expand Down
Loading