UNPKG

react-nativescript

Version:
95 lines (94 loc) 4.26 kB
import * as React from "react"; import { View, ItemsSource, ItemEventData, ListView as NativeScriptListView } from "@nativescript/core"; import { NSVElement } from "../nativescript-vue-next/runtime/nodes"; import { ListViewAttributes } from "../lib/react-nativescript-jsx"; export declare type CellViewContainer = View; declare type CellFactory = (item: any) => React.ReactElement; declare type OwnProps = { items: ItemsSource | any[]; /** User may specify cellFactory for single-template or cellFactories for multi-template. */ cellFactory?: CellFactory; cellFactories?: Map<string, { placeholderItem: any; cellFactory: CellFactory; }>; /** For now, we don't support custom onItemLoading event handlers. */ onItemTap?: (args: ItemEventData) => void; /** * The event will be raised when the ListView is scrolled so that the last item is visible. * This event is intended to be used to add additional data in the ListView. */ onLoadMoreItems?: (args: ItemEventData) => void; _debug?: { logLevel: "debug" | "info"; onCellFirstLoad?: (container: CellViewContainer) => void; onCellRecycle?: (container: CellViewContainer) => void; }; } & Omit<ListViewAttributes, "onItemLoading">; declare type Props = React.PropsWithChildren<OwnProps & { forwardedRef?: React.RefObject<NSVElement<NativeScriptListView>>; }>; declare type NumberKey = number | string; interface State { nativeCells: Record<NumberKey, CellViewContainer>; nativeCellToItemIndex: Map<CellViewContainer, NumberKey>; itemIndexToNativeCell?: Map<NumberKey, CellViewContainer>; } /** * A React wrapper around the NativeScript ListView component. * @see https://docs.nativescript.org/ui/ns-ui-widgets/list-view * @module ui/list-view/list-view */ export declare class _ListView extends React.Component<Props, State> { static readonly defaultProps: { _debug: { logLevel: "info"; onCellFirstLoad: any; onCellRecycle: any; }; }; constructor(props: Props); private readonly myRef; private readonly argsViewToRootKeyAndRef; private roots; /** * ListView code-behind: * @see https://github.com/NativeScript/nativescript-sdk-examples-js/blob/master/app/ns-ui-widgets-category/list-view/code-behind/code-behind-ts-page.ts * ListView item templates: * @see https://medium.com/@alexander.vakrilov/faster-nativescript-listview-with-multiple-item-templates-8f903a32e48f * Cell state in ListView: * @see https://medium.com/@alexander.vakrilov/managing-component-state-in-nativescript-listview-b139e45d899b * @see https://github.com/NativeScript/nativescript-angular/issues/1245#issuecomment-393465035 * loadMoreItems: * @see https://github.com/NativeScript/nativescript-sdk-examples-js/blob/master/app/ns-ui-widgets-category/list-view/events/events-ts-page.ts */ private readonly defaultOnItemLoading; protected getNativeView(): NativeScriptListView | null; private readonly renderNewRoot; componentDidMount(): void; componentWillUnmount(): void; static isItemsSource(arr: any[] | ItemsSource): arr is ItemsSource; render(): JSX.Element; } export declare const ListView: React.ForwardRefExoticComponent<{ items: ItemsSource | any[]; /** User may specify cellFactory for single-template or cellFactories for multi-template. */ cellFactory?: CellFactory; cellFactories?: Map<string, { placeholderItem: any; cellFactory: CellFactory; }>; /** For now, we don't support custom onItemLoading event handlers. */ onItemTap?: (args: ItemEventData) => void; /** * The event will be raised when the ListView is scrolled so that the last item is visible. * This event is intended to be used to add additional data in the ListView. */ onLoadMoreItems?: (args: ItemEventData) => void; _debug?: { logLevel: "debug" | "info"; onCellFirstLoad?: (container: CellViewContainer) => void; onCellRecycle?: (container: CellViewContainer) => void; }; } & Omit<ListViewAttributes, "onItemLoading"> & React.RefAttributes<NSVElement<NativeScriptListView>>>; export {};