UNPKG

rehance-forms

Version:
22 lines (21 loc) 1.15 kB
import * as React from "react"; import { ListScopeContext, ScopeContext } from "./ScopeContext"; export declare type CollectionScopeItemChildrenProps = { index: number; total: number; scope: ScopeContext; removeItem(): void; }; export declare type CollectionScopeProps = { /** The field key that this collection scope will mount to. */ name: string; /** Event that is triggered when an update is triggered realted to this collection scope (but not necessarily _by_ this collection scope. Called _after_ re-render and scope update. */ onChange?(scope: ListScopeContext): void; /** Event that is triggered when an item is removed from the collection via the `removeItem` callback given to `children`. Called _after_ re-render and scope update. */ onRemove?(index: number, scope: ListScopeContext): void; /** Renders a form or view per item in this collection scope. */ children(itemScope: CollectionScopeItemChildrenProps): React.ReactNode; }; export declare const CollectionScope: React.ForwardRefExoticComponent<{ children?: React.ReactNode; } & CollectionScopeProps & React.RefAttributes<any>>;