diff --git a/packages/components/pagination/__tests__/pagination.spec.ts b/packages/components/pagination/__tests__/pagination.spec.ts index d90c0e8b14..032ee2a8f6 100644 --- a/packages/components/pagination/__tests__/pagination.spec.ts +++ b/packages/components/pagination/__tests__/pagination.spec.ts @@ -1,6 +1,6 @@ import { nextTick, ref, h } from 'vue' import { mount } from '@vue/test-utils' -import Pagination from '../src/index' +import Pagination from '../src/pagination' import type { VueWrapper } from '@vue/test-utils' const assertElementsExistence = ( diff --git a/packages/components/pagination/index.ts b/packages/components/pagination/index.ts index e415f7ba44..ea97112bb4 100644 --- a/packages/components/pagination/index.ts +++ b/packages/components/pagination/index.ts @@ -1,15 +1,8 @@ -import Pagination from './src' +import { withInstall } from '@element-plus/utils/with-install' -import type { App } from 'vue' -import type { SFCWithInstall } from '@element-plus/utils/types' +import Pagination from './src/pagination' -const _Pagination = Pagination as SFCWithInstall - -_Pagination.install = (app: App) => { - app.component(_Pagination.name, _Pagination) -} - -export default _Pagination -export const ElPagination = _Pagination +export const ElPagination = withInstall(Pagination) +export default ElPagination export * from './src/pagination' diff --git a/packages/components/pagination/src/jumper.vue b/packages/components/pagination/src/components/jumper.vue similarity index 73% rename from packages/components/pagination/src/jumper.vue rename to packages/components/pagination/src/components/jumper.vue index 7cd77c33ad..48e80bc597 100644 --- a/packages/components/pagination/src/jumper.vue +++ b/packages/components/pagination/src/components/jumper.vue @@ -20,37 +20,37 @@ import { computed, defineComponent, ref } from 'vue' import { useLocaleInject } from '@element-plus/hooks' import ElInput from '@element-plus/components/input' -import { usePagination } from './usePagination' - -import type { Nullable } from '@element-plus/utils/types' +import { usePagination } from '../usePagination' export default defineComponent({ + name: 'ElPaginationJumper', components: { ElInput, }, + setup() { const { t } = useLocaleInject() - const { pagination, pageCount, disabled, currentPage } = usePagination() - const userInput = ref>(null) - const innerValue = computed(() => userInput.value ?? currentPage.value) + const { pageCount, disabled, currentPage, changeEvent } = usePagination() + const userInput = ref() + const innerValue = computed(() => userInput.value ?? currentPage?.value) function handleInput(val: number | string) { - userInput.value = Number(val) + userInput.value = +val } function handleChange(val: number | string) { - pagination?.changeEvent(Number(val)) - userInput.value = null + changeEvent?.(+val) + userInput.value = undefined } return { - t, - userInput, pageCount, disabled, + innerValue, + + t, handleInput, handleChange, - innerValue, } }, }) diff --git a/packages/components/pagination/src/next.vue b/packages/components/pagination/src/components/next.vue similarity index 64% rename from packages/components/pagination/src/next.vue rename to packages/components/pagination/src/components/next.vue index 693f130295..3f34ff300d 100644 --- a/packages/components/pagination/src/next.vue +++ b/packages/components/pagination/src/components/next.vue @@ -4,7 +4,7 @@ class="btn-next" :disabled="internalDisabled" :aria-disabled="internalDisabled" - @click.self.prevent + @click="$emit('click', $event)" > {{ nextText }} @@ -13,23 +13,29 @@