UNPKG

react-cookify

Version:

Simple, customizable open source cookie consent banner for GDPR law

110 lines (104 loc) 2.88 kB
import React, { ReactNode, InputHTMLAttributes } from 'react'; import { CookieAttributes } from 'js-cookie'; type ConsentObjectDataType = { [key: string]: boolean; }; type ConsentObjectType = { viewed: boolean; data: ConsentObjectDataType; uuid: string; created_at: Date; updated_at: Date; revision: number; }; interface CookifyContextProps { consentObject: ConsentObjectType; consentDisplayed: boolean; handleConsentDisplayedChange: (newConsentDisplayed: boolean) => void; consentTracking: number; actionCheckbox: (type: string) => void; actionAccept: () => void; actionNecessary: () => void; actionAll: () => void; } type CookifyOptionsType = { name?: string; store?: 'cookies' | 'storage'; saveWithChange?: boolean; saveByDefault?: boolean; typeDefault?: string; types?: ConsentObjectDataType; jscookie?: CookieAttributes; revision?: number; }; interface CookifyProviderProps { options: CookifyOptionsType; children: ReactNode; } interface InputProps extends InputHTMLAttributes<HTMLInputElement> { name: string; } interface CookifyConsentProps { settings: ConsentSettingsType; children: ReactNode; } type ConsentSettingsType = { options: CookifyOptionsType; consent: ConsentType; }; type ConsentType = { support?: boolean; theme?: 'light' | 'dark' | 'high-contrast' | 'custom'; first?: 'info' | 'detail'; force?: boolean; icon?: 'cookie' | 'fingerprint' | string; reopen?: boolean; paused?: { title?: string; desc?: string; icon?: string; url?: string; }; info?: { title?: string; desc?: string | JSX.Element; buttons?: InfoButtonType[]; }; detail?: { title?: string; desc?: string | JSX.Element; reference?: false | { desc?: string; uuid?: string; accepted?: string; updated?: string; }; buttons?: DetailButtonType[]; }; table?: { headers?: string[]; types: TableTypesType[]; }; }; type InfoButtonType = { action: 'manage' | 'necessary' | 'accept' | 'all'; label: string; schema: 'week' | 'strong'; }; type DetailButtonType = { action: 'necessary' | 'accept' | 'all'; label: string; schema: 'week' | 'strong'; }; type TableTypesType = { for: string; title: string; desc: string | JSX.Element; body?: TableRowType[]; }; type TableRowType = string[]; declare const Input: React.FC<InputProps>; declare const CookifyConsent: React.FC<CookifyConsentProps>; declare const CookifyProvider: ({ options, children }: CookifyProviderProps) => JSX.Element; declare const useCookifyProvider: () => CookifyContextProps; export { CookifyConsent, Input as CookifyInput, CookifyProvider, useCookifyProvider };