UNPKG

@tengerly/cookie-consent

Version:

A lightweight, customizable cookie consent solution for Next.js and modern web frameworks with comprehensive multi-language support

66 lines (59 loc) 1.77 kB
// Cookie Consent Library Type Definitions export interface CookieConsentOptions { cookieName?: string; cookieExpiryDays?: number; delay?: number; autoShow?: boolean; position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'bottom-center' | 'top-center'; theme?: string; language?: 'en' | 'fr' | 'de' | 'es' | 'it' | 'nl' | 'pt' | string; translations?: { [language: string]: { title: string; message: string; acceptAll: string; acceptSome: string; reject: string; continue: string; save: string; close: string; functionalTitle: string; functionalDesc: string; analyticsTitle: string; analyticsDesc: string; }; }; onAcceptAll?: () => void; onAcceptEssential?: () => void; onAcceptCustom?: (level: string, preferences: { analytics: boolean }) => void; onReject?: () => void; } export type ConsentLevel = 'all' | 'essential'; export declare class CookieConsent { constructor(options?: CookieConsentOptions); show(): void; hide(): void; showPreferences(): void; hidePreferences(): void; acceptAll(): void; acceptEssential(): void; saveCustomPreferences(): void; setConsent(level: ConsentLevel): void; getConsent(): string | null; hasConsent(type?: ConsentLevel): boolean; resetConsent(): void; remove(): void; setLanguage(language: string): void; detectLanguage(): string; getTranslations(): any; getAvailableLanguages(): string[]; addCustomTranslation(languageCode: string, translations: any): void; enableAnalytics(): void; static create(options?: CookieConsentOptions): CookieConsent; } declare global { interface Window { CookieConsent: typeof CookieConsent; } } export default CookieConsent;