mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 10:10:47 +01:00
18 lines
596 B
TypeScript
18 lines
596 B
TypeScript
|
|
const isNumeric = (num: any) => (typeof(num) === 'number' || typeof(num) === "string" && num.trim() !== '') && !isNaN(num as number);
|
|
|
|
export default function useQueryablePagination<T>(iterable: Array<T>, pageSize: number, query: Ref<string>) {
|
|
const pagination = computed(() => {
|
|
let filtered = [];
|
|
if (isNumeric(query.value))
|
|
filtered = iterable.filter((x: any) => x.id == parseInt(query.value, 10));
|
|
else
|
|
filtered = iterable.filter((x) => x.title.toLowerCase().includes(query.value.toLowerCase()));
|
|
|
|
return usePagination(icons, 100);
|
|
})
|
|
|
|
return {
|
|
|
|
}
|
|
} |