Pager.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { createVNode as _createVNode } from "vue";
  2. import PropTypes from '../_util/vue-types';
  3. import classNames from '../_util/classNames';
  4. import { defineComponent } from 'vue';
  5. export default defineComponent({
  6. compatConfig: {
  7. MODE: 3
  8. },
  9. name: 'Pager',
  10. inheritAttrs: false,
  11. props: {
  12. rootPrefixCls: String,
  13. page: Number,
  14. active: {
  15. type: Boolean,
  16. default: undefined
  17. },
  18. last: {
  19. type: Boolean,
  20. default: undefined
  21. },
  22. locale: PropTypes.object,
  23. showTitle: {
  24. type: Boolean,
  25. default: undefined
  26. },
  27. itemRender: {
  28. type: Function,
  29. default: () => {}
  30. },
  31. onClick: {
  32. type: Function
  33. },
  34. onKeypress: {
  35. type: Function
  36. }
  37. },
  38. eimt: ['click', 'keypress'],
  39. setup(props, _ref) {
  40. let {
  41. emit,
  42. attrs
  43. } = _ref;
  44. const handleClick = () => {
  45. emit('click', props.page);
  46. };
  47. const handleKeyPress = event => {
  48. emit('keypress', event, handleClick, props.page);
  49. };
  50. return () => {
  51. const {
  52. showTitle,
  53. page,
  54. itemRender
  55. } = props;
  56. const {
  57. class: _cls,
  58. style
  59. } = attrs;
  60. const prefixCls = `${props.rootPrefixCls}-item`;
  61. const cls = classNames(prefixCls, `${prefixCls}-${props.page}`, {
  62. [`${prefixCls}-active`]: props.active,
  63. [`${prefixCls}-disabled`]: !props.page
  64. }, _cls);
  65. return _createVNode("li", {
  66. "onClick": handleClick,
  67. "onKeypress": handleKeyPress,
  68. "title": showTitle ? String(page) : null,
  69. "tabindex": "0",
  70. "class": cls,
  71. "style": style
  72. }, [itemRender({
  73. page,
  74. type: 'page',
  75. originalElement: _createVNode("a", {
  76. "rel": "nofollow"
  77. }, [page])
  78. })]);
  79. };
  80. }
  81. });