@flows/js-components
Version:
Built-in components for Flows JS SDK
50 lines (46 loc) • 1.93 kB
text/typescript
import { ActiveBlock } from '@flows/js';
import { b as Components, T as TourComponents } from './components-NBzbhe6Q.mjs';
export { a as Component, c as TourComponent } from './components-NBzbhe6Q.mjs';
interface RenderOptions {
blocks: ActiveBlock[];
components: Components;
tourComponents: TourComponents;
}
/**
* Render floating blocks at the end of the body element. This function needs to be called every time the floating blocks change.
*
* @param options - active blocks to render and the components to render them with
*
* @example
* ```js
* import { addFloatingBlocksChangeListener } from "@flows/js";
* import { render } from "@flows/js-components";
* import * as components from "@flows/js-components/components";
* import * as tourComponents from "@flows/js-components/tour-components";
*
* const dispose = addFloatingBlocksChangeListener((blocks) => {
* render({
* blocks,
* components: { ...components },
* tourComponents: { ...tourComponents },
* });
* });
*
* // Call `dispose` when you want to stop listening to the changes to avoid memory leaks
* dispose();
* ```
*/
declare const render: (options: RenderOptions) => void;
type AddSlotBlocksChangeListener = (slotId: string, callback: (items: ActiveBlock[]) => void) => () => void;
interface UpdateSlotComponentsOptions {
components: Components;
tourComponents: TourComponents;
addSlotBlocksChangeListener?: AddSlotBlocksChangeListener;
}
/**
* This method is used to register custom `<flows-slot>` element as well as updating the components that can be rendered inside the slot.
*
* @param options - with components and tourComponents available to be rendered inside the slot
*/
declare const updateSlotComponents: (options: UpdateSlotComponentsOptions) => void;
export { Components, type RenderOptions, TourComponents, type UpdateSlotComponentsOptions, render, updateSlotComponents };