UNPKG

@sassoftware/vi-api

Version:
57 lines (56 loc) 3.41 kB
import { ControlCollectionBindings, PagePreviewBindings, PageViewerBindings, RelationshipDetailsBindings, SearchAndSelectWithPreviewBindings, SearchInputBindings, SviComponentBindings, TimeSliderBindings } from "./bindings"; export declare enum SviComponent { ControlCollection = "svi-control-collection", RelationshipDetails = "svi-relationship-details", SearchInput = "svi-search-input", Page = "svi-page", PagePreview = "svi-page-preview", SearchAndSelectWithPreview = "svi-search-and-select-with-preview", TimeSlider = "svi-time-slider" } export interface ComponentCreationResult<T> { element: HTMLElement; destroy: () => void; component: Record<string, any>; setComponentInputValue?: (name: keyof T, value: unknown) => void; } /** * Functionality related to dynamically creating SAS Visual Investigator user interface components. * * Accessed from the window at `window.sas.vi.component`. * * @example window.sas.vi.component.create(SviComponent.Page, targetElement, bindings); * @category API */ export interface ComponentApi { create(component: SviComponent.ControlCollection, target: HTMLElement, bindings?: ControlCollectionBindings): Promise<ComponentCreationResult<ControlCollectionBindings>>; create(component: SviComponent.Page, target: HTMLElement, bindings?: PageViewerBindings): Promise<ComponentCreationResult<PageViewerBindings>>; create(component: SviComponent.PagePreview, target: HTMLElement, bindings?: PagePreviewBindings): Promise<ComponentCreationResult<PagePreviewBindings>>; create(component: SviComponent.RelationshipDetails, target: HTMLElement, bindings?: RelationshipDetailsBindings): Promise<ComponentCreationResult<RelationshipDetailsBindings>>; create(component: SviComponent.SearchInput, target: HTMLElement, bindings?: SearchInputBindings): Promise<ComponentCreationResult<SearchInputBindings>>; create(component: SviComponent.SearchAndSelectWithPreview, target: HTMLElement, bindings?: SearchAndSelectWithPreviewBindings): Promise<ComponentCreationResult<SearchAndSelectWithPreviewBindings>>; create(component: SviComponent.TimeSlider, target: HTMLElement, bindings?: TimeSliderBindings): Promise<ComponentCreationResult<TimeSliderBindings>>; /** * Dynamically create a SAS Visual Investigator user interface component appended to a given target DOM element location. * * @method * @param component {SviComponent} Creates the component. * @param target {HTMLElement} Appends the component to the element. * @param [bindings] {SviComponentBindings} Creates the component with the bindings. * @returns A Promise that resolves when the component has been created. * Resolves to an object containing the created element and a function to destroy it. */ create(component: SviComponent, target: HTMLElement, bindings?: SviComponentBindings): Promise<ComponentCreationResult<SviComponentBindings>>; /** * @method * Notifies the application to identify and react to any changes that have been applied. * @param [callback] {ComponentApi~afterDetectChanges} Function to be called after a change is detected. */ detectChanges(callback?: () => void): void; } /** * @callback ComponentApi~afterDetectChanges * @description A function to be called after change detection. * @returns {void} */ export * from "./bindings";