import { createContext, useContext } from 'react'; /** * A React context that provides access to a TableFormIterator item meta (its index and the total number of items) and mutators (reorder and remove this remove). * Useful to create custom array input iterators. * @see {TableFormIterator} * @see {ArrayInput} */ // @ts-ignore const TableFormIteratorItemContext = createContext(undefined); type TableFormIteratorItemContextValue = { index: number; total: number; item: any; remove: () => void; reOrder: (newIndex: number) => void; }; /** * A hook that provides access to a TableFormIterator item meta (its index and the total number of items) and mutators (reorder and remove this remove). * Useful to create custom array input iterators. * @see {TableFormIterator} * @see {ArrayInput} */ function useTableFormIteratorItem(): TableFormIteratorItemContextValue { return useContext(TableFormIteratorItemContext); } export { TableFormIteratorItemContext, useTableFormIteratorItem }; export type { TableFormIteratorItemContextValue };