diff --git a/packages/ui/src/components/pagination/Pagination.tsx b/packages/ui/src/components/pagination/Pagination.tsx index 92d0ce03..288e6a25 100644 --- a/packages/ui/src/components/pagination/Pagination.tsx +++ b/packages/ui/src/components/pagination/Pagination.tsx @@ -87,139 +87,7 @@ export function DPagination(props: DPaginationProps): JSX.Element | null { const [jumpValue, setJumpValue] = useState(''); const lastPage = Math.max(Math.ceil(dTotal / pageSize), 1); - - const totalNode = (() => { - if (dCompose.includes('total')) { - const range: [number, number] = [Math.min((active - 1) * pageSize + 1, dTotal), Math.min(active * pageSize, dTotal)]; - if (dCustomRender && dCustomRender.total) { - return dCustomRender.total(range); - } else { - return ( -
- {t('Pagination', 'Total')} {dTotal} {t('Pagination', 'items')} -
- ); - } - } - return null; - })(); - - const [prevNode, pageNode, nextNode] = (() => { - let [prevNode, nextNode]: [React.ReactNode, React.ReactNode] = [null, null]; - if (dCompose.includes('pages')) { - prevNode = ( -
  • { - changeActive(active - 1); - }, active === 1)} - className={getClassName(`${dPrefix}pagination__button`, { - 'is-disabled': active === 1, - [`${dPrefix}pagination__button--border`]: !(dCustomRender && dCustomRender.prev), - })} - title={t('Pagination', 'Previous page')} - > - {dCustomRender && dCustomRender.prev ? dCustomRender.prev : } -
  • - ); - - nextNode = ( -
  • { - changeActive(active + 1); - }, active === lastPage)} - className={getClassName(`${dPrefix}pagination__button`, { - 'is-disabled': active === lastPage, - [`${dPrefix}pagination__button--border`]: !(dCustomRender && dCustomRender.next), - })} - style={{ marginRight: dCompose[dCompose.length - 1] === 'pages' ? 0 : `var(--${dPrefix}pagination-space)` }} - title={t('Pagination', 'Next page')} - > - {dCustomRender && dCustomRender.next ? dCustomRender.next : } -
  • - ); - } - return [ - prevNode, - (page: number) => { - if (dCustomRender && dCustomRender.page) { - return dCustomRender.page(page); - } else { - return
    {page}
    ; - } - }, - nextNode, - ]; - })(); - - const 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); - } - }} - /> - ); - })(); - - const jumpNode = (() => { - if (dCompose.includes('jump')) { - 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 null; - })(); + const paginationSpace = dMini ? 8 : 16; return (