@graffico/legal 0.2.6 → 0.3.0
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 +237 -79
- package/dist/index.d.ts +423 -16
- package/dist/index.js +22 -1
- package/dist/next.d.ts +154 -0
- package/dist/next.js +2 -0
- package/dist/server.d.ts +59 -1
- package/dist/server.js +1 -1
- package/package.json +13 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Banner di consenso GDPR mostrato finché l'utente non sceglie le preferenze.
|
|
@@ -43,7 +43,11 @@ declare const TRANSLATIONS: {
|
|
|
43
43
|
marketingDescription: string;
|
|
44
44
|
consentId: string;
|
|
45
45
|
consentDate: string;
|
|
46
|
+
consentPolicyVersion: string;
|
|
47
|
+
consentSource: string;
|
|
46
48
|
legalProofDescription: string;
|
|
49
|
+
consentCheckboxLabel: string;
|
|
50
|
+
privacyPolicyLink: string;
|
|
47
51
|
declineAll: string;
|
|
48
52
|
saveAndContinue: string;
|
|
49
53
|
acceptAll: string;
|
|
@@ -85,6 +89,23 @@ declare const TRANSLATIONS: {
|
|
|
85
89
|
ownerDefinitionDescription: string;
|
|
86
90
|
cookieDefinitionTitle: string;
|
|
87
91
|
cookieDefinitionDescription: string;
|
|
92
|
+
processorsTitle: string;
|
|
93
|
+
processorsIntro: string;
|
|
94
|
+
processorPurpose: string;
|
|
95
|
+
processorCountry: string;
|
|
96
|
+
processorTransferBasis: string;
|
|
97
|
+
processorPrivacyPolicy: string;
|
|
98
|
+
transfersTitle: string;
|
|
99
|
+
transfersDescription: string;
|
|
100
|
+
retentionTitle: string;
|
|
101
|
+
retentionIntro: string;
|
|
102
|
+
retentionContactForms: string;
|
|
103
|
+
retentionAnalytics: string;
|
|
104
|
+
retentionMarketing: string;
|
|
105
|
+
dpoTitle: string;
|
|
106
|
+
dpoIntro: string;
|
|
107
|
+
dpoPhone: string;
|
|
108
|
+
policyVersionLabel: string;
|
|
88
109
|
cookiePolicyTitle: string;
|
|
89
110
|
cookieWelcome: string;
|
|
90
111
|
cookieIntro: string;
|
|
@@ -163,7 +184,11 @@ declare const TRANSLATIONS: {
|
|
|
163
184
|
marketingDescription: string;
|
|
164
185
|
consentId: string;
|
|
165
186
|
consentDate: string;
|
|
187
|
+
consentPolicyVersion: string;
|
|
188
|
+
consentSource: string;
|
|
166
189
|
legalProofDescription: string;
|
|
190
|
+
consentCheckboxLabel: string;
|
|
191
|
+
privacyPolicyLink: string;
|
|
167
192
|
declineAll: string;
|
|
168
193
|
saveAndContinue: string;
|
|
169
194
|
acceptAll: string;
|
|
@@ -205,6 +230,23 @@ declare const TRANSLATIONS: {
|
|
|
205
230
|
ownerDefinitionDescription: string;
|
|
206
231
|
cookieDefinitionTitle: string;
|
|
207
232
|
cookieDefinitionDescription: string;
|
|
233
|
+
processorsTitle: string;
|
|
234
|
+
processorsIntro: string;
|
|
235
|
+
processorPurpose: string;
|
|
236
|
+
processorCountry: string;
|
|
237
|
+
processorTransferBasis: string;
|
|
238
|
+
processorPrivacyPolicy: string;
|
|
239
|
+
transfersTitle: string;
|
|
240
|
+
transfersDescription: string;
|
|
241
|
+
retentionTitle: string;
|
|
242
|
+
retentionIntro: string;
|
|
243
|
+
retentionContactForms: string;
|
|
244
|
+
retentionAnalytics: string;
|
|
245
|
+
retentionMarketing: string;
|
|
246
|
+
dpoTitle: string;
|
|
247
|
+
dpoIntro: string;
|
|
248
|
+
dpoPhone: string;
|
|
249
|
+
policyVersionLabel: string;
|
|
208
250
|
cookiePolicyTitle: string;
|
|
209
251
|
cookieWelcome: string;
|
|
210
252
|
cookieIntro: string;
|
|
@@ -278,6 +320,35 @@ type ServiceReference = string | LegalService;
|
|
|
278
320
|
* Posizione del toggle floating per riaprire le preferenze.
|
|
279
321
|
*/
|
|
280
322
|
type TogglePosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
323
|
+
/**
|
|
324
|
+
* Responsabile esterno / destinatario dei dati personali da dichiarare in policy
|
|
325
|
+
* ex art. 13.1.e GDPR.
|
|
326
|
+
*/
|
|
327
|
+
interface Processor {
|
|
328
|
+
name: string;
|
|
329
|
+
purpose: string;
|
|
330
|
+
country: string;
|
|
331
|
+
/** Base giuridica del trasferimento extra-UE (es. "DPF", "SCC 2021/914"). */
|
|
332
|
+
transferBasis?: string;
|
|
333
|
+
privacyUrl?: string;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Mappa retention per categoria/finalità. Valori liberi (es. "90d", "14m", "2y").
|
|
337
|
+
*/
|
|
338
|
+
interface RetentionMap {
|
|
339
|
+
contactForms?: string;
|
|
340
|
+
analytics?: string;
|
|
341
|
+
marketing?: string;
|
|
342
|
+
[key: string]: string | undefined;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Recapiti del DPO, renderizzati in policy solo se presenti.
|
|
346
|
+
*/
|
|
347
|
+
interface DpoInfo {
|
|
348
|
+
name: string;
|
|
349
|
+
email: string;
|
|
350
|
+
phone?: string;
|
|
351
|
+
}
|
|
281
352
|
/**
|
|
282
353
|
* Configurazione del titolare e branding mostrati nelle policy.
|
|
283
354
|
*/
|
|
@@ -294,9 +365,32 @@ interface CompanyConfig {
|
|
|
294
365
|
theme?: "light" | "dark";
|
|
295
366
|
primaryColor?: string;
|
|
296
367
|
language?: "it" | "en";
|
|
368
|
+
/**
|
|
369
|
+
* Versione dichiarata delle policy. Variare questa stringa invalida i
|
|
370
|
+
* consensi precedenti e ripropone il banner (art. 7.1 GDPR — consenso
|
|
371
|
+
* "informato" rispetto alla nuova finalità).
|
|
372
|
+
*/
|
|
373
|
+
policyVersion?: string;
|
|
374
|
+
/**
|
|
375
|
+
* Destinatari/responsabili esterni dichiarati nella privacy policy.
|
|
376
|
+
* Render automatico nella sezione "Trasferimenti e destinatari".
|
|
377
|
+
*/
|
|
378
|
+
processors?: Processor[];
|
|
379
|
+
/**
|
|
380
|
+
* Retention per categoria di dato. Render automatico in policy.
|
|
381
|
+
*/
|
|
382
|
+
retention?: RetentionMap;
|
|
383
|
+
/**
|
|
384
|
+
* Dati di contatto del DPO, se nominato (art. 37 GDPR).
|
|
385
|
+
*/
|
|
386
|
+
dpo?: DpoInfo;
|
|
297
387
|
}
|
|
298
388
|
/**
|
|
299
|
-
*
|
|
389
|
+
* Origine della scelta di consenso salvata. Utile per audit.
|
|
390
|
+
*/
|
|
391
|
+
type ConsentSource = "banner" | "modal" | "gpc-auto" | "api";
|
|
392
|
+
/**
|
|
393
|
+
* Stato di consenso persistito per categoria, con prova legale e TTL.
|
|
300
394
|
*/
|
|
301
395
|
interface ConsentState {
|
|
302
396
|
necessary: boolean;
|
|
@@ -304,6 +398,12 @@ interface ConsentState {
|
|
|
304
398
|
marketing: boolean;
|
|
305
399
|
consentId?: string;
|
|
306
400
|
timestamp?: string;
|
|
401
|
+
/** Epoch ms oltre cui il consenso scade e va riproposto (Garante: max 6 mesi). */
|
|
402
|
+
expiresAt?: number;
|
|
403
|
+
/** Versione delle policy al momento del consenso. */
|
|
404
|
+
policyVersion?: string;
|
|
405
|
+
/** Da quale interazione è stata espressa la scelta. */
|
|
406
|
+
source?: ConsentSource;
|
|
307
407
|
}
|
|
308
408
|
/**
|
|
309
409
|
* Codice lingua supportato dalla libreria.
|
|
@@ -327,15 +427,15 @@ interface ServiceGridProps {
|
|
|
327
427
|
*/
|
|
328
428
|
declare const ServiceGrid: ({ config: configProp, language: langProp, }?: ServiceGridProps) => react_jsx_runtime.JSX.Element | null;
|
|
329
429
|
|
|
330
|
-
interface Props {
|
|
331
|
-
language: Language;
|
|
332
|
-
primaryColor: string;
|
|
333
|
-
}
|
|
334
430
|
/**
|
|
335
|
-
*
|
|
431
|
+
* Categoria di consenso gestita dal CMP.
|
|
336
432
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
433
|
+
type ConsentCategory = "necessary" | "statistical" | "marketing";
|
|
434
|
+
/**
|
|
435
|
+
* Sottoinsieme di categorie che possono "gating" lo script di un tracker.
|
|
436
|
+
* Esclude `necessary` perché i tracker tecnici non sono mai opt-in.
|
|
437
|
+
*/
|
|
438
|
+
type TrackableCategory = Exclude<ConsentCategory, "necessary">;
|
|
339
439
|
/**
|
|
340
440
|
* Lingua corrente normalizzata, reattiva ai cambi via bridge i18n.
|
|
341
441
|
*/
|
|
@@ -344,6 +444,15 @@ declare const useLegalLanguage: () => Language;
|
|
|
344
444
|
* Stato di consenso corrente (necessary/statistical/marketing + prova legale).
|
|
345
445
|
*/
|
|
346
446
|
declare const useConsent: () => ConsentState;
|
|
447
|
+
/**
|
|
448
|
+
* Stato di una singola categoria. `undefined` finché lo store non è idratato,
|
|
449
|
+
* così il consumer può evitare flash di contenuto prima della scelta utente.
|
|
450
|
+
*/
|
|
451
|
+
declare const useConsentCategory: (category: ConsentCategory) => boolean | undefined;
|
|
452
|
+
/**
|
|
453
|
+
* `true` quando lo store ha completato l'idratazione da localStorage.
|
|
454
|
+
*/
|
|
455
|
+
declare const useIsHydrated: () => boolean;
|
|
347
456
|
/**
|
|
348
457
|
* Indica se il banner di consenso è da mostrare (post-hydration).
|
|
349
458
|
*/
|
|
@@ -357,6 +466,33 @@ declare const useModalOpen: () => boolean;
|
|
|
357
466
|
*/
|
|
358
467
|
declare function useT(): Translator;
|
|
359
468
|
|
|
469
|
+
interface ConsentGateProps {
|
|
470
|
+
category: ConsentCategory;
|
|
471
|
+
children: ReactNode;
|
|
472
|
+
/** Renderizzato se la categoria non è (ancora) attiva. Default: nessun rendering. */
|
|
473
|
+
fallback?: ReactNode;
|
|
474
|
+
/**
|
|
475
|
+
* Renderizza `children` anche durante l'idratazione (consenso ancora `undefined`).
|
|
476
|
+
* Da usare solo per contenuto privo di tracker (es. UI puramente decorativa).
|
|
477
|
+
*/
|
|
478
|
+
renderWhileHydrating?: boolean;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Gate dichiarativo: renderizza i children solo se la categoria di consenso
|
|
482
|
+
* indicata è attiva. Usato per wrappare componenti che caricano script o
|
|
483
|
+
* embed terzi (es. iframe YouTube, Maps).
|
|
484
|
+
*/
|
|
485
|
+
declare function ConsentGate({ category, children, fallback, renderWhileHydrating, }: ConsentGateProps): react_jsx_runtime.JSX.Element;
|
|
486
|
+
|
|
487
|
+
interface Props {
|
|
488
|
+
language: Language;
|
|
489
|
+
primaryColor: string;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Card "centro preferenze" della cookie policy: gestisci o resetta consenso.
|
|
493
|
+
*/
|
|
494
|
+
declare function PreferenceCard({ language, primaryColor }: Props): react_jsx_runtime.JSX.Element;
|
|
495
|
+
|
|
360
496
|
/**
|
|
361
497
|
* Boundary client root: espone la config via context, idrata il consenso
|
|
362
498
|
* persistito al mount e tiene sincronizzata la lingua dello store.
|
|
@@ -374,26 +510,57 @@ declare function useLegalConfig(): CompanyConfig;
|
|
|
374
510
|
*/
|
|
375
511
|
declare function useLegalConfigOptional(): CompanyConfig | null;
|
|
376
512
|
|
|
513
|
+
type Listener = () => void;
|
|
514
|
+
interface ClientState {
|
|
515
|
+
language: Language;
|
|
516
|
+
consent: ConsentState;
|
|
517
|
+
showBanner: boolean;
|
|
518
|
+
isModalOpen: boolean;
|
|
519
|
+
hydrated: boolean;
|
|
520
|
+
/** Versione delle policy attiva. Stampata nel consenso al save. */
|
|
521
|
+
activePolicyVersion?: string;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Durata di validità del consenso in millisecondi.
|
|
525
|
+
* Allineato alla raccomandazione Garante 10/06/2021 (max 6 mesi prima del re-prompt).
|
|
526
|
+
*/
|
|
527
|
+
declare const CONSENT_TTL_MS: number;
|
|
528
|
+
/**
|
|
529
|
+
* Registra un listener invocato a ogni mutazione dello store.
|
|
530
|
+
*/
|
|
531
|
+
declare function subscribe(l: Listener): () => void;
|
|
532
|
+
/**
|
|
533
|
+
* Snapshot corrente dello store, valido solo lato client.
|
|
534
|
+
*/
|
|
535
|
+
declare const getSnapshot: () => ClientState;
|
|
377
536
|
/**
|
|
378
537
|
* Aggiorna la lingua corrente normalizzando un codice arbitrario.
|
|
379
538
|
*/
|
|
380
539
|
declare function setLanguage(lang: string | undefined | null): void;
|
|
540
|
+
interface HydrateOptions {
|
|
541
|
+
language?: Language;
|
|
542
|
+
policyVersion?: string;
|
|
543
|
+
}
|
|
381
544
|
/**
|
|
382
|
-
* Carica il consenso da localStorage al mount
|
|
545
|
+
* Carica il consenso da localStorage al mount.
|
|
546
|
+
* Riconosce TTL scaduto, versione policy obsoleta e segnale GPC/DNT —
|
|
547
|
+
* in tutti questi casi il consenso esistente è invalidato e il banner riappare
|
|
548
|
+
* (oppure, per GPC, viene persistito un decline automatico).
|
|
383
549
|
*/
|
|
384
|
-
declare function hydrateFromStorage(
|
|
550
|
+
declare function hydrateFromStorage(opts?: HydrateOptions): void;
|
|
385
551
|
/**
|
|
386
|
-
* Persiste le preferenze e marca prova legale (consentId + timestamp
|
|
552
|
+
* Persiste le preferenze e marca prova legale (consentId + timestamp + TTL +
|
|
553
|
+
* policyVersion + source).
|
|
387
554
|
*/
|
|
388
|
-
declare function savePreferences(prefs: ConsentState):
|
|
555
|
+
declare function savePreferences(prefs: ConsentState, source?: ConsentSource): ConsentState;
|
|
389
556
|
/**
|
|
390
557
|
* Accetta tutte le categorie e chiude il banner.
|
|
391
558
|
*/
|
|
392
|
-
declare function acceptAll():
|
|
559
|
+
declare function acceptAll(source?: ConsentSource): ConsentState;
|
|
393
560
|
/**
|
|
394
561
|
* Rifiuta tutte le categorie opzionali e chiude il banner.
|
|
395
562
|
*/
|
|
396
|
-
declare function declineAll():
|
|
563
|
+
declare function declineAll(source?: ConsentSource): ConsentState;
|
|
397
564
|
/**
|
|
398
565
|
* Cancella il consenso persistito e riapre il banner iniziale.
|
|
399
566
|
*/
|
|
@@ -403,6 +570,246 @@ declare function resetConsent(): void;
|
|
|
403
570
|
*/
|
|
404
571
|
declare function setModalOpen(open: boolean): void;
|
|
405
572
|
|
|
573
|
+
type GtagFn = (...args: unknown[]) => void;
|
|
574
|
+
declare global {
|
|
575
|
+
interface Window {
|
|
576
|
+
dataLayer?: unknown[];
|
|
577
|
+
gtag?: GtagFn;
|
|
578
|
+
__gLegalConsentBooted?: boolean;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
interface ConsentModeBootProps {
|
|
582
|
+
/**
|
|
583
|
+
* Regioni a cui restringere la modalità di consenso. Lasciato vuoto = global.
|
|
584
|
+
* @example ["EEA", "UK", "CH"]
|
|
585
|
+
*/
|
|
586
|
+
regions?: string[];
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Boot di Google Consent Mode v2: inizializza `dataLayer`, `gtag` e imposta
|
|
590
|
+
* il default `denied` per i segnali pubblicitari/analitici prima che qualsiasi
|
|
591
|
+
* tracker Google parta. Da montare UNA volta nel layout, prima dei componenti
|
|
592
|
+
* `GoogleAnalyticsLegal`, `GoogleAdsLegal`, `GTMLegal`.
|
|
593
|
+
*
|
|
594
|
+
* Al cambiare delle scelte dell'utente emette `gtag('consent','update', …)`
|
|
595
|
+
* mappando le categorie del CMP sui segnali Google.
|
|
596
|
+
*/
|
|
597
|
+
declare function ConsentModeBoot({ regions }?: ConsentModeBootProps): react_jsx_runtime.JSX.Element;
|
|
598
|
+
|
|
599
|
+
interface GoogleAnalyticsLegalProps {
|
|
600
|
+
/** Misurazione GA4: `G-XXXXXXX`. */
|
|
601
|
+
gaId: string;
|
|
602
|
+
/** Categoria di consenso richiesta. Default `statistical`. */
|
|
603
|
+
category?: TrackableCategory;
|
|
604
|
+
/** Anonimizza l'IP a livello config. Default `true`. */
|
|
605
|
+
anonymizeIp?: boolean;
|
|
606
|
+
/** Invia il `page_view` automatico. Default `true`. */
|
|
607
|
+
sendPageViews?: boolean;
|
|
608
|
+
/** Attiva `debug_mode` per GA DebugView. */
|
|
609
|
+
debug?: boolean;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Carica GA4 solo dopo che l'utente ha concesso la categoria indicata.
|
|
613
|
+
* Lavora insieme a `<ConsentModeBoot/>`: prima del consenso lo script non
|
|
614
|
+
* viene neppure scaricato, dopo il consenso le opzioni Consent Mode v2
|
|
615
|
+
* vengono aggiornate dal boot.
|
|
616
|
+
*/
|
|
617
|
+
declare function GoogleAnalyticsLegal({ gaId, category, anonymizeIp, sendPageViews, debug, }: GoogleAnalyticsLegalProps): null;
|
|
618
|
+
/**
|
|
619
|
+
* Hook per inviare eventi GA4 custom. Diventa no-op senza consenso, così il
|
|
620
|
+
* call-site non deve mai controllare prima di chiamare.
|
|
621
|
+
*/
|
|
622
|
+
declare function useGAEvent(): (eventName: string, params?: Record<string, unknown>) => void;
|
|
623
|
+
|
|
624
|
+
interface AdsConversion {
|
|
625
|
+
/** Stringa completa `send_to` (es. `AW-1234567890/AbCdEfGhIj`). */
|
|
626
|
+
sendTo: string;
|
|
627
|
+
value?: number;
|
|
628
|
+
currency?: string;
|
|
629
|
+
}
|
|
630
|
+
interface GoogleAdsLegalProps {
|
|
631
|
+
/** ID account Google Ads, formato `AW-XXXXXXX`. */
|
|
632
|
+
conversionId: string;
|
|
633
|
+
/** Mappa eventi → conversion. Recuperabile via `useAdsConversion(key)`. */
|
|
634
|
+
conversions?: Record<string, AdsConversion>;
|
|
635
|
+
/** Categoria di consenso richiesta. Default `marketing`. */
|
|
636
|
+
category?: TrackableCategory;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Carica il tag Google Ads (gtag.js per AW-…) e registra le conversioni
|
|
640
|
+
* dichiarative usate da `useAdsConversion()`. Gated dalla categoria
|
|
641
|
+
* `marketing` per default.
|
|
642
|
+
*
|
|
643
|
+
* Scrive `registeredConversions` durante render (idempotente sui prop):
|
|
644
|
+
* un `useAdsConversion` invocato immediatamente dopo il mount trova già
|
|
645
|
+
* la mappa pronta.
|
|
646
|
+
*/
|
|
647
|
+
declare function GoogleAdsLegal({ conversionId, conversions, category, }: GoogleAdsLegalProps): null;
|
|
648
|
+
/**
|
|
649
|
+
* Restituisce una funzione che invia la conversion mappata su `key`. No-op se
|
|
650
|
+
* il consenso `marketing` non è attivo o la chiave non è registrata.
|
|
651
|
+
*/
|
|
652
|
+
declare function useAdsConversion(key: string): (overrides?: Partial<AdsConversion> & Record<string, unknown>) => void;
|
|
653
|
+
|
|
654
|
+
type FbqFn = ((...args: unknown[]) => void) & {
|
|
655
|
+
callMethod?: (...args: unknown[]) => void;
|
|
656
|
+
queue: unknown[][];
|
|
657
|
+
push: FbqFn;
|
|
658
|
+
loaded: boolean;
|
|
659
|
+
version: string;
|
|
660
|
+
};
|
|
661
|
+
declare global {
|
|
662
|
+
interface Window {
|
|
663
|
+
fbq?: FbqFn;
|
|
664
|
+
_fbq?: FbqFn;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
interface MetaPixelLegalProps {
|
|
668
|
+
/** Meta Pixel ID numerico. */
|
|
669
|
+
pixelId: string;
|
|
670
|
+
/** Categoria di consenso richiesta. Default `marketing`. */
|
|
671
|
+
category?: TrackableCategory;
|
|
672
|
+
/** Traccia PageView automatico all'init. Default `true`. */
|
|
673
|
+
autoPageView?: boolean;
|
|
674
|
+
/**
|
|
675
|
+
* Whitelist di eventi pixel autorizzati lato site (es. `["Lead","Contact"]`).
|
|
676
|
+
* `useMetaEvent(name)` rifiuta eventi fuori da questa lista.
|
|
677
|
+
*/
|
|
678
|
+
events?: readonly string[];
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Carica il Meta Pixel solo dopo consenso `marketing`. Su revoca emette
|
|
682
|
+
* `fbq('consent','revoke')` per fermare la trasmissione (lo script non viene
|
|
683
|
+
* rimosso ma resta inerte fino al prossimo grant).
|
|
684
|
+
*/
|
|
685
|
+
declare function MetaPixelLegal({ pixelId, category, autoPageView, events, }: MetaPixelLegalProps): null;
|
|
686
|
+
/**
|
|
687
|
+
* Restituisce una funzione `track` per eventi pixel. Verifica il consenso
|
|
688
|
+
* `marketing` e (se configurata) la whitelist `events` su `MetaPixelLegal`.
|
|
689
|
+
*/
|
|
690
|
+
declare function useMetaEvent(eventName: string): (params?: Record<string, unknown>) => void;
|
|
691
|
+
|
|
692
|
+
interface GTMLegalProps {
|
|
693
|
+
/** Container GTM, formato `GTM-XXXXXXX`. */
|
|
694
|
+
containerId: string;
|
|
695
|
+
/** Categoria di consenso richiesta. Default `marketing`. */
|
|
696
|
+
category?: TrackableCategory;
|
|
697
|
+
/** Nome del dataLayer (se diverso dal default). */
|
|
698
|
+
dataLayerName?: string;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Carica Google Tag Manager solo dopo consenso. Lascia ai tag interni di GTM
|
|
702
|
+
* la gestione fine-grained via Consent Mode v2 (già configurato di default
|
|
703
|
+
* `denied` da `<ConsentModeBoot/>`).
|
|
704
|
+
*/
|
|
705
|
+
declare function GTMLegal({ containerId, category, dataLayerName, }: GTMLegalProps): null;
|
|
706
|
+
|
|
707
|
+
type HjFn = ((...args: unknown[]) => void) & {
|
|
708
|
+
q?: unknown[][];
|
|
709
|
+
};
|
|
710
|
+
declare global {
|
|
711
|
+
interface Window {
|
|
712
|
+
hj?: HjFn;
|
|
713
|
+
_hjSettings?: {
|
|
714
|
+
hjid: number;
|
|
715
|
+
hjsv: number;
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
interface HotjarLegalProps {
|
|
720
|
+
/** Hotjar Site ID numerico (visibile in Settings → Site & Org). */
|
|
721
|
+
siteId: number;
|
|
722
|
+
/** Snippet version Hotjar. Default `6` (corrente al 2026). */
|
|
723
|
+
snippetVersion?: number;
|
|
724
|
+
/**
|
|
725
|
+
* Categoria di consenso richiesta. Hotjar registra session recording +
|
|
726
|
+
* heatmap → trattamento statistico/comportamentale. Default `statistical`.
|
|
727
|
+
* Imposta `marketing` se la finalità dichiarata in policy è profilazione.
|
|
728
|
+
*/
|
|
729
|
+
category?: TrackableCategory;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Carica Hotjar solo dopo consenso. Session recording, heatmap, surveys e
|
|
733
|
+
* feedback widget restano inattivi finché il consenso non è espresso.
|
|
734
|
+
*/
|
|
735
|
+
declare function HotjarLegal({ siteId, snippetVersion, category, }: HotjarLegalProps): null;
|
|
736
|
+
/**
|
|
737
|
+
* Hook per inviare eventi Hotjar custom. No-op senza consenso.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* const track = useHotjarEvent();
|
|
741
|
+
* track("contact_form_submit");
|
|
742
|
+
*/
|
|
743
|
+
declare function useHotjarEvent(category?: TrackableCategory): (eventName: string) => void;
|
|
744
|
+
/**
|
|
745
|
+
* Hook per `hj('identify', userId, attributes)`. No-op senza consenso.
|
|
746
|
+
* Usalo solo per utenti loggati con base giuridica appropriata.
|
|
747
|
+
*/
|
|
748
|
+
declare function useHotjarIdentify(category?: TrackableCategory): (userId: string | null, attributes?: Record<string, unknown>) => void;
|
|
749
|
+
|
|
750
|
+
interface EmailJSLegalProps {
|
|
751
|
+
/** ID servizio EmailJS (es. `service_xxx`). */
|
|
752
|
+
serviceId: string;
|
|
753
|
+
/** ID template EmailJS (es. `template_xxx`). */
|
|
754
|
+
templateId: string;
|
|
755
|
+
/** Public key EmailJS (`NEXT_PUBLIC_EMAILJS_USER_ID`). */
|
|
756
|
+
publicKey: string;
|
|
757
|
+
/**
|
|
758
|
+
* Se `true` (default), `send()` rifiuta finché un input
|
|
759
|
+
* `name="_legalConsent"` non risulta `checked`. Disabilita solo se la
|
|
760
|
+
* raccolta avviene già con consenso documentato altrove (es. account loggato).
|
|
761
|
+
*/
|
|
762
|
+
requireExplicitConsent?: boolean;
|
|
763
|
+
/**
|
|
764
|
+
* Retention dei dati submitter dichiarata in policy (string per la UI,
|
|
765
|
+
* la retention effettiva dipende dal backend EmailJS / inbox).
|
|
766
|
+
*/
|
|
767
|
+
retentionDays?: number;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Config holder per la pipeline EmailJS. Non renderizza nulla; espone i valori
|
|
771
|
+
* al hook `useEmailJS()` montato nei form. Tipicamente piazzato accanto a
|
|
772
|
+
* `<ConsentModeBoot/>` nel layout root.
|
|
773
|
+
*
|
|
774
|
+
* Scrive in `config` durante render (non in `useEffect`): un submit immediato
|
|
775
|
+
* dopo l'hydration trova la config già pronta, evitando false `CONFIG_MISSING`.
|
|
776
|
+
* L'operazione è idempotente: re-render con stessi prop scrive gli stessi valori.
|
|
777
|
+
*/
|
|
778
|
+
declare function EmailJSLegal({ serviceId, templateId, publicKey, requireExplicitConsent, }: EmailJSLegalProps): null;
|
|
779
|
+
type EmailJSSendStatus = "idle" | "loading" | "success" | "error";
|
|
780
|
+
interface SendResult {
|
|
781
|
+
ok: boolean;
|
|
782
|
+
error?: "CONSENT_MISSING" | "CONFIG_MISSING" | "MODULE_MISSING" | "SEND_FAILED";
|
|
783
|
+
detail?: unknown;
|
|
784
|
+
}
|
|
785
|
+
interface ConsentCheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "name"> {
|
|
786
|
+
label?: ReactNode;
|
|
787
|
+
/** Link alla privacy policy. Default `/privacy-policy`. */
|
|
788
|
+
privacyHref?: string;
|
|
789
|
+
/** Label del link policy. Default tradotta. */
|
|
790
|
+
privacyLabel?: ReactNode;
|
|
791
|
+
className?: string;
|
|
792
|
+
style?: CSSProperties;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* Checkbox a11y per il consenso al trattamento. Identità stabile: definito a
|
|
796
|
+
* livello modulo per non re-istanziarsi a ogni render del form che lo ospita
|
|
797
|
+
* (altrimenti la subtree perderebbe focus/state ad ogni re-render).
|
|
798
|
+
*/
|
|
799
|
+
declare function ConsentCheckbox({ label, privacyHref, privacyLabel, className, style, ...rest }: ConsentCheckboxProps): react_jsx_runtime.JSX.Element;
|
|
800
|
+
/**
|
|
801
|
+
* Hook che valida + stampa il consenso e invia il form via EmailJS.
|
|
802
|
+
*
|
|
803
|
+
* Restituisce inoltre `ConsentCheckbox`, un componente pronto da incollare nel
|
|
804
|
+
* form: il `send()` cerca un input con `name="_legalConsent"`.
|
|
805
|
+
*/
|
|
806
|
+
declare function useEmailJS(): {
|
|
807
|
+
send: (form: HTMLFormElement) => Promise<SendResult>;
|
|
808
|
+
status: EmailJSSendStatus;
|
|
809
|
+
reset: () => void;
|
|
810
|
+
ConsentCheckbox: typeof ConsentCheckbox;
|
|
811
|
+
};
|
|
812
|
+
|
|
406
813
|
/**
|
|
407
814
|
* Catalogo di servizi pre-configurati identificati per id (es. "google-analytics").
|
|
408
815
|
*/
|
|
@@ -417,4 +824,4 @@ declare const resolveService: (ref: string | LegalService) => LegalService;
|
|
|
417
824
|
*/
|
|
418
825
|
declare const DEFAULT_PRIMARY_COLOR = "#2c5282";
|
|
419
826
|
|
|
420
|
-
export { type CompanyConfig, ConsentBanner, type ConsentState, DEFAULT_PRIMARY_COLOR, FloatingConsentToggle, type Language, LegalConfigProvider, type LegalService, PreferenceCard, PreferenceModal, SERVICE_PRESETS, ServiceGrid, type ServiceReference, type TogglePosition, type TranslationKey, type Translator, acceptAll, declineAll, hydrateFromStorage, resetConsent, resolveService, savePreferences, setLanguage, setModalOpen, useConsent, useLegalConfig, useLegalConfigOptional, useLegalLanguage, useModalOpen, useShowBanner, useT };
|
|
827
|
+
export { CONSENT_TTL_MS, type CompanyConfig, ConsentBanner, type ConsentCategory, ConsentCheckbox, ConsentGate, ConsentModeBoot, type ConsentSource, type ConsentState, DEFAULT_PRIMARY_COLOR, type DpoInfo, EmailJSLegal, FloatingConsentToggle, GTMLegal, GoogleAdsLegal, GoogleAnalyticsLegal, HotjarLegal, type Language, LegalConfigProvider, type LegalService, MetaPixelLegal, PreferenceCard, PreferenceModal, type Processor, type RetentionMap, SERVICE_PRESETS, ServiceGrid, type ServiceReference, type TogglePosition, type TrackableCategory, type TranslationKey, type Translator, acceptAll, declineAll, getSnapshot as getConsentSnapshot, hydrateFromStorage, resetConsent, resolveService, savePreferences, setLanguage, setModalOpen, subscribe as subscribeConsent, useAdsConversion, useConsent, useConsentCategory, useEmailJS, useGAEvent, useHotjarEvent, useHotjarIdentify, useIsHydrated, useLegalConfig, useLegalConfigOptional, useLegalLanguage, useMetaEvent, useModalOpen, useShowBanner, useT };
|