@inov-ai/feedback-widget
Version:
Modern React feedback widget with surveys, analytics, and Next.js 15 support. Collect user feedback and run surveys in your SaaS applications.
147 lines (134 loc) • 4.16 kB
TypeScript
import React, { ReactNode } from 'react';
interface FeedbackConfig {
siteKey: string;
primaryColor?: string;
textColor?: string;
backgroundColor?: string;
fontFamily?: string;
fontSize?: string;
buttonRadius?: string;
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
buttonText?: string;
buttonIcon?: string;
theme?: 'light' | 'dark' | 'auto' | 'system';
animation?: 'slide' | 'fade' | 'none';
trigger?: 'manual' | 'auto' | 'timer' | 'scroll' | 'exit';
triggerDelay?: number;
surveyFrequency?: 'every-visit' | 'once' | 'daily' | 'weekly';
minimized?: boolean;
feedbackTypes?: string[];
paths?: string[];
customCSS?: string;
onOpen?: () => void;
onClose?: () => void;
onSubmit?: (data: FeedbackSubmission) => void;
onError?: (error: Error) => void;
}
interface FeedbackSubmission {
feedback: string;
category?: string;
rating?: number;
metadata: {
page_url: string;
user_agent: string;
timestamp: string;
ip?: string;
};
}
interface SurveyQuestion {
id: number;
question_text: string;
question_type: string;
type: 'text' | 'rating' | 'multiple_choice' | 'scale';
required?: boolean;
options?: Array<string | {
value: string;
label: string;
}>;
min_rating?: number;
max_rating?: number;
}
interface Survey {
id: number;
title: string;
description: string;
questions: SurveyQuestion[];
is_active: boolean;
active: boolean;
}
interface FeedbackContextType {
config: FeedbackConfig;
isOpen: boolean;
currentSurvey: Survey | null;
openWidget: () => void;
closeWidget: () => void;
submitFeedback: (data: FeedbackSubmission) => Promise<void>;
}
interface ApiResponse<T = any> {
success: boolean;
data?: T;
error?: string;
message?: string;
}
interface FeedbackMetadata {
page_url: string;
user_agent: string;
ip?: string;
timestamp: string;
referrer?: string;
viewport?: {
width: number;
height: number;
};
screen?: {
width: number;
height: number;
};
}
interface InovaiWidgetProps extends FeedbackConfig {
className?: string;
style?: React.CSSProperties;
}
declare const InovaiWidget: React.FC<InovaiWidgetProps>;
interface FeedbackProviderProps {
config: FeedbackConfig;
children: ReactNode;
}
declare const FeedbackProvider: React.FC<FeedbackProviderProps>;
declare const useFeedback: () => FeedbackContextType;
interface FeedbackButtonProps {
onClick: () => void;
config: FeedbackConfig;
minimized?: boolean;
}
declare const FeedbackButton: React.FC<FeedbackButtonProps>;
interface FeedbackModalProps {
isOpen: boolean;
onClose: () => void;
config: FeedbackConfig;
}
declare const FeedbackModal: React.FC<FeedbackModalProps>;
interface FeedbackFormProps {
onSubmit: (data: FeedbackSubmission) => Promise<void>;
config: FeedbackConfig;
isLoading?: boolean;
}
declare const FeedbackForm: React.FC<FeedbackFormProps>;
interface SurveyFormProps {
survey: Survey;
onSubmit: (surveyId: number, answers: any[]) => Promise<void>;
config: FeedbackConfig;
isLoading?: boolean;
}
declare const SurveyForm: React.FC<SurveyFormProps>;
declare const SuccessMessage: React.FC;
declare const useThemeDetection: () => "light" | "dark";
declare const usePathMonitoring: (allowedPaths?: string[]) => boolean;
declare const useFeedbackApi: (config: FeedbackConfig) => {
submitFeedback: (data: FeedbackSubmission) => Promise<void>;
submitSurvey: (surveyId: number, answers: any[]) => Promise<void>;
fetchSurvey: () => Promise<Survey | null>;
getFeedbackMetadata: () => Promise<FeedbackMetadata>;
};
export { FeedbackButton, FeedbackForm, FeedbackModal, FeedbackProvider, InovaiWidget, SuccessMessage, SurveyForm, InovaiWidget as default, useFeedback, useFeedbackApi, usePathMonitoring, useThemeDetection };
export type { ApiResponse, FeedbackConfig, FeedbackContextType, FeedbackMetadata, FeedbackSubmission, Survey, SurveyQuestion };