@mongodb-js/charts-embed-dom
Version:
JavaScript library for embedding MongoDB Charts
74 lines (73 loc) • 2.68 kB
TypeScript
import { ChattyHostBuilder, ChattyHostConnection } from '@looker/chatty';
import { SharedEmbedOptions, Theme, EncodingType } from './types';
type EmbedErrors = {
SEND: string;
IFRAME: string;
};
type EmbedItemColour = {
LIGHT: string;
DARK: string;
};
type GetImageOptions = {
encoding: EncodingType;
};
declare abstract class BaseEmbedItem {
/** @ignore */
iframe?: HTMLIFrameElement;
protected connection?: ChattyHostConnection;
protected abstract name: string;
protected abstract ERRORS: EmbedErrors;
protected abstract COLOUR: EmbedItemColour;
protected abstract options: SharedEmbedOptions;
protected abstract getEmbedUrl(): string;
/**
* Renders an embeddable item into the given `container`.
*
* This method should only be called once, and successive attempts to call `render`
* will fail with an error.
*
* @returns a promise that will resolve once the item has successfully been embedded
*/
render(container: HTMLElement): Promise<void>;
/**
* @returns whether auto refreshing is enabled
*/
isAutoRefresh(): Promise<boolean>;
/**
* Enable/Disable auto refreshing.
*/
setAutoRefresh(value: boolean): Promise<void>;
/**
* @returns the number of seconds before a chart or dashboard's data expires
*/
getMaxDataAge(): Promise<number>;
/**
* Set the number of seconds a chart or dashboard's data expires.
*/
setMaxDataAge(value: number): Promise<void>;
/**
* Sets the color scheme to apply to the chart or dashboard.
*
* If the theme is set to 'dark' and you have specified a custom background color, you should ensure that your background color has appropriate contrast.
*/
setTheme(value: Theme): Promise<void>;
/**
* @returns the current theme applied to the chart or dashboard
*/
getTheme(): Promise<string>;
protected _configureHost(hostBuilder: ChattyHostBuilder): ChattyHostBuilder;
protected _configureEmbedRoot(embedRoot: HTMLElement): HTMLElement;
protected _setBackground(background: string | undefined, theme: string | undefined): void;
protected _retrieveAndSetToken(): Promise<void>;
/**
* Send message to embedded app.
*/
_send(eventName: string, ...payload: unknown[]): Promise<[unknown]>;
/**
* Get the image data of embeded entity in base64 or binary encoding
* @param {GetImageOptions} options options for image generation
* @returns {string | Blob} image encoded with base64 or binary
*/
getImage(options: GetImageOptions): Promise<string | Blob>;
}
export default BaseEmbedItem;