import { GetCustomObjectKeys, GetQueryResponseType, GetQueryShapeType, QResult, QueryControllerProps, QueryResponseToResultType, SelectQueryFactory, ToQueryResultSet } from '../queries/SelectQuery.js'; import { Shape } from '../shapes/Shape.js'; import React from 'react'; import { NodeSet } from '../collections/NodeSet.js'; import { ShapeSet } from '../collections/ShapeSet.js'; import { Node } from '../models.js'; export type Component

= ClassComponent | LinkedComponent | LinkedSetComponent; export interface ClassComponent extends React.ComponentClass

> { props: P & LinkedComponentProps; shape?: typeof Shape; } export interface LinkedComponent extends React.FC

& React.ComponentPropsWithRef> { /** * Binds a component to a source. Usually used in Shape.request() for automatic data loading. * @param source the node or shape that this component should visualise */ original?: LinkableComponent; query?: SelectQueryFactory; shape?: typeof Shape; } export interface LinkedSetComponent extends React.FC

& React.ComponentPropsWithRef> { /** * Binds a component to a source. Usually used in Shape.request() for automatic data loading. * @param source the node or shape that this component should visualise */ original?: LinkableSetComponent; query?: SelectQueryFactory; shape?: typeof Shape; } export type LinkableComponent = React.FC

>; export type LinkableSetComponent = React.FC & P>; export interface LinkedSetComponentProps extends LinkedComponentBaseProps, QueryControllerProps { /** * An instance of the Shape that this component is linked to. * Users of this component can provide this shape with the property of: of={nodeOrShapeInstance} * if a node was given for 'of', linkedComponent() converts that node into an instance of the shape and provides it as 'source' */ sources: ShapeSet; } export interface LinkedComponentProps extends LinkedComponentBaseProps { /** * An instance of the Shape that this component is linked to. * Users of this component can provide this shape with the property of: of={nodeOrShapeInstance} * if a node was given for 'of', linkedComponent() converts that node into an instance of the shape and provides it as 'source' */ source: ShapeType; /** * @beta * Refreshes the data and rerenders the component. * WARNING: this prop will likely be replaced in a next version */ _refresh: (updatedProps?: any) => void; } interface LinkedComponentBaseProps extends React.PropsWithChildren { /** * Then linkedData will be the result of the data request, if defined. * linkedData will either be an array or an object, matching the function defined in this very component * See the first parameter of linkedComponent(). If a data request is made with Shape.request() * e.g: linkedComponent(Shape.request((shapeInstance) => ...)) then linkedData is defined. * If simply a Shape class was given as first parameter, only source will be defined, and linkedData will be undefined. */ linkedData?: DataResultType; } export interface LinkedSetComponentInputProps extends LinkedComponentInputBaseProps { /** * The primary set of data sources that this component will represent. * Can be a set of Nodes in the graph or a set of instances of the Shape that this component uses */ of?: NodeSet | ShapeSet | QResult[]; } export interface LinkedComponentInputProps extends LinkedComponentInputBaseProps { /** * The primary data source that this component will represent. * Can be a Node in the graph or an instance of the Shape that this component uses */ of: Node | ShapeType | QResult; } interface LinkedComponentInputBaseProps extends React.PropsWithChildren { /** * Add class name(s) to the top level DOM element of this component * A single class name or an array of classnames. Empty entries are allowed and will be filtered * e.g. className={[style.defaultClass,activeState && style.activeClass]} */ className?: string | string[]; /** * Add styles to the top level DOM element of this component */ style?: React.CSSProperties; } export type LinkedSetComponentFactoryFn = | { [key: string]: SelectQueryFactory; } = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType, Res = ToQueryResultSet>(requiredData: QueryType, functionalComponent: LinkableSetComponent & QueryControllerProps, //this maps all the keys of the result object to props, but only if a QueryWrapperObject was used as query ShapeType, Res>) => LinkedSetComponent; export type LinkedComponentFactoryFn = = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType, Response = GetQueryResponseType, ResultType = QueryResponseToResultType>(query: QueryType, functionalComponent: LinkableComponent) => LinkedComponent; export declare function createLinkedComponentFn(registerPackageExport: any, registerComponent: any): = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType, Res = GetQueryResponseType>(query: QueryType, functionalComponent: LinkableComponent, ShapeType>) => LinkedComponent; export declare function createLinkedSetComponentFn(registerPackageExport: any, registerComponent: any): = null, CustomProps = {}, ShapeType extends Shape = GetQueryShapeType, Res = GetQueryResponseType>(query: QueryType, functionalComponent: LinkableSetComponent>, ShapeType>, ShapeType>) => LinkedSetComponent; export declare function getSourceFromInputProps(props: any, shapeClass: any): any; export {};