2019-01-12 03:33:27 +00:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-08-31 08:53:19 +00:00
|
|
|
import classNames from '../_util/classNames';
|
2020-07-24 06:23:14 +00:00
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
2018-03-05 11:06:44 +00:00
|
|
|
|
2017-11-07 03:57:16 +00:00
|
|
|
export default {
|
2018-05-26 14:47:19 +00:00
|
|
|
name: 'Pager',
|
2020-07-24 06:23:14 +00:00
|
|
|
mixins: [BaseMixin],
|
2020-07-14 13:51:48 +00:00
|
|
|
inheritAttrs: false,
|
2017-11-07 03:57:16 +00:00
|
|
|
props: {
|
2018-03-05 11:06:44 +00:00
|
|
|
rootPrefixCls: PropTypes.string,
|
|
|
|
page: PropTypes.number,
|
|
|
|
active: PropTypes.bool,
|
|
|
|
last: PropTypes.bool,
|
|
|
|
locale: PropTypes.object,
|
|
|
|
showTitle: PropTypes.bool,
|
2017-12-20 02:56:21 +00:00
|
|
|
itemRender: {
|
|
|
|
type: Function,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2017-11-07 03:57:16 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
handleClick() {
|
2020-07-24 06:23:14 +00:00
|
|
|
this.__emit('click', this.page);
|
2017-11-07 03:57:16 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
handleKeyPress(event) {
|
2020-07-24 06:23:14 +00:00
|
|
|
this.__emit('keypress', event, this.handleClick, this.page);
|
2017-11-07 03:57:16 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2020-07-14 13:51:48 +00:00
|
|
|
const { class: _cls, style } = this.$attrs;
|
2020-03-07 11:45:13 +00:00
|
|
|
const props = this.$props;
|
|
|
|
const prefixCls = `${props.rootPrefixCls}-item`;
|
2020-07-14 13:51:48 +00:00
|
|
|
const cls = classNames(
|
|
|
|
prefixCls,
|
|
|
|
`${prefixCls}-${props.page}`,
|
|
|
|
{
|
|
|
|
[`${prefixCls}-active`]: props.active,
|
|
|
|
[`${prefixCls}-disabled`]: !props.page,
|
|
|
|
},
|
|
|
|
_cls,
|
|
|
|
);
|
2019-01-01 13:19:50 +00:00
|
|
|
|
2017-12-20 02:56:21 +00:00
|
|
|
return (
|
|
|
|
<li
|
|
|
|
onClick={this.handleClick}
|
|
|
|
onKeypress={this.handleKeyPress}
|
2018-03-05 11:06:44 +00:00
|
|
|
title={this.showTitle ? this.page : null}
|
2020-07-17 09:13:30 +00:00
|
|
|
tabindex="0"
|
2020-07-14 13:51:48 +00:00
|
|
|
class={cls}
|
|
|
|
style={style}
|
2018-03-05 11:06:44 +00:00
|
|
|
>
|
2020-08-17 10:02:28 +00:00
|
|
|
{this.itemRender({ page: this.page, type: 'page', originalElement: <a>{this.page}</a> })}
|
2017-12-20 02:56:21 +00:00
|
|
|
</li>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2017-12-20 02:56:21 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|