Pager.js 2.1 KB

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