feat(Pagination): simple prop extend to object & add align prop (#49562)

* feat(pagination): simple prop extend to object

* feat(pagination): add align prop

* Update components/pagination/Pagination.tsx

Co-authored-by: afc163 <afc163@gmail.com>
Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>

* refactor: remove useless types

* refactor(List): align prop

---------

Signed-off-by: ice <49827327+coding-ice@users.noreply.github.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
ice 2024-06-25 21:27:11 +08:00 committed by GitHub
parent ee40b3d44b
commit e76e386966
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 980 additions and 94 deletions

View File

@ -2172,10 +2172,10 @@ Array [
</div>
</div>
<div
class="ant-list-pagination ant-list-pagination-align-center"
class="ant-list-pagination"
>
<ul
class="ant-pagination"
class="ant-pagination ant-pagination-center"
>
<li
aria-disabled="true"
@ -3245,7 +3245,7 @@ exports[`renders components/list/demo/vertical.tsx extend context correctly 1`]
</div>
</div>
<div
class="ant-list-pagination ant-list-pagination-align-end"
class="ant-list-pagination"
>
<ul
class="ant-pagination"
@ -3424,34 +3424,3 @@ exports[`renders components/list/demo/vertical.tsx extend context correctly 1`]
`;
exports[`renders components/list/demo/vertical.tsx extend context correctly 2`] = `[]`;
exports[`renders components/list/demo/virtual-list.tsx extend context correctly 1`] = `
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="rc-virtual-list"
style="position: relative;"
>
<div
class="rc-virtual-list-holder"
style="height: 400px; overflow-y: auto;"
>
<div>
<div
class="rc-virtual-list-holder-inner"
style="display: flex; flex-direction: column;"
/>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@ -2165,10 +2165,10 @@ Array [
</div>
</div>
<div
class="ant-list-pagination ant-list-pagination-align-center"
class="ant-list-pagination"
>
<ul
class="ant-pagination"
class="ant-pagination ant-pagination-center"
>
<li
aria-disabled="true"
@ -3225,7 +3225,7 @@ exports[`renders components/list/demo/vertical.tsx correctly 1`] = `
</div>
</div>
<div
class="ant-list-pagination ant-list-pagination-align-end"
class="ant-list-pagination"
>
<ul
class="ant-pagination"
@ -3402,34 +3402,3 @@ exports[`renders components/list/demo/vertical.tsx correctly 1`] = `
</div>
</div>
`;
exports[`renders components/list/demo/virtual-list.tsx correctly 1`] = `
<div
class="ant-list ant-list-split"
>
<div
class="ant-spin-nested-loading"
>
<div
class="ant-spin-container"
>
<div
class="rc-virtual-list"
style="position:relative"
>
<div
class="rc-virtual-list-holder"
style="height:400px;overflow-y:auto;overflow-anchor:none"
>
<div>
<div
class="rc-virtual-list-holder-inner"
style="display:flex;flex-direction:column"
/>
</div>
</div>
</div>
</div>
</div>
</div>
`;

View File

@ -120,7 +120,7 @@ exports[`List.pagination renders pagination correctly 1`] = `
</div>
</div>
<div
class="ant-list-pagination ant-list-pagination-align-end"
class="ant-list-pagination"
>
<ul
class="ant-pagination my-page"

View File

@ -201,20 +201,15 @@ function List<T>({
if (paginationProps.current > largestPage) {
paginationProps.current = largestPage;
}
const paginationContent = pagination ? (
<div
className={classNames(
`${prefixCls}-pagination`,
`${prefixCls}-pagination-align-${paginationProps?.align ?? 'end'}`,
)}
>
const paginationContent = pagination && (
<div className={classNames(`${prefixCls}-pagination`)}>
<Pagination
{...paginationProps}
onChange={onPaginationChange}
onShowSizeChange={onPaginationShowSizeChange}
/>
</div>
) : null;
);
let splitDataSource = [...dataSource];
if (pagination) {

View File

@ -183,13 +183,6 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
descriptionFontSize,
} = token;
const alignCls: any = {};
['start', 'center', 'end'].forEach((item) => {
alignCls[`&-align-${item}`] = {
textAlign: item,
};
});
return {
[`${componentCls}`]: {
...resetComponent(token),
@ -210,8 +203,6 @@ const genBaseStyle: GenerateStyle<ListToken> = (token) => {
[`${componentCls}-pagination`]: {
marginBlockStart: marginLG,
...alignCls,
// https://github.com/ant-design/ant-design/issues/20037
[`${antCls}-pagination-options`]: {
textAlign: 'start',

View File

@ -28,17 +28,15 @@ export interface PaginationProps extends RcPaginationProps {
export type PaginationPosition = 'top' | 'bottom' | 'both';
export type PaginationAlign = 'start' | 'center' | 'end';
export interface PaginationConfig extends Omit<PaginationProps, 'rootClassName'> {
position?: PaginationPosition;
align?: PaginationAlign;
}
export type { PaginationLocale };
const Pagination: React.FC<PaginationProps> = (props) => {
const {
align,
prefixCls: customizePrefixCls,
selectPrefixCls: customizeSelectPrefixCls,
className,
@ -115,6 +113,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
const extendedClassName = classNames(
{
[`${prefixCls}-${align}`]: !!align,
[`${prefixCls}-mini`]: isSmall,
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-bordered`]: token.wireframe,

View File

@ -1,5 +1,383 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders components/pagination/demo/align.tsx extend context correctly 1`] = `
Array [
<ul
class="ant-pagination ant-pagination-start"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-center"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-end"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
]
`;
exports[`renders components/pagination/demo/align.tsx extend context correctly 2`] = `[]`;
exports[`renders components/pagination/demo/all.tsx extend context correctly 1`] = `
<ul
class="ant-pagination"
@ -4298,6 +4676,87 @@ Array [
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-simple"
>
<li
aria-disabled="false"
class="ant-pagination-prev"
tabindex="0"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-simple-pager"
title="2/5"
>
2
<span
class="ant-pagination-slash"
>
/
</span>
5
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-simple ant-pagination-disabled"
>

View File

@ -1,5 +1,381 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders components/pagination/demo/align.tsx correctly 1`] = `
Array [
<ul
class="ant-pagination ant-pagination-start"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-center"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-end"
>
<li
aria-disabled="true"
class="ant-pagination-prev ant-pagination-disabled"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
disabled=""
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active"
tabindex="0"
title="1"
>
<a
rel="nofollow"
>
1
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-2"
tabindex="0"
title="2"
>
<a
rel="nofollow"
>
2
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-3"
tabindex="0"
title="3"
>
<a
rel="nofollow"
>
3
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-4"
tabindex="0"
title="4"
>
<a
rel="nofollow"
>
4
</a>
</li>
<li
class="ant-pagination-item ant-pagination-item-5"
tabindex="0"
title="5"
>
<a
rel="nofollow"
>
5
</a>
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
]
`;
exports[`renders components/pagination/demo/all.tsx correctly 1`] = `
<ul
class="ant-pagination"
@ -3147,6 +3523,87 @@ Array [
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-simple"
>
<li
aria-disabled="false"
class="ant-pagination-prev"
tabindex="0"
title="Previous Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="left"
class="anticon anticon-left"
role="img"
>
<svg
aria-hidden="true"
data-icon="left"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"
/>
</svg>
</span>
</button>
</li>
<li
class="ant-pagination-simple-pager"
title="2/5"
>
2
<span
class="ant-pagination-slash"
>
/
</span>
5
</li>
<li
aria-disabled="false"
class="ant-pagination-next"
tabindex="0"
title="Next Page"
>
<button
class="ant-pagination-item-link"
tabindex="-1"
type="button"
>
<span
aria-label="right"
class="anticon anticon-right"
role="img"
>
<svg
aria-hidden="true"
data-icon="right"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"
/>
</svg>
</span>
</button>
</li>
</ul>,
<br />,
<ul
class="ant-pagination ant-pagination-simple ant-pagination-disabled"
>

View File

@ -89,4 +89,19 @@ describe('Pagination', () => {
expect(container.querySelectorAll('.ant-select-lg').length).toBe(0);
});
});
describe('should support align props', () => {
it('should support align to start', () => {
const { container } = render(<Pagination align="start" />);
expect(container.querySelector('.ant-pagination-start')).toBeTruthy();
});
it('should support align to center', () => {
const { container } = render(<Pagination align="center" />);
expect(container.querySelector('.ant-pagination-center')).toBeTruthy();
});
it('should support align to end', () => {
const { container } = render(<Pagination align="end" />);
expect(container.querySelector('.ant-pagination-end')).toBeTruthy();
});
});
});

View File

@ -0,0 +1,14 @@
import React from 'react';
import { Pagination } from 'antd';
const App: React.FC = () => (
<>
<Pagination align="start" defaultCurrent={1} total={50} />
<br />
<Pagination align="center" defaultCurrent={1} total={50} />
<br />
<Pagination align="end" defaultCurrent={1} total={50} />
</>
);
export default App;

View File

@ -5,6 +5,8 @@ const App: React.FC = () => (
<>
<Pagination simple defaultCurrent={2} total={50} />
<br />
<Pagination simple={{ readOnly: true }} defaultCurrent={2} total={50} />
<br />
<Pagination disabled simple defaultCurrent={2} total={50} />
</>
);

View File

@ -16,6 +16,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*WM86SrBC8TsAAA
<!-- prettier-ignore -->
<code src="./demo/basic.tsx">Basic</code>
<code src="./demo/align.tsx">Align</code>
<code src="./demo/more.tsx">More</code>
<code src="./demo/changer.tsx">Changer</code>
<code src="./demo/jump.tsx">Jumper</code>
@ -38,6 +39,7 @@ Common props ref[Common props](/docs/react/common-props)
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| align | Align | start \| center \| end | - | |
| current | Current page number | number | - | |
| defaultCurrent | Default initial page number | number | 1 | |
| defaultPageSize | Default number of data items per page | number | 10 | |
@ -52,7 +54,7 @@ Common props ref[Common props](/docs/react/common-props)
| showSizeChanger | Determine whether to show `pageSize` select, it will be true when `total > 50` | boolean | - | |
| showTitle | Show page item's title | boolean | true | |
| showTotal | To display the total number and range | function(total, range) | - | |
| simple | Whether to use simple mode | boolean | - | |
| simple | Whether to use simple mode | boolean \| { readOnly?: boolean } | - | |
| size | Specify the size of `Pagination`, can be set to `small` | `default` \| `small` | `default` | |
| total | Total number of data items | number | 0 | |
| onChange | Called when the page number or `pageSize` is changed, and it takes the resulting page number and pageSize as its arguments | function(page, pageSize) | - | |

View File

@ -17,6 +17,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*WM86SrBC8TsAAA
<!-- prettier-ignore -->
<code src="./demo/basic.tsx">基本</code>
<code src="./demo/align.tsx">方向</code>
<code src="./demo/more.tsx">更多</code>
<code src="./demo/changer.tsx">改变</code>
<code src="./demo/jump.tsx">跳转</code>
@ -39,6 +40,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*WM86SrBC8TsAAA
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| align | 对齐方式 | start \| center \| end | - | |
| current | 当前页数 | number | - | |
| defaultCurrent | 默认的当前页数 | number | 1 | |
| defaultPageSize | 默认的每页条数 | number | 10 | |
@ -53,7 +55,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*WM86SrBC8TsAAA
| showSizeChanger | 是否展示 `pageSize` 切换器,当 `total` 大于 50 时默认为 true | boolean | - | |
| showTitle | 是否显示原生 tooltip 页码提示 | boolean | true | |
| showTotal | 用于显示数据总量和当前数据顺序 | function(total, range) | - | |
| simple | 当添加该属性时,显示为简单分页 | boolean | - | |
| simple | 当添加该属性时,显示为简单分页 | boolean \| { readOnly?: boolean } | - | |
| size | 当为 `small` 时,是小尺寸分页 | `default` \| `small` | `default` | |
| total | 数据总数 | number | 0 | |
| onChange | 页码或 `pageSize` 改变的回调,参数是改变后的页码及每页条数 | function(page, pageSize) | - | |

View File

@ -298,7 +298,6 @@ const genPaginationSimpleStyle: GenerateStyle<PaginationToken, CSSObject> = (tok
input: {
boxSizing: 'border-box',
height: '100%',
marginInlineEnd: token.marginXS,
padding: `0 ${unit(token.paginationItemPaddingInline)}`,
textAlign: 'center',
backgroundColor: token.itemInputBg,
@ -570,6 +569,19 @@ const genPaginationStyle: GenerateStyle<PaginationToken, CSSObject> = (token) =>
return {
[componentCls]: {
...resetComponent(token),
display: 'flex',
'&-start': {
justifyContent: 'start',
},
'&-center': {
justifyContent: 'center',
},
'&-end': {
justifyContent: 'end',
},
'ul, ol': {
margin: 0,
@ -684,7 +696,7 @@ export const prepareToken = (token: Parameters<GenStyleFn<'Pagination'>>[0]) =>
paginationMiniQuickJumperInputWidth: token.calc(token.controlHeightLG).mul(1.1).equal(),
paginationItemPaddingInline: token.calc(token.marginXXS).mul(1.5).equal(),
paginationEllipsisLetterSpacing: token.calc(token.marginXXS).div(2).equal(),
paginationSlashMarginInlineStart: token.marginXXS,
paginationSlashMarginInlineStart: token.marginSM,
paginationSlashMarginInlineEnd: token.marginSM,
paginationEllipsisTextIndent: '0.13em', // magic for ui experience
},

View File

@ -127,7 +127,7 @@
"rc-menu": "~9.14.1",
"rc-motion": "^2.9.2",
"rc-notification": "~5.6.0",
"rc-pagination": "~4.0.4",
"rc-pagination": "~4.2.0",
"rc-picker": "~4.6.4",
"rc-progress": "~4.0.0",
"rc-rate": "~2.13.0",