import React from 'react'; import { Size } from '@pdfme-tables/common'; import { theme, Typography, Button } from 'antd'; import { LeftOutlined, RightOutlined, DoubleLeftOutlined, DoubleRightOutlined, } from '@ant-design/icons'; const { Text } = Typography; type UnitButtonProps = { type: 'left' | 'right' | 'doubleLeft' | 'doubleRight'; onClick: () => void; disabled: boolean; textStyle: { color: string; fontSize: number; margin: number }; }; const icons = { left: LeftOutlined, right: RightOutlined, doubleLeft: DoubleLeftOutlined, doubleRight: DoubleRightOutlined, }; const UnitButton: React.FC = ({ type, onClick, disabled, textStyle }) => { const Icon = icons[type]; return ( ); }; type Props = { size: Size; unitCursor: number; unitNum: number; setUnitCursor: (page: number) => void; }; const UnitPager = ({ size, unitCursor, unitNum, setUnitCursor }: Props) => { if (unitNum <= 1) return null; const { token } = theme.useToken(); const buttonWrapStyle: React.CSSProperties = { pointerEvents: 'initial', position: 'sticky', zIndex: 1, display: 'flex', alignItems: 'center', boxSizing: 'border-box', height: 40, padding: token.paddingSM, borderRadius: token.borderRadius, backgroundColor: token.colorBgMask, }; const textStyle = { color: token.colorWhite, fontSize: token.fontSize, margin: token.marginXS, }; return (
{unitCursor > 0 && (
setUnitCursor(0)} disabled={unitCursor <= 0} textStyle={textStyle} /> setUnitCursor(unitCursor - 1)} disabled={unitCursor <= 0} textStyle={textStyle} /> {unitCursor + 1}/{unitNum}
)} {unitCursor + 1 < unitNum && (
{unitCursor + 1}/{unitNum} setUnitCursor(unitCursor + 1)} disabled={unitCursor + 1 >= unitNum} textStyle={textStyle} /> setUnitCursor(unitNum - 1)} disabled={unitCursor + 1 >= unitNum} textStyle={textStyle} />
)}
); }; export default UnitPager;