Skip to content

Instantly share code, notes, and snippets.

@ramybenaroya
Last active May 9, 2023 07:37
Show Gist options
  • Save ramybenaroya/22bc7b6cad5fecf780d10c0d31352053 to your computer and use it in GitHub Desktop.
Save ramybenaroya/22bc7b6cad5fecf780d10c0d31352053 to your computer and use it in GitHub Desktop.
declare module 'virtualizedtableforantd4' {
export interface VtOpts {
id?: number | string;
/**
* @default 5
*/
overscanRowCount?: number;
/**
* this only needs the scroll.y
*/
scroll: {
y: number | string;
};
/**
* wheel event(only works on native events).
*/
onScroll?: ({ left, top, isEnd }: { top: number; left: number; isEnd: boolean }) => void;
initTop?: number;
/**
* Offset of the table when isEnd becomes true.
* @default 0
*/
offset?: number;
/**
* @default false
*/
debug?: boolean;
// pass -1 means scroll to the bottom of the table
ref?: React.MutableRefObject<{
scrollTo: (y: number) => void;
scrollToIndex: (idx: number) => void;
}>;
}
type CustomizeComponent = React.FC<any>;
export interface TableComponents {
table?: CustomizeComponent;
header?: {
wrapper?: CustomizeComponent;
row?: CustomizeComponent;
cell?: CustomizeComponent;
};
body?: {
wrapper?: CustomizeComponent;
row?: CustomizeComponent;
cell?: CustomizeComponent;
};
}
export function useVT(
fnOpts: () => VtOpts,
deps: React.DependencyList,
): [TableComponents, (components: TableComponents) => void];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment