UNPKG

@prefecthq/prefect-ui-library

Version:

This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.

22 lines (18 loc) 680 B
import { ComputedRef, MaybeRefOrGetter, Ref, computed, toRef, toValue } from 'vue' // this will eventually need to come from the ui settings export const GLOBAL_API_LIMIT = 200 export type UseFilterPagination = { limit: ComputedRef<number>, offset: ComputedRef<number>, page: Ref<number>, } export function useFilterPagination(page: MaybeRefOrGetter<number> = 1, limit?: MaybeRefOrGetter<number | undefined>): UseFilterPagination { const pageRef = toRef(page) const limitRef = computed(() => toValue(limit) ?? GLOBAL_API_LIMIT) const offset = computed(() => (pageRef.value - 1) * limitRef.value) return { limit: limitRef, offset, page: pageRef, } }