+ {t('Pagination', 'Total')} {dTotal} {t('Pagination', 'items')}
+
+ );
+ }
+ })();
+
return (
-
+
{totalNode}
);
}
if (item === 'pages') {
+ const [prevNode, pageNode, nextNode] = [
+
{
+ changeActive(active - 1);
+ }, active === 1)}
+ className={getClassName(`${dPrefix}pagination__button`, {
+ 'is-disabled': active === 1,
+ [`${dPrefix}pagination__button--border`]: !(dCustomRender && dCustomRender.prev),
+ })}
+ style={{ marginLeft: index === 0 ? undefined : paginationSpace }}
+ title={t('Pagination', 'Previous page')}
+ >
+ {dCustomRender && dCustomRender.prev ? dCustomRender.prev : }
+ ,
+ (page: number) => {
+ if (dCustomRender && dCustomRender.page) {
+ return dCustomRender.page(page);
+ } else {
+ return
{page}
;
+ }
+ },
+
{
+ changeActive(active + 1);
+ }, active === lastPage)}
+ className={getClassName(`${dPrefix}pagination__button`, {
+ 'is-disabled': active === lastPage,
+ [`${dPrefix}pagination__button--border`]: !(dCustomRender && dCustomRender.next),
+ })}
+ title={t('Pagination', 'Next page')}
+ >
+ {dCustomRender && dCustomRender.next ? dCustomRender.next : }
+ ,
+ ];
+
let pages: (number | 'prev5' | 'next5')[] = [];
if (lastPage <= 7) {
@@ -370,16 +282,75 @@ export function DPagination(props: DPaginationProps): JSX.Element | null {
}
if (item === 'page-size') {
- return pageSizeNode;
+ const list = dPageSizeList.map((size) => ({
+ label: size.toString(),
+ value: size,
+ }));
+
+ return (
+
(dCustomRender && dCustomRender.pageSize ? dCustomRender.pageSize(item.value) : item.label)}
+ dCustomSelected={(select) => `${select.label}${t('Pagination', ' / Page')}`}
+ onModelChange={(value) => {
+ if (!isNull(value)) {
+ changePageSize(value);
+ }
+ }}
+ />
+ );
}
if (item === 'jump') {
+ const jumpNode = (() => {
+ const jumpInput = (
+
+ cloneHTMLElement(el, {
+ onKeyDown: (e) => {
+ el.props.onKeyDown?.(e);
+
+ if (e.code === 'Enter') {
+ e.preventDefault();
+
+ const val = Number(jumpValue);
+ if (!isNaN(val)) {
+ changeActive(val);
+ }
+ }
+ },
+ })
+ }
+ onModelChange={setJumpValue}
+ />
+ );
+
+ if (dCustomRender && dCustomRender.jump) {
+ return dCustomRender.jump(jumpInput);
+ } else {
+ return (
+ <>
+ {t('Pagination', 'Go')}
+ {jumpInput}
+ {t('Pagination', 'Page')}
+ >
+ );
+ }
+ })();
+
return (
-
+
{jumpNode}
);
diff --git a/packages/ui/src/styles/components/pagination.scss b/packages/ui/src/styles/components/pagination.scss
index 84abfaa0..f8817254 100644
--- a/packages/ui/src/styles/components/pagination.scss
+++ b/packages/ui/src/styles/components/pagination.scss
@@ -2,8 +2,6 @@
@include b(pagination) {
--#{$rd-prefix}pagination-size: 32px;
- --#{$rd-prefix}pagination-space: 16px;
- --#{$rd-prefix}pagination-button-space: 8px;
display: flex;
flex-wrap: wrap;
@@ -29,8 +27,6 @@
@include m(mini) {
--#{$rd-prefix}pagination-size: 24px;
- --#{$rd-prefix}pagination-space: 8px;
- --#{$rd-prefix}pagination-button-space: 2px;
@include polyfill-gap(4px, 2px);
@@ -66,7 +62,6 @@
position: relative;
display: inline-flex;
align-items: center;
- margin-right: var(--#{$rd-prefix}pagination-space);
vertical-align: top;
}
@@ -77,7 +72,6 @@
justify-content: center;
min-width: var(--#{$rd-prefix}pagination-size);
height: var(--#{$rd-prefix}pagination-size);
- margin-right: var(--#{$rd-prefix}pagination-button-space);
vertical-align: top;
cursor: pointer;
user-select: none;
@@ -152,7 +146,6 @@
@include e(page-size) {
@include overwrite-component(select) {
width: auto;
- margin-right: var(--#{$rd-prefix}pagination-space);
font-size: inherit;
}
}
@@ -161,7 +154,6 @@
position: relative;
display: inline-flex;
align-items: center;
- margin-right: var(--#{$rd-prefix}pagination-space);
vertical-align: top;
}