UNPKG

1.58 kBTypeScriptView Raw
1import { PureComponent } from "react";
2import { RenderedSection } from "./Grid";
3
4export type OnSectionRenderedParams = RenderedSection;
5
6export type ChildProps = {
7 onSectionRendered: (params: RenderedSection) => void;
8 scrollToColumn: number;
9 scrollToRow: number;
10};
11/**
12 * This HOC decorates a virtualized component and responds to arrow-key events by scrolling one row or column at a time.
13 */
14export type ArrowKeyStepperProps = {
15 children: (props: ChildProps) => React.ReactNode;
16 className?: string | undefined;
17 columnCount: number;
18 rowCount: number;
19 mode?: "edges" | "cells" | undefined;
20 disabled?: boolean | undefined;
21 isControlled?: boolean | undefined;
22 onScrollToChange?: ((params: ScrollIndices) => void) | undefined;
23 scrollToColumn?: number | undefined;
24 scrollToRow?: number | undefined;
25 /**
26 * PLEASE NOTE
27 * The [key: string]: any; line is here on purpose
28 * This is due to the need of force re-render of PureComponent
29 * Check the following link if you want to know more
30 * https://github.com/bvaughn/react-virtualized#pass-thru-props
31 */
32 [key: string]: any;
33};
34export type ScrollIndices = {
35 scrollToRow: number;
36 scrollToColumn: number;
37};
38
39export type ScrollIndexes = ScrollIndices;
40
41export class ArrowKeyStepper extends PureComponent<ArrowKeyStepperProps, ScrollIndices> {
42 static defaultProps: {
43 disabled: false;
44 isControlled: false;
45 mode: "edges";
46 scrollToColumn: 0;
47 scrollToRow: 0;
48 };
49}
50
51export default ArrowKeyStepper;
52
\No newline at end of file