@adaptabletools/adaptable
Version:
Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
58 lines (57 loc) • 1.89 kB
TypeScript
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<T = unknown> = {
/**
* 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<T>;
};
/**
*
* 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<Component extends unknown = unknown> = ({ 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;
}