UNPKG

@start-base/react-consent-manager

Version:

JavaScript library designed to simplify the management of user consents in web applications developed with React. This package is particularly useful for complying with data protection regulations such as the General Data Protection Regulation (GDPR) in t

76 lines (70 loc) 1.73 kB
import * as React from 'react'; import React__default, { ReactNode } from 'react'; interface ConsentProviderProps { options: Options; children: ReactNode; } interface Options { services: Service[]; } interface Script { id?: string; src?: string; code?: string; async?: boolean; } interface Service { id: string; name: string; description?: string; mandatory: boolean; scripts: Script[]; cookies?: []; localStorage?: []; sessionStorage?: []; } interface ModalConfig { title: string; description?: string; decline?: { hidden?: boolean; label?: string; }; approve?: { hidden?: boolean; label?: string; }; approveAll?: { hidden?: boolean; label?: string; }; } interface ConsentBannerProps { children: ReactNode; settings?: { hidden?: boolean; label?: string; modal?: ModalConfig; }; approve?: { label?: string; hidden?: boolean; }; decline?: { hidden?: boolean; label?: string; }; } declare function ConsentBanner({ children, settings, approve, decline, }: Readonly<ConsentBannerProps>): React__default.JSX.Element; declare function ConsentProvider({ options, children, }: Readonly<ConsentProviderProps>): React__default.JSX.Element; declare function useConsent(): { consent: string[]; isBannerVisible: boolean; isDetailsVisible: boolean; hasConsent: (id: string) => boolean; toggleConsentBanner: () => void; toggleConsentModal: () => void; setConsent: React.Dispatch<React.SetStateAction<string[]>>; options: Options; }; export { ConsentBanner, ConsentProvider, useConsent };