UNPKG

@etsoo/react

Version:

TypeScript ReactJs UI Independent Framework

101 lines (100 loc) 2.82 kB
import { DataTypes } from "@etsoo/shared"; import React from "react"; import { GridImperativeAPI, GridProps } from "react-window"; import { GridJsonData, GridLoadDataProps, GridLoader, GridLoaderPartialStates, GridLoaderStates } from "./GridLoader"; import { GridMethodRef, ScrollToRowParam } from "./GridMethodRef"; type ScrollerGridCellrops<T extends object> = { rows: T[]; states: GridLoaderStates<T>; }; /** * Scroller grid forward params */ export type ScrollToCellParam = { behavior?: ScrollToRowParam["behavior"]; columnAlign?: ScrollToRowParam["align"]; columnIndex: number; rowAlign?: ScrollToRowParam["align"]; rowIndex: number; }; /** * On cells rendered data */ export type OnCellsRenderedData = Parameters<NonNullable<GridProps<object>["onCellsRendered"]>>[0]; /** * Scroller vertical grid props */ export type ScrollerGridProps<T extends object, P extends GridJsonData = GridLoadDataProps> = GridLoader<T, P> & Omit<GridProps<ScrollerGridCellrops<T>>, "cellProps" | "overscanCount" | "rowCount"> & { /** * Footer renderer */ footerRenderer?: (rows: T[], states: GridLoaderStates<T>) => React.ReactNode; /** * Header renderer */ headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode; /** * Height of the grid */ height?: number | string; /** * Id field */ idField?: DataTypes.Keys<T>; /** * Methods */ mRef?: React.Ref<ScrollerGridForwardRef<T>>; /** * Handler for init load * @param ref Ref * @returns Result */ onInitLoad?: (ref: GridImperativeAPI) => [T[], GridLoaderPartialStates<T>?] | null | undefined; /** * On items select change */ onSelectChange?: (selectedItems: T[]) => void; /** * Width of the grid */ width?: number | string; }; /** * Scroller grid forward ref */ export interface ScrollerGridForwardRef<T> extends GridMethodRef<T> { /** * Scroll to the cell * @param param Parameters to control */ scrollToCell(param: ScrollToCellParam): void; /** * Scroll to the cell * @param param Parameters to control */ scrollToColumn(param: ScrollToRowParam): 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; } /** * Scroller vertical grid * @param props Props * @returns Component */ export declare const ScrollerGrid: <T extends object>(props: ScrollerGridProps<T>) => import("react/jsx-runtime").JSX.Element; export {};