@iqworksai/consentiq-react 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/index.d.mts +192 -14
- package/dist/index.d.ts +192 -14
- package/dist/index.js +739 -125
- package/dist/index.mjs +729 -122
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @consentiq
|
|
1
|
+
# @iqworksai/consentiq-react
|
|
2
2
|
|
|
3
3
|
React SDK for ConsentIQ consent management platform.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @consentiq
|
|
8
|
+
npm install @iqworksai/consentiq-react
|
|
9
9
|
# or
|
|
10
|
-
yarn add @consentiq
|
|
10
|
+
yarn add @iqworksai/consentiq-react
|
|
11
11
|
# or
|
|
12
|
-
pnpm add @consentiq
|
|
12
|
+
pnpm add @iqworksai/consentiq-react
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import { ConsentIQProvider, CookieBanner, PreferenceCenter } from '@consentiq
|
|
18
|
+
import { ConsentIQProvider, CookieBanner, PreferenceCenter } from '@iqworksai/consentiq-react';
|
|
19
19
|
|
|
20
20
|
function App() {
|
|
21
21
|
return (
|
|
@@ -35,7 +35,7 @@ function App() {
|
|
|
35
35
|
```tsx
|
|
36
36
|
<ConsentIQProvider
|
|
37
37
|
propertyKey="YOUR_PROPERTY_KEY"
|
|
38
|
-
apiUrl="https://
|
|
38
|
+
apiUrl="https://consent.iqworks.ai" // Optional: custom API URL
|
|
39
39
|
autoShow={true} // Optional: show banner automatically
|
|
40
40
|
language="en" // Optional: override detected language
|
|
41
41
|
debug={false} // Optional: enable debug logging
|
|
@@ -50,7 +50,7 @@ function App() {
|
|
|
50
50
|
### Using the Consent Hook
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
import { useConsentIQ } from '@consentiq
|
|
53
|
+
import { useConsentIQ } from '@iqworksai/consentiq-react';
|
|
54
54
|
|
|
55
55
|
function Analytics() {
|
|
56
56
|
const { hasConsent } = useConsentIQ();
|
|
@@ -66,7 +66,7 @@ function Analytics() {
|
|
|
66
66
|
### Simplified Consent Check
|
|
67
67
|
|
|
68
68
|
```tsx
|
|
69
|
-
import { useConsent } from '@consentiq
|
|
69
|
+
import { useConsent } from '@iqworksai/consentiq-react';
|
|
70
70
|
|
|
71
71
|
function MarketingScript() {
|
|
72
72
|
const hasMarketing = useConsent('marketing');
|
|
@@ -80,7 +80,7 @@ function MarketingScript() {
|
|
|
80
80
|
### Consent Gate Component
|
|
81
81
|
|
|
82
82
|
```tsx
|
|
83
|
-
import { ConsentGate } from '@consentiq
|
|
83
|
+
import { ConsentGate } from '@iqworksai/consentiq-react';
|
|
84
84
|
|
|
85
85
|
function App() {
|
|
86
86
|
return (
|
|
@@ -97,7 +97,7 @@ function App() {
|
|
|
97
97
|
### Manual Control
|
|
98
98
|
|
|
99
99
|
```tsx
|
|
100
|
-
import { useConsentIQ } from '@consentiq
|
|
100
|
+
import { useConsentIQ } from '@iqworksai/consentiq-react';
|
|
101
101
|
|
|
102
102
|
function SettingsPage() {
|
|
103
103
|
const { showPreferenceCenter, resetConsent } = useConsentIQ();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React$1 from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* ConsentIQ React SDK Types
|
|
6
6
|
*/
|
|
7
7
|
type ConsentCategory = 'necessary' | 'analytics' | 'marketing' | 'preferences' | 'social';
|
|
8
|
-
type ConsentMethod = 'banner' | 'preference_center' | 'api' | 'sdk';
|
|
8
|
+
type ConsentMethod = 'banner' | 'preference_center' | 'api' | 'sdk' | 'form' | 'import' | 'offline';
|
|
9
9
|
type BannerPosition = 'bottom' | 'bottom-left' | 'bottom-right' | 'top' | 'center';
|
|
10
10
|
type BannerLayout = 'banner' | 'floating' | 'modal';
|
|
11
11
|
type BannerTheme = 'light' | 'dark' | 'auto';
|
|
@@ -43,14 +43,26 @@ interface ConsentIQConfig {
|
|
|
43
43
|
autoShow?: boolean;
|
|
44
44
|
/** Custom language code (overrides auto-detection) */
|
|
45
45
|
language?: string;
|
|
46
|
+
/** Alias for `language` — locale/language code to use as the default (e.g. site locale) */
|
|
47
|
+
locale?: string;
|
|
46
48
|
/** Debug mode for development */
|
|
47
49
|
debug?: boolean;
|
|
48
50
|
}
|
|
51
|
+
interface FormConsentSource {
|
|
52
|
+
selector: string | null;
|
|
53
|
+
isAutoResolved: boolean;
|
|
54
|
+
privacyNotice: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
49
60
|
interface PropertyConfig {
|
|
50
61
|
property: {
|
|
51
62
|
id: string;
|
|
52
63
|
name: string;
|
|
53
|
-
|
|
64
|
+
identifier: string;
|
|
65
|
+
platform: 'web' | 'ios' | 'android';
|
|
54
66
|
defaultLanguage: string;
|
|
55
67
|
supportedLanguages: string[];
|
|
56
68
|
};
|
|
@@ -65,6 +77,8 @@ interface PropertyConfig {
|
|
|
65
77
|
categories: CategoryInfo[];
|
|
66
78
|
marketingChannels: MarketingChannelInfo[];
|
|
67
79
|
geoRules: GeoRule[];
|
|
80
|
+
formConsentSources: FormConsentSource[];
|
|
81
|
+
privacyNoticeUrl: string | null;
|
|
68
82
|
translations: Record<string, TranslationSet>;
|
|
69
83
|
}
|
|
70
84
|
interface CategoryInfo {
|
|
@@ -107,6 +121,36 @@ interface SavedConsent {
|
|
|
107
121
|
regulationApplied: string;
|
|
108
122
|
consentVersion?: string;
|
|
109
123
|
}
|
|
124
|
+
interface FormConsentProps {
|
|
125
|
+
propertyKey?: string;
|
|
126
|
+
apiUrl?: string;
|
|
127
|
+
subjectId: string;
|
|
128
|
+
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
129
|
+
mode?: 'granular' | 'simple';
|
|
130
|
+
simpleLabel?: string;
|
|
131
|
+
channels?: string[];
|
|
132
|
+
onConsentSubmitted?: (result: {
|
|
133
|
+
consentId: string;
|
|
134
|
+
proofHash: string;
|
|
135
|
+
consents: MarketingConsentState;
|
|
136
|
+
}) => void;
|
|
137
|
+
onConsentChange?: (consents: MarketingConsentState) => void;
|
|
138
|
+
autoSubmit?: boolean;
|
|
139
|
+
className?: string;
|
|
140
|
+
style?: React.CSSProperties;
|
|
141
|
+
showDescriptions?: boolean;
|
|
142
|
+
showPrivacyLink?: boolean;
|
|
143
|
+
privacyLinkText?: string;
|
|
144
|
+
privacyUrl?: string;
|
|
145
|
+
}
|
|
146
|
+
interface FormConsentRef {
|
|
147
|
+
submit: () => Promise<{
|
|
148
|
+
consentId: string;
|
|
149
|
+
proofHash: string;
|
|
150
|
+
} | null>;
|
|
151
|
+
getConsents: () => MarketingConsentState;
|
|
152
|
+
reset: () => void;
|
|
153
|
+
}
|
|
110
154
|
interface ConsentIQContextValue {
|
|
111
155
|
/** Current consent state */
|
|
112
156
|
consent: ConsentState;
|
|
@@ -122,6 +166,10 @@ interface ConsentIQContextValue {
|
|
|
122
166
|
isPreferenceCenterVisible: boolean;
|
|
123
167
|
/** Current language */
|
|
124
168
|
language: string;
|
|
169
|
+
/** Change the active display language (must be one of the property's supportedLanguages) */
|
|
170
|
+
changeLanguage: (language: string) => void;
|
|
171
|
+
/** Text direction derived from the active language ('rtl' for ar/he/fa/ur/…, else 'ltr') */
|
|
172
|
+
dir: 'ltr' | 'rtl';
|
|
125
173
|
/** Detected regulation */
|
|
126
174
|
regulation: string | null;
|
|
127
175
|
/** Check if a specific category has consent */
|
|
@@ -149,9 +197,9 @@ interface ConsentIQContextValue {
|
|
|
149
197
|
}
|
|
150
198
|
|
|
151
199
|
interface ConsentIQProviderProps extends ConsentIQConfig {
|
|
152
|
-
children: React.ReactNode;
|
|
200
|
+
children: React$1.ReactNode;
|
|
153
201
|
}
|
|
154
|
-
declare function ConsentIQProvider({ children, propertyKey, apiUrl, subjectId: providedSubjectId, autoGenerateSubjectId, onConsentChange, onOpen, onClose, autoShow, language: preferredLanguage, debug, }: ConsentIQProviderProps): react_jsx_runtime.JSX.Element;
|
|
202
|
+
declare function ConsentIQProvider({ children, propertyKey, apiUrl, subjectId: providedSubjectId, autoGenerateSubjectId, onConsentChange, onOpen, onClose, autoShow, language: preferredLanguage, locale, debug, }: ConsentIQProviderProps): react_jsx_runtime.JSX.Element;
|
|
155
203
|
/**
|
|
156
204
|
* Hook to access ConsentIQ context
|
|
157
205
|
*/
|
|
@@ -176,17 +224,95 @@ interface CookieBannerProps {
|
|
|
176
224
|
/** Override banner theme */
|
|
177
225
|
theme?: 'light' | 'dark' | 'auto';
|
|
178
226
|
/** Custom styles */
|
|
179
|
-
style?: React.CSSProperties;
|
|
227
|
+
style?: React$1.CSSProperties;
|
|
180
228
|
}
|
|
181
229
|
declare function CookieBanner({ className, position, theme, style }: CookieBannerProps): react_jsx_runtime.JSX.Element | null;
|
|
182
230
|
|
|
231
|
+
interface ConsentTriggerProps {
|
|
232
|
+
/** Custom class name for the trigger button */
|
|
233
|
+
className?: string;
|
|
234
|
+
/** Corner to anchor the trigger to */
|
|
235
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
236
|
+
/** Override trigger theme */
|
|
237
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
238
|
+
/** Custom styles merged onto the button */
|
|
239
|
+
style?: React$1.CSSProperties;
|
|
240
|
+
/** Accessible label / tooltip text */
|
|
241
|
+
label?: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Persistent re-entry point for consent preferences.
|
|
245
|
+
*
|
|
246
|
+
* Renders a small fixed badge that reopens the Preference Center, giving users
|
|
247
|
+
* a way to change or withdraw consent after the banner is dismissed (required
|
|
248
|
+
* by GDPR/DPDPA). Hidden while the banner or Preference Center is open, so it
|
|
249
|
+
* only appears once a consent decision has been recorded.
|
|
250
|
+
*/
|
|
251
|
+
declare function ConsentTrigger({ className, position, theme, style, label, }: ConsentTriggerProps): react_jsx_runtime.JSX.Element | null;
|
|
252
|
+
|
|
253
|
+
interface ConsentPageTriggerProps {
|
|
254
|
+
/** ConsentIQ origin, e.g. https://consent.iqworks.ai */
|
|
255
|
+
apiUrl: string;
|
|
256
|
+
/** The consent page's public token */
|
|
257
|
+
token: string;
|
|
258
|
+
/** popup = open in a modal iframe (default); redirect = navigate to the hosted page */
|
|
259
|
+
mode?: 'popup' | 'redirect';
|
|
260
|
+
/** redirect mode only: an allowlisted return URL */
|
|
261
|
+
redirect?: string;
|
|
262
|
+
onComplete?: (result: {
|
|
263
|
+
consentId?: string;
|
|
264
|
+
proofHash?: string;
|
|
265
|
+
email?: string;
|
|
266
|
+
}) => void;
|
|
267
|
+
onClose?: () => void;
|
|
268
|
+
className?: string;
|
|
269
|
+
style?: React$1.CSSProperties;
|
|
270
|
+
children?: React$1.ReactNode;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Opens a property's hosted consent page as a modal iframe popup (or a redirect),
|
|
274
|
+
* and reports completion. Standalone — does not require the cookie ConsentIQProvider.
|
|
275
|
+
*/
|
|
276
|
+
declare function ConsentPageTrigger({ apiUrl, token, mode, redirect, onComplete, onClose, className, style, children, }: ConsentPageTriggerProps): react_jsx_runtime.JSX.Element;
|
|
277
|
+
|
|
278
|
+
interface ConsentFormProps {
|
|
279
|
+
/** ConsentIQ origin, e.g. https://consent.iqworks.ai */
|
|
280
|
+
apiUrl: string;
|
|
281
|
+
/** The consent page's public token (binding must have embed enabled) */
|
|
282
|
+
token: string;
|
|
283
|
+
/** If the host already knows the person's email, pass it to skip the email field */
|
|
284
|
+
email?: string;
|
|
285
|
+
onRecorded?: (result: {
|
|
286
|
+
consentId: string;
|
|
287
|
+
proofHash: string;
|
|
288
|
+
}) => void;
|
|
289
|
+
className?: string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Renders a consent page's purposes as inline checkboxes on the host's own form and records
|
|
293
|
+
* consent via the embed API. Drop in on the specific forms that need inline consent — Stage 2.
|
|
294
|
+
*/
|
|
295
|
+
declare function ConsentForm({ apiUrl, token, email: initialEmail, onRecorded, className }: ConsentFormProps): react_jsx_runtime.JSX.Element;
|
|
296
|
+
|
|
297
|
+
interface LanguageSelectorProps {
|
|
298
|
+
/** Custom class name */
|
|
299
|
+
className?: string;
|
|
300
|
+
/** Custom styles merged onto the select */
|
|
301
|
+
style?: React$1.CSSProperties;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Language switcher for the consent UI. Renders nothing when the property
|
|
305
|
+
* supports a single language, so callers can drop it in unconditionally.
|
|
306
|
+
*/
|
|
307
|
+
declare function LanguageSelector({ className, style }: LanguageSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
308
|
+
|
|
183
309
|
interface PreferenceCenterProps {
|
|
184
310
|
/** Custom class name */
|
|
185
311
|
className?: string;
|
|
186
312
|
/** Override theme */
|
|
187
313
|
theme?: 'light' | 'dark' | 'auto';
|
|
188
314
|
/** Custom styles */
|
|
189
|
-
style?: React.CSSProperties;
|
|
315
|
+
style?: React$1.CSSProperties;
|
|
190
316
|
}
|
|
191
317
|
declare function PreferenceCenter({ className, theme, style }: PreferenceCenterProps): react_jsx_runtime.JSX.Element | null;
|
|
192
318
|
|
|
@@ -194,11 +320,11 @@ interface ConsentGateProps {
|
|
|
194
320
|
/** The consent category required to show children */
|
|
195
321
|
category: ConsentCategory | string;
|
|
196
322
|
/** Content to show when consent is granted */
|
|
197
|
-
children: React.ReactNode;
|
|
323
|
+
children: React$1.ReactNode;
|
|
198
324
|
/** Content to show when consent is not granted (optional) */
|
|
199
|
-
fallback?: React.ReactNode;
|
|
325
|
+
fallback?: React$1.ReactNode;
|
|
200
326
|
/** Content to show while loading (optional) */
|
|
201
|
-
loading?: React.ReactNode;
|
|
327
|
+
loading?: React$1.ReactNode;
|
|
202
328
|
}
|
|
203
329
|
/**
|
|
204
330
|
* ConsentGate - Conditionally render content based on consent status
|
|
@@ -226,7 +352,59 @@ declare function ConsentGate({ category, children, fallback, loading, }: Consent
|
|
|
226
352
|
* const ProtectedAnalytics = withConsentGate(GoogleAnalytics, 'analytics');
|
|
227
353
|
* ```
|
|
228
354
|
*/
|
|
229
|
-
declare function withConsentGate<P extends object>(Component: React.ComponentType<P>, category: ConsentCategory | string, FallbackComponent?: React.ComponentType<P>): (props: P) => react_jsx_runtime.JSX.Element | null;
|
|
355
|
+
declare function withConsentGate<P extends object>(Component: React$1.ComponentType<P>, category: ConsentCategory | string, FallbackComponent?: React$1.ComponentType<P>): (props: P) => react_jsx_runtime.JSX.Element | null;
|
|
356
|
+
|
|
357
|
+
declare const MarketingConsentForm: React$1.ForwardRefExoticComponent<FormConsentProps & React$1.RefAttributes<FormConsentRef>>;
|
|
358
|
+
|
|
359
|
+
interface UseFormConsentOptions {
|
|
360
|
+
propertyKey: string;
|
|
361
|
+
apiUrl?: string;
|
|
362
|
+
subjectId: string;
|
|
363
|
+
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
364
|
+
debug?: boolean;
|
|
365
|
+
}
|
|
366
|
+
interface UseFormConsentReturn {
|
|
367
|
+
channels: MarketingChannelInfo[];
|
|
368
|
+
consents: MarketingConsentState;
|
|
369
|
+
privacyNoticeUrl: string | null;
|
|
370
|
+
lastSubmission: {
|
|
371
|
+
consentId: string;
|
|
372
|
+
proofHash: string;
|
|
373
|
+
} | null;
|
|
374
|
+
setConsent: (channel: string, value: boolean) => void;
|
|
375
|
+
setAllConsents: (value: boolean) => void;
|
|
376
|
+
submit: () => Promise<{
|
|
377
|
+
consentId: string;
|
|
378
|
+
proofHash: string;
|
|
379
|
+
} | null>;
|
|
380
|
+
isLoading: boolean;
|
|
381
|
+
isSubmitting: boolean;
|
|
382
|
+
error: string | null;
|
|
383
|
+
}
|
|
384
|
+
declare function useFormConsent(options: UseFormConsentOptions): UseFormConsentReturn;
|
|
385
|
+
|
|
386
|
+
interface ConsentPurpose {
|
|
387
|
+
purpose_id: string;
|
|
388
|
+
label: string | null;
|
|
389
|
+
description: string | null;
|
|
390
|
+
data_items: string[] | null;
|
|
391
|
+
is_required: boolean;
|
|
392
|
+
}
|
|
393
|
+
interface RecordedConsent {
|
|
394
|
+
success: boolean;
|
|
395
|
+
consentId: string;
|
|
396
|
+
proofHash: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Fetches a consent page's purposes (for the host to render its own checkboxes) and records
|
|
400
|
+
* consent inline via the embed API — Stage 2 of the integration journey.
|
|
401
|
+
*/
|
|
402
|
+
declare function useConsentPurposes(apiUrl: string, token: string): {
|
|
403
|
+
purposes: ConsentPurpose[];
|
|
404
|
+
loading: boolean;
|
|
405
|
+
error: string | null;
|
|
406
|
+
record: (email: string, purposeConsents: Record<string, boolean>) => Promise<RecordedConsent>;
|
|
407
|
+
};
|
|
230
408
|
|
|
231
409
|
/**
|
|
232
410
|
* ConsentIQ API Client
|
|
@@ -254,12 +432,12 @@ declare class ConsentIQApiClient {
|
|
|
254
432
|
submitConsent(data: {
|
|
255
433
|
subjectId: string;
|
|
256
434
|
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
257
|
-
cookieConsents
|
|
435
|
+
cookieConsents?: ConsentState;
|
|
258
436
|
marketingConsents?: MarketingConsentState;
|
|
259
437
|
geoCountry?: string;
|
|
260
438
|
geoRegion?: string;
|
|
261
439
|
geoSource?: 'ip' | 'user_override' | 'browser';
|
|
262
|
-
consentMethod?:
|
|
440
|
+
consentMethod?: ConsentMethod;
|
|
263
441
|
consentVersion?: string;
|
|
264
442
|
}): Promise<{
|
|
265
443
|
success: boolean;
|
|
@@ -295,4 +473,4 @@ declare function detectCountry(): string | undefined;
|
|
|
295
473
|
*/
|
|
296
474
|
declare function detectLanguage(supportedLanguages: string[]): string;
|
|
297
475
|
|
|
298
|
-
export { type BannerLayout, type BannerPosition, type BannerTheme, type CategoryInfo, type ConsentCategory, ConsentGate, type ConsentGateProps, ConsentIQApiClient, type ConsentIQConfig, type ConsentIQContextValue, ConsentIQProvider, type ConsentMethod, type ConsentState, CookieBanner, type CookieBannerProps, type GeoRule, type MarketingChannelInfo, type MarketingConsentState, PreferenceCenter, type PreferenceCenterProps, type PropertyConfig, type SavedConsent, type TranslationSet, detectCountry, detectLanguage, generateSubjectId, getOrCreateSubjectId, useConsent, useConsentGate, useConsentIQ, withConsentGate };
|
|
476
|
+
export { type BannerLayout, type BannerPosition, type BannerTheme, type CategoryInfo, type ConsentCategory, ConsentForm, type ConsentFormProps, ConsentGate, type ConsentGateProps, ConsentIQApiClient, type ConsentIQConfig, type ConsentIQContextValue, ConsentIQProvider, type ConsentMethod, ConsentPageTrigger, type ConsentPageTriggerProps, type ConsentPurpose, type ConsentState, ConsentTrigger, type ConsentTriggerProps, CookieBanner, type CookieBannerProps, type FormConsentProps, type FormConsentRef, type FormConsentSource, type GeoRule, LanguageSelector, type LanguageSelectorProps, type MarketingChannelInfo, MarketingConsentForm, type MarketingConsentState, PreferenceCenter, type PreferenceCenterProps, type PropertyConfig, type RecordedConsent, type SavedConsent, type TranslationSet, detectCountry, detectLanguage, generateSubjectId, getOrCreateSubjectId, useConsent, useConsentGate, useConsentIQ, useConsentPurposes, useFormConsent, withConsentGate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React$1 from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* ConsentIQ React SDK Types
|
|
6
6
|
*/
|
|
7
7
|
type ConsentCategory = 'necessary' | 'analytics' | 'marketing' | 'preferences' | 'social';
|
|
8
|
-
type ConsentMethod = 'banner' | 'preference_center' | 'api' | 'sdk';
|
|
8
|
+
type ConsentMethod = 'banner' | 'preference_center' | 'api' | 'sdk' | 'form' | 'import' | 'offline';
|
|
9
9
|
type BannerPosition = 'bottom' | 'bottom-left' | 'bottom-right' | 'top' | 'center';
|
|
10
10
|
type BannerLayout = 'banner' | 'floating' | 'modal';
|
|
11
11
|
type BannerTheme = 'light' | 'dark' | 'auto';
|
|
@@ -43,14 +43,26 @@ interface ConsentIQConfig {
|
|
|
43
43
|
autoShow?: boolean;
|
|
44
44
|
/** Custom language code (overrides auto-detection) */
|
|
45
45
|
language?: string;
|
|
46
|
+
/** Alias for `language` — locale/language code to use as the default (e.g. site locale) */
|
|
47
|
+
locale?: string;
|
|
46
48
|
/** Debug mode for development */
|
|
47
49
|
debug?: boolean;
|
|
48
50
|
}
|
|
51
|
+
interface FormConsentSource {
|
|
52
|
+
selector: string | null;
|
|
53
|
+
isAutoResolved: boolean;
|
|
54
|
+
privacyNotice: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
49
60
|
interface PropertyConfig {
|
|
50
61
|
property: {
|
|
51
62
|
id: string;
|
|
52
63
|
name: string;
|
|
53
|
-
|
|
64
|
+
identifier: string;
|
|
65
|
+
platform: 'web' | 'ios' | 'android';
|
|
54
66
|
defaultLanguage: string;
|
|
55
67
|
supportedLanguages: string[];
|
|
56
68
|
};
|
|
@@ -65,6 +77,8 @@ interface PropertyConfig {
|
|
|
65
77
|
categories: CategoryInfo[];
|
|
66
78
|
marketingChannels: MarketingChannelInfo[];
|
|
67
79
|
geoRules: GeoRule[];
|
|
80
|
+
formConsentSources: FormConsentSource[];
|
|
81
|
+
privacyNoticeUrl: string | null;
|
|
68
82
|
translations: Record<string, TranslationSet>;
|
|
69
83
|
}
|
|
70
84
|
interface CategoryInfo {
|
|
@@ -107,6 +121,36 @@ interface SavedConsent {
|
|
|
107
121
|
regulationApplied: string;
|
|
108
122
|
consentVersion?: string;
|
|
109
123
|
}
|
|
124
|
+
interface FormConsentProps {
|
|
125
|
+
propertyKey?: string;
|
|
126
|
+
apiUrl?: string;
|
|
127
|
+
subjectId: string;
|
|
128
|
+
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
129
|
+
mode?: 'granular' | 'simple';
|
|
130
|
+
simpleLabel?: string;
|
|
131
|
+
channels?: string[];
|
|
132
|
+
onConsentSubmitted?: (result: {
|
|
133
|
+
consentId: string;
|
|
134
|
+
proofHash: string;
|
|
135
|
+
consents: MarketingConsentState;
|
|
136
|
+
}) => void;
|
|
137
|
+
onConsentChange?: (consents: MarketingConsentState) => void;
|
|
138
|
+
autoSubmit?: boolean;
|
|
139
|
+
className?: string;
|
|
140
|
+
style?: React.CSSProperties;
|
|
141
|
+
showDescriptions?: boolean;
|
|
142
|
+
showPrivacyLink?: boolean;
|
|
143
|
+
privacyLinkText?: string;
|
|
144
|
+
privacyUrl?: string;
|
|
145
|
+
}
|
|
146
|
+
interface FormConsentRef {
|
|
147
|
+
submit: () => Promise<{
|
|
148
|
+
consentId: string;
|
|
149
|
+
proofHash: string;
|
|
150
|
+
} | null>;
|
|
151
|
+
getConsents: () => MarketingConsentState;
|
|
152
|
+
reset: () => void;
|
|
153
|
+
}
|
|
110
154
|
interface ConsentIQContextValue {
|
|
111
155
|
/** Current consent state */
|
|
112
156
|
consent: ConsentState;
|
|
@@ -122,6 +166,10 @@ interface ConsentIQContextValue {
|
|
|
122
166
|
isPreferenceCenterVisible: boolean;
|
|
123
167
|
/** Current language */
|
|
124
168
|
language: string;
|
|
169
|
+
/** Change the active display language (must be one of the property's supportedLanguages) */
|
|
170
|
+
changeLanguage: (language: string) => void;
|
|
171
|
+
/** Text direction derived from the active language ('rtl' for ar/he/fa/ur/…, else 'ltr') */
|
|
172
|
+
dir: 'ltr' | 'rtl';
|
|
125
173
|
/** Detected regulation */
|
|
126
174
|
regulation: string | null;
|
|
127
175
|
/** Check if a specific category has consent */
|
|
@@ -149,9 +197,9 @@ interface ConsentIQContextValue {
|
|
|
149
197
|
}
|
|
150
198
|
|
|
151
199
|
interface ConsentIQProviderProps extends ConsentIQConfig {
|
|
152
|
-
children: React.ReactNode;
|
|
200
|
+
children: React$1.ReactNode;
|
|
153
201
|
}
|
|
154
|
-
declare function ConsentIQProvider({ children, propertyKey, apiUrl, subjectId: providedSubjectId, autoGenerateSubjectId, onConsentChange, onOpen, onClose, autoShow, language: preferredLanguage, debug, }: ConsentIQProviderProps): react_jsx_runtime.JSX.Element;
|
|
202
|
+
declare function ConsentIQProvider({ children, propertyKey, apiUrl, subjectId: providedSubjectId, autoGenerateSubjectId, onConsentChange, onOpen, onClose, autoShow, language: preferredLanguage, locale, debug, }: ConsentIQProviderProps): react_jsx_runtime.JSX.Element;
|
|
155
203
|
/**
|
|
156
204
|
* Hook to access ConsentIQ context
|
|
157
205
|
*/
|
|
@@ -176,17 +224,95 @@ interface CookieBannerProps {
|
|
|
176
224
|
/** Override banner theme */
|
|
177
225
|
theme?: 'light' | 'dark' | 'auto';
|
|
178
226
|
/** Custom styles */
|
|
179
|
-
style?: React.CSSProperties;
|
|
227
|
+
style?: React$1.CSSProperties;
|
|
180
228
|
}
|
|
181
229
|
declare function CookieBanner({ className, position, theme, style }: CookieBannerProps): react_jsx_runtime.JSX.Element | null;
|
|
182
230
|
|
|
231
|
+
interface ConsentTriggerProps {
|
|
232
|
+
/** Custom class name for the trigger button */
|
|
233
|
+
className?: string;
|
|
234
|
+
/** Corner to anchor the trigger to */
|
|
235
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
236
|
+
/** Override trigger theme */
|
|
237
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
238
|
+
/** Custom styles merged onto the button */
|
|
239
|
+
style?: React$1.CSSProperties;
|
|
240
|
+
/** Accessible label / tooltip text */
|
|
241
|
+
label?: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Persistent re-entry point for consent preferences.
|
|
245
|
+
*
|
|
246
|
+
* Renders a small fixed badge that reopens the Preference Center, giving users
|
|
247
|
+
* a way to change or withdraw consent after the banner is dismissed (required
|
|
248
|
+
* by GDPR/DPDPA). Hidden while the banner or Preference Center is open, so it
|
|
249
|
+
* only appears once a consent decision has been recorded.
|
|
250
|
+
*/
|
|
251
|
+
declare function ConsentTrigger({ className, position, theme, style, label, }: ConsentTriggerProps): react_jsx_runtime.JSX.Element | null;
|
|
252
|
+
|
|
253
|
+
interface ConsentPageTriggerProps {
|
|
254
|
+
/** ConsentIQ origin, e.g. https://consent.iqworks.ai */
|
|
255
|
+
apiUrl: string;
|
|
256
|
+
/** The consent page's public token */
|
|
257
|
+
token: string;
|
|
258
|
+
/** popup = open in a modal iframe (default); redirect = navigate to the hosted page */
|
|
259
|
+
mode?: 'popup' | 'redirect';
|
|
260
|
+
/** redirect mode only: an allowlisted return URL */
|
|
261
|
+
redirect?: string;
|
|
262
|
+
onComplete?: (result: {
|
|
263
|
+
consentId?: string;
|
|
264
|
+
proofHash?: string;
|
|
265
|
+
email?: string;
|
|
266
|
+
}) => void;
|
|
267
|
+
onClose?: () => void;
|
|
268
|
+
className?: string;
|
|
269
|
+
style?: React$1.CSSProperties;
|
|
270
|
+
children?: React$1.ReactNode;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Opens a property's hosted consent page as a modal iframe popup (or a redirect),
|
|
274
|
+
* and reports completion. Standalone — does not require the cookie ConsentIQProvider.
|
|
275
|
+
*/
|
|
276
|
+
declare function ConsentPageTrigger({ apiUrl, token, mode, redirect, onComplete, onClose, className, style, children, }: ConsentPageTriggerProps): react_jsx_runtime.JSX.Element;
|
|
277
|
+
|
|
278
|
+
interface ConsentFormProps {
|
|
279
|
+
/** ConsentIQ origin, e.g. https://consent.iqworks.ai */
|
|
280
|
+
apiUrl: string;
|
|
281
|
+
/** The consent page's public token (binding must have embed enabled) */
|
|
282
|
+
token: string;
|
|
283
|
+
/** If the host already knows the person's email, pass it to skip the email field */
|
|
284
|
+
email?: string;
|
|
285
|
+
onRecorded?: (result: {
|
|
286
|
+
consentId: string;
|
|
287
|
+
proofHash: string;
|
|
288
|
+
}) => void;
|
|
289
|
+
className?: string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Renders a consent page's purposes as inline checkboxes on the host's own form and records
|
|
293
|
+
* consent via the embed API. Drop in on the specific forms that need inline consent — Stage 2.
|
|
294
|
+
*/
|
|
295
|
+
declare function ConsentForm({ apiUrl, token, email: initialEmail, onRecorded, className }: ConsentFormProps): react_jsx_runtime.JSX.Element;
|
|
296
|
+
|
|
297
|
+
interface LanguageSelectorProps {
|
|
298
|
+
/** Custom class name */
|
|
299
|
+
className?: string;
|
|
300
|
+
/** Custom styles merged onto the select */
|
|
301
|
+
style?: React$1.CSSProperties;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Language switcher for the consent UI. Renders nothing when the property
|
|
305
|
+
* supports a single language, so callers can drop it in unconditionally.
|
|
306
|
+
*/
|
|
307
|
+
declare function LanguageSelector({ className, style }: LanguageSelectorProps): react_jsx_runtime.JSX.Element | null;
|
|
308
|
+
|
|
183
309
|
interface PreferenceCenterProps {
|
|
184
310
|
/** Custom class name */
|
|
185
311
|
className?: string;
|
|
186
312
|
/** Override theme */
|
|
187
313
|
theme?: 'light' | 'dark' | 'auto';
|
|
188
314
|
/** Custom styles */
|
|
189
|
-
style?: React.CSSProperties;
|
|
315
|
+
style?: React$1.CSSProperties;
|
|
190
316
|
}
|
|
191
317
|
declare function PreferenceCenter({ className, theme, style }: PreferenceCenterProps): react_jsx_runtime.JSX.Element | null;
|
|
192
318
|
|
|
@@ -194,11 +320,11 @@ interface ConsentGateProps {
|
|
|
194
320
|
/** The consent category required to show children */
|
|
195
321
|
category: ConsentCategory | string;
|
|
196
322
|
/** Content to show when consent is granted */
|
|
197
|
-
children: React.ReactNode;
|
|
323
|
+
children: React$1.ReactNode;
|
|
198
324
|
/** Content to show when consent is not granted (optional) */
|
|
199
|
-
fallback?: React.ReactNode;
|
|
325
|
+
fallback?: React$1.ReactNode;
|
|
200
326
|
/** Content to show while loading (optional) */
|
|
201
|
-
loading?: React.ReactNode;
|
|
327
|
+
loading?: React$1.ReactNode;
|
|
202
328
|
}
|
|
203
329
|
/**
|
|
204
330
|
* ConsentGate - Conditionally render content based on consent status
|
|
@@ -226,7 +352,59 @@ declare function ConsentGate({ category, children, fallback, loading, }: Consent
|
|
|
226
352
|
* const ProtectedAnalytics = withConsentGate(GoogleAnalytics, 'analytics');
|
|
227
353
|
* ```
|
|
228
354
|
*/
|
|
229
|
-
declare function withConsentGate<P extends object>(Component: React.ComponentType<P>, category: ConsentCategory | string, FallbackComponent?: React.ComponentType<P>): (props: P) => react_jsx_runtime.JSX.Element | null;
|
|
355
|
+
declare function withConsentGate<P extends object>(Component: React$1.ComponentType<P>, category: ConsentCategory | string, FallbackComponent?: React$1.ComponentType<P>): (props: P) => react_jsx_runtime.JSX.Element | null;
|
|
356
|
+
|
|
357
|
+
declare const MarketingConsentForm: React$1.ForwardRefExoticComponent<FormConsentProps & React$1.RefAttributes<FormConsentRef>>;
|
|
358
|
+
|
|
359
|
+
interface UseFormConsentOptions {
|
|
360
|
+
propertyKey: string;
|
|
361
|
+
apiUrl?: string;
|
|
362
|
+
subjectId: string;
|
|
363
|
+
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
364
|
+
debug?: boolean;
|
|
365
|
+
}
|
|
366
|
+
interface UseFormConsentReturn {
|
|
367
|
+
channels: MarketingChannelInfo[];
|
|
368
|
+
consents: MarketingConsentState;
|
|
369
|
+
privacyNoticeUrl: string | null;
|
|
370
|
+
lastSubmission: {
|
|
371
|
+
consentId: string;
|
|
372
|
+
proofHash: string;
|
|
373
|
+
} | null;
|
|
374
|
+
setConsent: (channel: string, value: boolean) => void;
|
|
375
|
+
setAllConsents: (value: boolean) => void;
|
|
376
|
+
submit: () => Promise<{
|
|
377
|
+
consentId: string;
|
|
378
|
+
proofHash: string;
|
|
379
|
+
} | null>;
|
|
380
|
+
isLoading: boolean;
|
|
381
|
+
isSubmitting: boolean;
|
|
382
|
+
error: string | null;
|
|
383
|
+
}
|
|
384
|
+
declare function useFormConsent(options: UseFormConsentOptions): UseFormConsentReturn;
|
|
385
|
+
|
|
386
|
+
interface ConsentPurpose {
|
|
387
|
+
purpose_id: string;
|
|
388
|
+
label: string | null;
|
|
389
|
+
description: string | null;
|
|
390
|
+
data_items: string[] | null;
|
|
391
|
+
is_required: boolean;
|
|
392
|
+
}
|
|
393
|
+
interface RecordedConsent {
|
|
394
|
+
success: boolean;
|
|
395
|
+
consentId: string;
|
|
396
|
+
proofHash: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Fetches a consent page's purposes (for the host to render its own checkboxes) and records
|
|
400
|
+
* consent inline via the embed API — Stage 2 of the integration journey.
|
|
401
|
+
*/
|
|
402
|
+
declare function useConsentPurposes(apiUrl: string, token: string): {
|
|
403
|
+
purposes: ConsentPurpose[];
|
|
404
|
+
loading: boolean;
|
|
405
|
+
error: string | null;
|
|
406
|
+
record: (email: string, purposeConsents: Record<string, boolean>) => Promise<RecordedConsent>;
|
|
407
|
+
};
|
|
230
408
|
|
|
231
409
|
/**
|
|
232
410
|
* ConsentIQ API Client
|
|
@@ -254,12 +432,12 @@ declare class ConsentIQApiClient {
|
|
|
254
432
|
submitConsent(data: {
|
|
255
433
|
subjectId: string;
|
|
256
434
|
subjectType?: 'visitor' | 'user' | 'subscriber';
|
|
257
|
-
cookieConsents
|
|
435
|
+
cookieConsents?: ConsentState;
|
|
258
436
|
marketingConsents?: MarketingConsentState;
|
|
259
437
|
geoCountry?: string;
|
|
260
438
|
geoRegion?: string;
|
|
261
439
|
geoSource?: 'ip' | 'user_override' | 'browser';
|
|
262
|
-
consentMethod?:
|
|
440
|
+
consentMethod?: ConsentMethod;
|
|
263
441
|
consentVersion?: string;
|
|
264
442
|
}): Promise<{
|
|
265
443
|
success: boolean;
|
|
@@ -295,4 +473,4 @@ declare function detectCountry(): string | undefined;
|
|
|
295
473
|
*/
|
|
296
474
|
declare function detectLanguage(supportedLanguages: string[]): string;
|
|
297
475
|
|
|
298
|
-
export { type BannerLayout, type BannerPosition, type BannerTheme, type CategoryInfo, type ConsentCategory, ConsentGate, type ConsentGateProps, ConsentIQApiClient, type ConsentIQConfig, type ConsentIQContextValue, ConsentIQProvider, type ConsentMethod, type ConsentState, CookieBanner, type CookieBannerProps, type GeoRule, type MarketingChannelInfo, type MarketingConsentState, PreferenceCenter, type PreferenceCenterProps, type PropertyConfig, type SavedConsent, type TranslationSet, detectCountry, detectLanguage, generateSubjectId, getOrCreateSubjectId, useConsent, useConsentGate, useConsentIQ, withConsentGate };
|
|
476
|
+
export { type BannerLayout, type BannerPosition, type BannerTheme, type CategoryInfo, type ConsentCategory, ConsentForm, type ConsentFormProps, ConsentGate, type ConsentGateProps, ConsentIQApiClient, type ConsentIQConfig, type ConsentIQContextValue, ConsentIQProvider, type ConsentMethod, ConsentPageTrigger, type ConsentPageTriggerProps, type ConsentPurpose, type ConsentState, ConsentTrigger, type ConsentTriggerProps, CookieBanner, type CookieBannerProps, type FormConsentProps, type FormConsentRef, type FormConsentSource, type GeoRule, LanguageSelector, type LanguageSelectorProps, type MarketingChannelInfo, MarketingConsentForm, type MarketingConsentState, PreferenceCenter, type PreferenceCenterProps, type PropertyConfig, type RecordedConsent, type SavedConsent, type TranslationSet, detectCountry, detectLanguage, generateSubjectId, getOrCreateSubjectId, useConsent, useConsentGate, useConsentIQ, useConsentPurposes, useFormConsent, withConsentGate };
|