@tantainnovative/ndpr-toolkit
Version:
Nigeria Data Protection Toolkit — enterprise-grade compliance components for the Nigeria Data Protection Act (NDPA) 2023
146 lines (136 loc) • 5.04 kB
TypeScript
import React__default from 'react';
declare interface ConsentBannerClassNames {
root?: string;
container?: string;
title?: string;
description?: string;
optionsList?: string;
optionItem?: string;
optionCheckbox?: string;
optionLabel?: string;
optionDescription?: string;
buttonGroup?: string;
acceptButton?: string;
rejectButton?: string;
customizeButton?: string;
saveButton?: string;
customizePanel?: string;
selectAllButton?: string;
/** The optional on-page cookie scan panel (shown in the customize view) */
cookieScanPanel?: string;
/** Alias for acceptButton */
primaryButton?: string;
/** Alias for rejectButton */
secondaryButton?: string;
}
/**
* Consent types aligned with NDPA 2023 Section 25-26
* Consent must be freely given, specific, informed, and unambiguous
*/
/**
* Represents a consent option that can be presented to users
*/
declare interface ConsentOption {
/** Unique identifier for the consent option */
id: string;
/** Display label for the consent option */
label: string;
/** Detailed description of what this consent option covers */
description: string;
/** Whether this consent option is required (cannot be declined) */
required: boolean;
/**
* The specific purpose for which data will be processed
* NDPA Section 25(2) requires consent to be specific to each purpose
*/
purpose: string;
/**
* Default state of the consent option
* @default false
*/
defaultValue?: boolean;
/**
* Categories of personal data covered by this consent option
*/
dataCategories?: string[];
}
/**
* Represents the user's consent settings
*/
declare interface ConsentSettings {
/** Map of consent option IDs to boolean values indicating consent status */
consents: Record<string, boolean>;
/** Timestamp when consent was last updated */
timestamp: number;
/** Version of the consent form that was accepted */
version: string;
/** Method used to collect consent (e.g., "banner", "settings", "api") */
method: string;
/** Whether the user has actively made a choice (as opposed to default settings) */
hasInteracted: boolean;
/**
* The lawful basis under which processing is conducted
* Required by NDPA Section 25(1)
*/
lawfulBasis?: LawfulBasisType;
}
/**
* Lawful basis for processing personal data per NDPA Section 25(1)
*/
declare type LawfulBasisType = 'consent' | 'contract' | 'legal_obligation' | 'vital_interests' | 'public_interest' | 'legitimate_interests';
export declare const NDPRConsent: React__default.FC<NDPRConsentProps>;
/**
* UX copy overrides for the NDPRConsent preset. Pass any subset to
* replace the default text without dropping to the lower-level
* `<ConsentBanner>` API. Strings you omit fall back to the toolkit
* defaults (which already cite NDPA Section 26).
*
* @example
* <NDPRConsent copy={{
* title: 'Cookie preferences',
* description: 'Acme uses cookies to keep you signed in and improve our store.',
* acceptAll: 'Allow all',
* rejectAll: 'Only essentials',
* }} />
*/
export declare interface NDPRConsentCopy {
/** Banner heading. Default: "We Value Your Privacy" */
title?: string;
/** Body paragraph under the heading. Default cites NDPA Section 26. */
description?: string;
/** Primary CTA — accepts all categories. Default: "Accept All" */
acceptAll?: string;
/** Secondary CTA — rejects all non-essential categories. Default: "Reject All" */
rejectAll?: string;
/** Tertiary CTA — opens the per-category controls. Default: "Customize" */
customize?: string;
/** Submit button on the per-category panel. Default: "Save Preferences" */
save?: string;
}
export declare interface NDPRConsentProps {
/**
* Consent categories to present. When omitted, the toolkit's
* default options are used. (4.0: legacy `extraOptions` was removed —
* pass the full options array here instead.)
*/
options?: ConsentOption[];
adapter?: StorageAdapter<ConsentSettings>;
position?: 'top' | 'bottom' | 'center' | 'inline';
classNames?: ConsentBannerClassNames;
unstyled?: boolean;
onSave?: (settings: ConsentSettings) => void;
/**
* UX copy overrides — see {@link NDPRConsentCopy}. Lets you brand the
* banner without dropping to the lower-level `<ConsentBanner>` API.
*/
copy?: NDPRConsentCopy;
}
declare interface StorageAdapter<T = unknown> {
/** Load persisted data. Called once on hook mount. */
load(): T | null | Promise<T | null>;
/** Persist data. Called on every state change. */
save(data: T): void | Promise<void>;
/** Clear persisted data. Called on reset. */
remove(): void | Promise<void>;
}
export { }