2022-11-17 01:11:08 +09:00
|
|
|
<script setup lang="ts">
|
2022-11-17 16:35:42 +09:00
|
|
|
import type { Paginator } from 'masto'
|
2022-11-17 01:11:08 +09:00
|
|
|
|
2022-11-17 16:35:42 +09:00
|
|
|
const { paginator, keyProp = 'id' } = defineProps<{
|
|
|
|
paginator: Paginator<any, any[]>
|
|
|
|
keyProp?: string
|
2022-11-17 01:11:08 +09:00
|
|
|
}>()
|
2022-11-17 16:35:42 +09:00
|
|
|
|
|
|
|
const { items, state, endAnchor, error } = usePaginator(paginator)
|
2022-11-17 01:11:08 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-17 16:35:42 +09:00
|
|
|
<div>
|
|
|
|
<slot
|
|
|
|
v-for="item of items"
|
|
|
|
:key="item[keyProp]"
|
|
|
|
:item="item"
|
|
|
|
/>
|
|
|
|
<div ref="endAnchor" />
|
|
|
|
<div v-if="state === 'loading'" p5 color-gray-5>
|
|
|
|
Loading...
|
|
|
|
</div>
|
|
|
|
<div v-else-if="state === 'done'" p5 color-gray>
|
|
|
|
End of list
|
|
|
|
</div>
|
|
|
|
<div v-else-if="state === 'error'" p5 color-gray>
|
|
|
|
ERROR: {{ error }}
|
|
|
|
</div>
|
2022-11-17 01:11:08 +09:00
|
|
|
</div>
|
|
|
|
</template>
|