You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
19 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, ref, computed, watchEffect, openBlock, createElementBlock, normalizeClass, unref, withKeys, createCommentVNode, createBlock, Fragment, renderList, toDisplayString } from 'vue';\nimport { DArrowLeft, MoreFilled, DArrowRight } from '@element-plus/icons-vue';\nimport { paginationPagerProps } from './pager2.mjs';\nimport _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { useLocale } from '../../../../hooks/use-locale/index.mjs';\nconst __default__ = defineComponent({\n name: \"ElPaginationPager\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: paginationPagerProps,\n emits: [\"change\"],\n setup(__props, {\n emit\n }) {\n const props = __props;\n const nsPager = useNamespace(\"pager\");\n const nsIcon = useNamespace(\"icon\");\n const {\n t\n } = useLocale();\n const showPrevMore = ref(false);\n const showNextMore = ref(false);\n const quickPrevHover = ref(false);\n const quickNextHover = ref(false);\n const quickPrevFocus = ref(false);\n const quickNextFocus = ref(false);\n const pagers = computed(() => {\n const pagerCount = props.pagerCount;\n const halfPagerCount = (pagerCount - 1) / 2;\n const currentPage = Number(props.currentPage);\n const pageCount = Number(props.pageCount);\n let showPrevMore2 = false;\n let showNextMore2 = false;\n if (pageCount > pagerCount) {\n if (currentPage > pagerCount - halfPagerCount) {\n showPrevMore2 = true;\n }\n if (currentPage < pageCount - halfPagerCount) {\n showNextMore2 = true;\n }\n }\n const array = [];\n if (showPrevMore2 && !showNextMore2) {\n const startPage = pageCount - (pagerCount - 2);\n for (let i = startPage; i < pageCount; i++) {\n array.push(i);\n }\n } else if (!showPrevMore2 && showNextMore2) {\n for (let i = 2; i < pagerCount; i++) {\n array.push(i);\n }\n } else if (showPrevMore2 && showNextMore2) {\n const offset = Math.floor(pagerCount / 2) - 1;\n for (let i = currentPage - offset; i <= currentPage + offset; i++) {\n array.push(i);\n }\n } else {\n for (let i = 2; i < pageCount; i++) {\n array.push(i);\n }\n }\n return array;\n });\n const prevMoreKls = computed(() => [\"more\", \"btn-quickprev\", nsIcon.b(), nsPager.is(\"disabled\", props.disabled)]);\n const nextMoreKls = computed(() => [\"more\", \"btn-quicknext\", nsIcon.b(), nsPager.is(\"disabled\", props.disabled)]);\n const tabindex = computed(() => props.disabled ? -1 : 0);\n watchEffect(() => {\n const halfPagerCount = (props.pagerCount - 1) / 2;\n showPrevMore.value = false;\n showNextMore.value = false;\n if (props.pageCount > props.pagerCount) {\n if (props.currentPage > props.pagerCount - halfPagerCount) {\n showPrevMore.value = true;\n }\n if (props.currentPage < props.pageCount - halfPagerCount) {\n showNextMore.value = true;\n }\n }\n });\n function onMouseEnter(forward = false) {\n if (props.disabled) return;\n if (forward) {\n quickPrevHover.value = true;\n } else {\n quickNextHover.value = true;\n }\n }\n function onFocus(forward = false) {\n if (forward) {\n quickPrevFocus.value = true;\n } else {\n quickNextFocus.value = true;\n }\n }\n function onEnter(e) {\n const target = e.target;\n if (target.tagName.toLowerCase() === \"li\" && Array.from(target.classList).includes(\"number\")) {\n const newPage = Number(target.textContent);\n if (newPage !== props.currentPage) {\n emit(\"change\", newPage);\n }\n } else if (target.tagName.toLowerCase() === \"li\" && Array.from(target.classList).includes(\"more\")) {\n onPagerClick(e)