react-consent-management-banner
Version:
Beautiful and Highly Customizable GDPR/ePrivacy React Consent and Cookie Management Library for React and Next.js
80 lines (76 loc) • 2.38 kB
TypeScript
import React from 'react';
interface IPreferenceOption {
key: string;
label: string;
description: string;
alwaysEnabled?: boolean;
}
interface IMoreLinks {
title: string;
url: string;
}
type CookieConsentConfig = {
banner: {
className?: string;
title?: string;
position?: "top" | "bottom";
button: {
acceptAlText?: string;
rejectNonEssentialText?: string;
preferencesText?: string;
};
links: {
cookiePolicy?: IMoreLinks;
privacyPolicy?: IMoreLinks;
terms?: IMoreLinks;
moreLinks?: Array<IMoreLinks>;
};
};
preferences: {
title: string;
para?: string;
className?: string;
button: {
savePreferencesText?: string;
goBackText?: string;
};
options: Array<IPreferenceOption>;
};
cookieFloatingButton: {
position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
Component: React.JSX.Element | React.JSX.Element[] | React.ReactNode;
show: boolean;
};
backgroundColor: string;
linkColor: string;
buttonBackgroundColor: string;
textColor: string;
onPreferencesChange?: (preferences: Record<string, boolean>, consentGiven: boolean) => void;
getConsentGiven?: () => void;
getConsentPreferences?: () => void;
};
type Props = {
config?: Partial<CookieConsentConfig>;
GA_TRACKING_ID: string;
};
interface IGetGtagAdsPropsDefault {
isDefault: true;
}
interface IGetGtagAdsPropsNonDefault {
ad_storage: boolean;
analytics_storage: boolean;
functionality_storage: boolean;
personalization_storage: boolean;
security_storage: boolean;
necessary_storage: boolean;
}
type GetGtagAdsPropsT = IGetGtagAdsPropsDefault | (Partial<IGetGtagAdsPropsDefault> & IGetGtagAdsPropsNonDefault) | Record<string, boolean>;
declare global {
interface Window {
gtag?: Function;
dataLayer?: any;
}
}
type PreferenceType = "all" | "essential";
declare function CookieConsent({ GA_TRACKING_ID, config, }: Props): any;
export { CookieConsent, type CookieConsentConfig, type GetGtagAdsPropsT, type IGetGtagAdsPropsDefault, type IGetGtagAdsPropsNonDefault, type IMoreLinks, type IPreferenceOption, type PreferenceType, type Props };