@logilab/cwelements
Version:
Library of reusable React components for building web application with cubicweb
114 lines (113 loc) • 3.44 kB
TypeScript
import * as React from 'react';
import { providers, client } from '@logilab/cwclientlibjs';
/**
* Parameters for an entity browser
*/
export interface EntityBrowserProps {
/**
* The RQL client to use
*/
client: client.RqlClient;
/**
* The CSS class name(s) for the component
*/
className: string;
/**
* Renders the browser's view when waiting for input
*/
renderViewWaiting: (component: EntityBrowser) => JSX.Element;
/**
* Renders the browser's view for the specified EID
*/
renderViewData: (component: EntityBrowser) => JSX.Element;
/**
* Renders the EID input component
*/
renderInput: (component: EntityBrowser) => JSX.Element;
/**
* Renders the component
*/
render: (component: EntityBrowser) => JSX.Element;
}
/**
* The state of an entity browser
*/
export interface EntityBrowserState {
/**
* The current timestamp
*/
timestamp: number;
/**
* The current input for the EID
*/
input: string;
/**
* The EID of the entity to display
*/
eidToShow: number | null;
}
/**
* The interface of an entity browser
*/
export interface EntityBrowser<P extends EntityBrowserProps = EntityBrowserProps, S extends EntityBrowserState = EntityBrowserState> extends React.Component<P, S> {
/**
* The schema provider to use
*/
schemaProvider: providers.EntitySchemaProvider;
/**
* The entity provider to use
*/
entityProvider: providers.EntityProvider;
/**
* When the input for EID selection changed
*/
onInputChanged: (input: string) => void;
/**
* When the used clicked on a link to an entity
*/
onClickGotoTarget: (eid: number) => void;
}
/**
* The default props for an entity browser
*/
export declare const ENTITY_BROWSER_DEFAULT_PROPS: {
className: string;
renderViewWaiting: (component: EntityBrowser) => JSX.Element;
renderViewData: (component: EntityBrowser) => JSX.Element;
renderInput: (component: EntityBrowser) => JSX.Element;
render: (component: EntityBrowser) => JSX.Element;
};
/**
* A naviguable browser of entities
*/
export declare class DefaultEntityBrowser extends React.Component<EntityBrowserProps, EntityBrowserState> implements EntityBrowser<EntityBrowserProps, EntityBrowserState> {
static defaultProps: {
className: string;
renderViewWaiting: (component: EntityBrowser<EntityBrowserProps, EntityBrowserState>) => JSX.Element;
renderViewData: (component: EntityBrowser<EntityBrowserProps, EntityBrowserState>) => JSX.Element;
renderInput: (component: EntityBrowser<EntityBrowserProps, EntityBrowserState>) => JSX.Element;
render: (component: EntityBrowser<EntityBrowserProps, EntityBrowserState>) => JSX.Element;
};
/**
* The schema provider to use
*/
schemaProvider: providers.EntitySchemaProvider;
/**
* The entity provider to use
*/
entityProvider: providers.EntityProvider;
/**
* Whether the component is currently mounted
*/
_isMounted: boolean;
/**
* The timeout for the input
*/
timeout: number | undefined;
constructor(props: Readonly<EntityBrowserProps>);
componentDidMount(): void;
componentWillUnmount(): void;
onInputChanged(input: string): void;
onClickGotoTarget(eid: number): void;
render(): JSX.Element;
}