@feedal/embed
Version:
Feedal embed script to load feedback forms via JS or NPM
100 lines (99 loc) • 3.32 kB
TypeScript
export interface EmbedOptions {
formId: string;
sessionKey?: string;
token?: string;
host?: string;
mode?: "fullscreen" | "embedded" | "popup" | "drawer" | "button" | "sidebar" | "toast" | "inline" | "modal" | "slide-over";
theme?: 'light' | 'dark' | 'auto' | 'custom';
customCssUrl?: string;
position?: "top" | "bottom" | "left" | "right" | "center" | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "center-left" | "center-right";
width?: string | number;
height?: string | number;
offset?: {
x?: number;
y?: number;
};
buttonPosition?: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "center-left" | "center" | "center-right";
buttonSize?: "small" | "medium" | "large" | "custom";
buttonColor?: string;
buttonIcon?: string;
buttonText?: string;
trigger?: "manual" | "auto" | "click" | "scroll" | "time" | "exit-intent" | "element-visible" | "session-duration" | "idle";
triggerDelay?: number | string;
triggerElement?: string | HTMLElement;
triggerThreshold?: number;
triggerCooldown?: number | string;
autoClose?: boolean | number | string;
closeOnOverlayClick?: boolean;
showCloseButton?: boolean;
draggable?: boolean;
resizable?: boolean;
collapsible?: boolean;
persistent?: boolean;
responsive?: boolean;
maxWidth?: string | number;
minWidth?: string | number;
maxHeight?: string | number;
minHeight?: string | number;
zIndex?: number;
ariaLabel?: string;
focusTrap?: boolean;
lazyLoad?: boolean;
preloadResources?: boolean;
performanceMonitoring?: boolean;
showLoadingIndicator?: boolean;
loadingText?: string;
loadingSpinner?: boolean;
disableFormAnimations?: boolean;
rememberSubmission?: boolean;
submissionExpiry?: number | string;
storageType?: 'local' | 'session' | 'cookie';
containerId?: string;
useCard?: boolean;
animation?: "fade" | "slide" | "scale" | "bounce" | "flip" | "elastic" | "none";
overlay?: boolean;
blurBackground?: boolean;
metadata?: Record<string, any>;
prefill?: Record<string, any>;
onLoad?: () => void;
onOpen?: () => void;
onClose?: () => void;
onSubmit?: (data?: any) => void;
onSkipped?: () => void;
onError?: (error: Error) => void;
onResize?: (dimensions: {
width: number;
height: number;
}) => void;
onMove?: (position: {
x: number;
y: number;
}) => void;
}
export interface FeedalWidgetInterface {
open(): void;
close(): void;
toggle(): void;
destroy(): void;
updateOptions(newOptions: Partial<EmbedOptions>): void;
getPerformanceMetrics(): Record<string, number>;
resetSubmissionHistory(): void;
isVisible: boolean;
element: HTMLElement | null;
}
export interface MessageData {
event: string;
data?: any;
type?: string;
height?: number;
sessionKey?: string;
formId?: string;
}
export interface TriggerState {
sessionStartTime: number;
lastActivityTime: number;
hasTriggered: boolean;
cooldownUntil: number;
exitIntentTriggered: boolean;
}
export declare const DEFAULT_OPTIONS: Partial<EmbedOptions>;