import { Entity, EntityRelation, FilterValues } from "@rebasepro/types"; import type { AdminCollection } from "@rebasepro/cms-types"; export interface RelationItem { id: string | number; label: string; description?: string; data: Entity; relation: EntityRelation; } export interface UseRelationSelectorProps = any> { /** * Full path where the relation data is located */ path: string; /** * The collection that represents the relation entities */ collection: AdminCollection; /** * Force filter to be applied to the relation search */ fixedFilter?: FilterValues; /** * Page size for pagination */ pageSize?: number; /** * Function to extract the label from a entity */ getLabelFromEntity?: (entity: Entity) => string; /** * Function to extract the description from a entity */ getDescriptionFromEntity?: (entity: Entity) => string | undefined; /** * Property name to use as the secondary display field */ descriptionProperty?: keyof M; /** * Whether the list should be fetched at all. Defaults to `true`. * * A picker that is mounted is not a picker that is open, and the two used * to be the same thing here: the fetch ran on mount, so a collection table * with a relation column paid for one query — or one realtime subscription * — per rendered row before anyone clicked a cell. Pass `false` until the * list is actually needed and nothing is requested; flipping it to `true` * fetches once, and it never goes back. */ enabled?: boolean; } export interface RelationSelectorController { items: RelationItem[]; isLoading: boolean; error: Error | undefined; search: (searchString: string) => void; loadMore: () => void; hasMore: boolean; entityToRelationItem: (entity: Entity, relation: EntityRelation) => RelationItem; } /** * Hook to manage relation selection with data fetching from Rebase data source */ export declare function useRelationSelector = any>({ path, collection, fixedFilter, pageSize, getLabelFromEntity, getDescriptionFromEntity, descriptionProperty, enabled }: UseRelationSelectorProps): RelationSelectorController;