From 2ae39a1bfbd62782e55d4c3e9d7af9d1ebd0a85a Mon Sep 17 00:00:00 2001 From: AntoXa PRO Date: Thu, 12 Oct 2023 11:43:59 +0300 Subject: [PATCH] use find filter --- package.json | 2 +- src/components/Pagination.vue | 10 ++-- src/hooks/find-filter.ts | 92 ++++++++++++++++++++++++++++++- src/stories/Pagination.stories.ts | 34 ++++++++++++ 4 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 src/stories/Pagination.stories.ts diff --git a/package.json b/package.json index a4a354e..82aeebd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "axp-ui", "descriiption": "My helper ui lib", - "version": "1.8.7", + "version": "1.9.0", "homepage": "https://antoxahub.ru/antoxa/axp-ui", "repository": { "type": "git", diff --git a/src/components/Pagination.vue b/src/components/Pagination.vue index a6bb9ce..339a55b 100644 --- a/src/components/Pagination.vue +++ b/src/components/Pagination.vue @@ -23,8 +23,6 @@ import { Pagination } from 'axp-ts' // Props. const props = withDefaults(defineProps(), { - // @ts-ignore - modelValue: new Pagination().toObject(), length: 3 }) @@ -32,7 +30,7 @@ const props = withDefaults(defineProps(), { const emit = defineEmits() // Data. -const page = computed(() => props.modelValue.page || 1) +const page = computed(() => props.modelValue?.page || 1) const pages = computed(() => { let pages: TUiPaginationPage[] = [] @@ -53,7 +51,7 @@ const pages = computed(() => { // Next pages. for (let i = 1; i <= length; i++) { const value = page.value + i - if (value > (props.modelValue.pages || 0)) break + if (value > (props.modelValue?.pages || 0)) break pages.push({ value }) } // for(page in props.modelValue) @@ -70,13 +68,13 @@ const updateHandler = (page: number) => { const isShowFirst = computed(() => page.value - props.length > 0) const isShowLast = computed( () => - props.modelValue.pages && + props.modelValue?.pages && page.value + props.length < props.modelValue.pages )