Skip to content

Commit ed4be99

Browse files
committed
chore: convert items/visibleItems to generic
1 parent f62cf3e commit ed4be99

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/components/KPagination/KPagination.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
</nav>
150150
</template>
151151

152-
<script setup lang="ts">
152+
<script setup lang="ts" generic="T">
153153
import { ref, computed, watch, onMounted, onUnmounted, nextTick } from 'vue'
154154
import KDropdown from '@/components/KDropdown/KDropdown.vue'
155155
import KButton from '@/components/KButton/KButton.vue'
@@ -173,9 +173,9 @@ const {
173173
offset,
174174
offsetPreviousButtonDisabled,
175175
offsetNextButtonDisabled,
176-
} = defineProps<PaginationProps>()
176+
} = defineProps<PaginationProps<T>>()
177177
178-
const emit = defineEmits<PaginationEmits>()
178+
const emit = defineEmits<PaginationEmits<T>>()
179179
180180
const kPaginationElement = ref<HTMLElement | null>(null)
181181
const resizeObserver = ref<ResizeObserverHelper>()

src/types/pagination.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
export interface PageChangeData {
1+
export interface PageChangeData<T = any> {
22
page: number
33
pageCount: number
44
firstItem: number
55
lastItem: number
6-
visibleItems: string | number[]
6+
visibleItems: T[]
77
}
88

99
export interface PageSizeChangeData {
1010
pageSize: number
1111
pageCount: number
1212
}
1313

14-
export interface PaginationProps {
14+
export interface PaginationProps<T> {
1515
/**
1616
* Optional array of items that can be provided for easy pagination.
1717
* Slice of this array with visible items is returned as visibleItems inside the pageChange event.
1818
* @default []
1919
*/
20-
items?: string | number[]
20+
items?: T[]
2121

2222
/**
2323
* The total number of items.
@@ -74,11 +74,11 @@ export interface PaginationProps {
7474
offsetNextButtonDisabled?: boolean
7575
}
7676

77-
export interface PaginationEmits {
77+
export interface PaginationEmits<T> {
7878
/**
7979
* Emitted when the page changes, pass the current page information along with it.
8080
*/
81-
pageChange: [data: PageChangeData]
81+
pageChange: [data: PageChangeData<T>]
8282
/**
8383
* Emitted when the page size changes, pass the current page size and page count.
8484
*/

0 commit comments

Comments
 (0)