UNPKG

@etsoo/react

Version:

TypeScript ReactJs UI Independent Framework

113 lines (112 loc) 3.2 kB
import { DataTypes } from "@etsoo/shared"; import React from "react"; import { Align, GridChildComponentProps, VariableSizeGridProps } from "react-window"; import { GridJsonData, GridLoadDataProps, GridLoader, GridLoaderStates } from "./GridLoader"; import { GridMethodRef } from "./GridMethodRef"; export type ScrollerGridItemRendererProps<T> = Omit<GridChildComponentProps<T>, "data"> & { /** * Selected items */ selectedItems: T[]; /** * Set items for rerenderer * @param callback Callback */ setItems: (callback: (items: T[], ref: ScrollerGridForwardRef<T>) => T[] | undefined | void) => void; /** * Data */ data?: T; }; /** * Scroller vertical grid props */ export type ScrollerGridProps<T extends object, P extends GridJsonData = GridLoadDataProps> = GridLoader<T, P> & Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> & { /** * Footer renderer */ footerRenderer?: (rows: T[], states: GridLoaderStates<T>) => React.ReactNode; /** * Header renderer */ headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode; /** * Id field */ idField?: DataTypes.Keys<T>; /** * Item renderer */ itemRenderer: (props: ScrollerGridItemRendererProps<T>) => React.ReactElement; /** * Methods */ mRef?: React.Ref<ScrollerGridForwardRef<T>>; /** * On items select change */ onSelectChange?: (selectedItems: T[]) => void; /** * Returns the height of the specified row. */ rowHeight?: ((index: number) => number) | number; }; /** * Scroller grid forward ref */ export interface ScrollerGridForwardRef<T> extends GridMethodRef<T> { /** * Scroll to the specified offsets */ scrollTo(params: { scrollLeft: number; scrollTop: number; }): void; scrollToItem(params: { align?: Align | undefined; columnIndex?: number | undefined; rowIndex?: number | undefined; }): void; /** * Scroll to the specified item */ scrollToItem(params: { align?: Align | undefined; columnIndex?: number | undefined; rowIndex?: number | undefined; }): void; /** * Select the item * @param rowIndex Row index */ select(rowIndex: number): void; /** * Select or unselect all items * @param checked Checked */ selectAll(checked: boolean): void; /** * Select item * @param item Item * @param checked Checked */ selectItem(item: any, checked: boolean): void; /** * * @param index * @param shouldForceUpdate */ resetAfterColumnIndex(index: number, shouldForceUpdate?: boolean): void; resetAfterIndices(params: { columnIndex: number; rowIndex: number; shouldForceUpdate?: boolean | undefined; }): void; resetAfterRowIndex(index: number, shouldForceUpdate?: boolean): void; } /** * Scroller vertical grid * @param props Props * @returns Component */ export declare const ScrollerGrid: <T extends object>(props: ScrollerGridProps<T>) => import("react/jsx-runtime").JSX.Element;