import * as React from 'react'; import { client, providers } from '@logilab/cwclientlibjs'; import { TranslationContext } from './commons'; /** * The basic information required for getting the entities related to a specific one */ export interface EntityRelationsSpecification { /** * The entity */ entity: providers.Entity; /** * The shema for the relations in the group */ relations: providers.EntityRelationSchema[]; /** * Whether the entity is the relation's subject */ entityIsSubject: boolean; /** * The RQL client to use */ rqlClient: client.RqlClient; /** * The provider of entities */ entityProvider: providers.EntityProvider; /** * The provider of entity schemas */ schemaProvider: providers.EntitySchemaProvider; } /** * Changes to entity relations */ export interface EntityRelationsChanges { /** * The EIDs of the entities added to the relation */ added: providers.Entity[]; /** * The EIDs of the entities removed from the relation */ removed: providers.Entity[]; } /** * The parameters for editors of relations */ export interface EntityRelationsEditorProps { /** * The specification for the related entities */ specification: EntityRelationsSpecification; /** * The base changes to the relations to be included as reference during the edition */ baseChanges: EntityRelationsChanges; /** * The CSS class name(s) for the component */ className: string; /** * Validates changes made through the editor (and close it) */ validate: (changes: EntityRelationsChanges) => void; /** * Cancels any changes and close the editor */ cancel: () => void; /** * Renders the component used to lookup candidate relatable entities * @param component The current editor component */ renderLookup: (component: EntityRelationsEditor) => JSX.Element; /** * Renders a specific relatable candidate entity * @param component The current editor component * @param entity The candidate entity * @param status The status of the entity in the relation */ renderRelatable: (component: EntityRelationsEditor, entity: providers.Entity, status: RelationStatus) => JSX.Element[]; /** * Renders the content of the editors with the candidate relatable entities */ renderContentRelatables: (component: EntityRelationsEditor) => JSX.Element; /** * Renders the content of the editor when loading * @param component The current editor component */ renderContentLoading: (component: EntityRelationsEditor) => JSX.Element; /** * Renders the validation button for the editor * @param component The current editor component */ renderButtonValidate: (component: EntityRelationsEditor) => JSX.Element; /** * Renders the cancel button for the editor * @param component The current editor component */ renderButtonCancel: (component: EntityRelationsEditor) => JSX.Element; /** * Renders the component * @param component The current editor component */ render: (component: EntityRelationsEditor) => JSX.Element; } /** * The state for editors of relations */ export interface EntityRelationsEditorState { /** * The base count of related entities, * i.e. the number of entities in the relations given by the specification, * modified by the base changes not made in this editor */ baseCount: number; /** * The current changes made by this editor */ changes: EntityRelationsChanges; /** * Whether candidate relatables entities are currently loading */ isLoadingRelatables: boolean; /** * The current relatables results */ relatables: providers.Entity[]; } /** * The common interface of editors of relations */ export declare class EntityRelationsEditor
extends React.Component
{
static contextType: React.Context