23 lines
937 B
JavaScript
23 lines
937 B
JavaScript
import classNames from 'classnames';
|
|
import React from 'react';
|
|
import Style from "./index.module.less";
|
|
const Pager = (props) => {
|
|
const { rootPrefixCls, page, active, className, showTitle, onClick, onKeyPress, itemRender, } = props;
|
|
const prefixCls = `${rootPrefixCls}-item`;
|
|
const cls = classNames(prefixCls, Style[`${prefixCls}`], {
|
|
[Style[`${prefixCls}-active`]]: active,
|
|
[Style[`${prefixCls}-disabled`]]: !page,
|
|
}, className);
|
|
const handleClick = () => {
|
|
onClick && onClick(page);
|
|
};
|
|
const handleKeyPress = (e) => {
|
|
onKeyPress && onKeyPress(e, onClick, page);
|
|
};
|
|
const pager = itemRender && itemRender(page, 'page', <a rel="nofollow">{page}</a>);
|
|
return pager ? (<li title={showTitle ? String(page) : undefined} className={cls} onClick={handleClick} onKeyDown={handleKeyPress} tabIndex={0}>
|
|
{pager}
|
|
</li>) : null;
|
|
};
|
|
export default Pager;
|