@indielayer/ui
Version:
Indielayer UI Components with Tailwind CSS build for Vue 3
49 lines (48 loc) • 1.32 kB
TypeScript
import type { Ref, StyleValue } from 'vue';
import type { MaybeRef } from '@vueuse/shared';
type UseVirtualListItemSize = number | ((index: number) => number);
export type UseVirtualListOptions = {
/**
* item height, accept a pixel value or a function that returns the height
*
* @default 0
*/
disabled?: boolean;
itemHeight: UseVirtualListItemSize;
topOffset: number;
bottomOffset: number;
/**
* the extra buffer items outside of the view area
*
* @default 5
*/
overscan?: number;
};
export interface UseVirtualListItem<T> {
data: T;
index: number;
}
export interface UseVirtualListReturn<T> {
list: Ref<UseVirtualListItem<T>[]>;
scrollTo: (index: number) => void;
reset: () => void;
containerProps: {
ref: Ref<HTMLElement | null>;
style: StyleValue;
onScroll: () => void;
};
wrapperProps: MaybeRef<{
style?: {
width: string;
height: string;
marginTop: string;
} | {
width: string;
height: string;
marginLeft: string;
display: string;
};
}>;
}
export declare function useVirtualList<T = any>(list: MaybeRef<T[]>, options: UseVirtualListOptions): UseVirtualListReturn<T>;
export {};