import { AdaptableApi } from '../Api/AdaptableApi'; import { ReactElement } from 'react'; import { BaseContext } from '../types'; /** * Base Component for Bespoke Components: can be Angular, React or Vue */ export type AdaptableFrameworkComponent = AngularFrameworkComponent | ReactFrameworkComponent | VueFrameworkComponent; /** * Angular component defined by its type and (optional) initialisation callback */ export type AngularFrameworkComponent = { /** * Angular component class (instance of https://angular.io/api/core/Type); will be automatically instantiated at runtime - `adaptableApi` is provided via Injection token */ type: T; /** * Optional initialisation callback; will be invoked after each component instantiation and returned object properties assigned to component instance */ onSetup?: ({ adaptableApi }: { adaptableApi: AdaptableApi; }) => Partial; }; /** * * A function that returns a ReactNode */ export type ReactFrameworkComponent = ({ adaptableApi, }: { adaptableApi: AdaptableApi; }) => ReactElement; /** * Creates a Vue Component to be used in AdapTable UI controls */ export type VueFrameworkComponent = ({ adaptableApi, }: { adaptableApi: AdaptableApi; }) => Component; /** * Context provided for any custom rendering */ export interface CustomRenderContext extends BaseContext { /** * Phase of DOM Element lifecycle */ phase: 'onMount' | 'onDestroy'; /** * Container Div Element */ element: HTMLDivElement; } /** * Function which is called when rendering/destroying a custom framework-agnostic component */ export interface CustomRenderFunction { /** * Function to provide bespoke content when NOT using a Framework wrapper */ (customRenderContext: CustomRenderContext): string | null; }