cookiebanner-finally
Version:
Headless cookie banner library for Next.js with shadcn philosophy
72 lines (64 loc) • 1.59 kB
text/typescript
/**
* Cookie consent categories
*/
export enum ConsentCategory {
Necessary = 'necessary',
Preferences = 'preferences',
Analytics = 'analytics',
Marketing = 'marketing'
}
/**
* Cookie consent preferences
*/
export interface ConsentPreferences {
[]: boolean; // Always true
[]: boolean;
[]: boolean;
[]: boolean;
lastUpdated?: string;
}
/**
* Default consent preferences
*/
export const DEFAULT_CONSENT_PREFERENCES: ConsentPreferences = {
[]: true, // Necessary cookies are always allowed
[]: false,
[]: false,
[]: false
};
/**
* Custom messages for consent gate
*/
export interface ConsentGateMessages {
/**
* Message shown when content requires consent
* Can include {category} placeholder for the consent category
*/
consentRequired?: string;
/**
* Button text for managing preferences
*/
managePreferences?: string;
/**
* Loading message
*/
loading?: string;
}
/**
* Default messages for consent gate
*/
export const DEFAULT_CONSENT_GATE_MESSAGES: ConsentGateMessages = {
consentRequired: 'This content requires consent for {category} cookies.',
managePreferences: 'Manage Cookie Preferences',
loading: 'Loading...'
};
/**
* Script definition
*/
export interface Script {
id: string;
category: ConsentCategory;
src?: string;
content?: string;
attributes?: Record<string, string>;
}