@graffico/legal 0.3.11 → 0.3.13
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 +370 -341
- package/dist/index.d.ts +109 -19
- package/dist/index.js +2 -2
- package/dist/next.d.cts +16 -0
- package/dist/next.d.ts +16 -0
- package/dist/server.d.ts +20 -2
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,17 @@ import { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* Banner di consenso GDPR. Tipografia compressa su mobile (`text-base` /
|
|
6
6
|
* `text-[11px]`) per evitare di diventare LCP candidate quando il viewport è
|
|
7
|
-
* piccolo; su desktop torna alle dimensioni piene.
|
|
8
|
-
*
|
|
7
|
+
* piccolo; su desktop torna alle dimensioni piene. La X chiude mantenendo le
|
|
8
|
+
* impostazioni di default, senza alcun consenso (Garante 10/06/2021, par. 7.1).
|
|
9
|
+
* Il testo cita solo le finalità a consenso in uso (`getTrackingPurposes`).
|
|
9
10
|
*/
|
|
10
11
|
declare const ConsentBanner: () => react_jsx_runtime.JSX.Element;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Modale per regolare in dettaglio le preferenze per categoria di tracker.
|
|
15
|
+
* Dialog modale: il focus entra all'apertura e resta dentro col Tab, Esc
|
|
16
|
+
* chiude senza salvare (come la X), alla chiusura il focus torna a chi l'ha
|
|
17
|
+
* aperta.
|
|
14
18
|
*/
|
|
15
19
|
declare const PreferenceModal: () => react_jsx_runtime.JSX.Element | null;
|
|
16
20
|
|
|
@@ -29,7 +33,10 @@ declare const TRANSLATIONS: {
|
|
|
29
33
|
bannerTitle: string;
|
|
30
34
|
bannerDescription: string;
|
|
31
35
|
bannerDescriptionMeasurement: string;
|
|
36
|
+
bannerDescriptionMarketing: string;
|
|
37
|
+
bannerDescriptionExternalContent: string;
|
|
32
38
|
bannerDescriptionEnd: string;
|
|
39
|
+
bannerDescriptionTechnicalOnly: string;
|
|
33
40
|
cookiePolicyLink: string;
|
|
34
41
|
decline: string;
|
|
35
42
|
customize: string;
|
|
@@ -44,6 +51,20 @@ declare const TRANSLATIONS: {
|
|
|
44
51
|
measurementDescription: string;
|
|
45
52
|
marketingTitle: string;
|
|
46
53
|
marketingDescription: string;
|
|
54
|
+
externalContentTitle: string;
|
|
55
|
+
externalContentDescription: string;
|
|
56
|
+
closeWithoutAccepting: string;
|
|
57
|
+
bannerCloseNotice: string;
|
|
58
|
+
reviewCookieChoices: string;
|
|
59
|
+
providersLabel: string;
|
|
60
|
+
retentionDay: string;
|
|
61
|
+
retentionDays: string;
|
|
62
|
+
retentionWeek: string;
|
|
63
|
+
retentionWeeks: string;
|
|
64
|
+
retentionMonth: string;
|
|
65
|
+
retentionMonths: string;
|
|
66
|
+
retentionYear: string;
|
|
67
|
+
retentionYears: string;
|
|
47
68
|
consentId: string;
|
|
48
69
|
consentDate: string;
|
|
49
70
|
consentPolicyVersion: string;
|
|
@@ -142,9 +163,13 @@ declare const TRANSLATIONS: {
|
|
|
142
163
|
lawfulBasisPublicTask: string;
|
|
143
164
|
lawfulBasisNotDeclared: string;
|
|
144
165
|
profilingTitle: string;
|
|
166
|
+
profilingMarketingNote: string;
|
|
145
167
|
profilingDeclaredYes: string;
|
|
146
168
|
profilingDeclaredNo: string;
|
|
147
169
|
cookieTableTitle: string;
|
|
170
|
+
consentRecordName: string;
|
|
171
|
+
consentRecordPurpose: string;
|
|
172
|
+
consentRecordDuration: string;
|
|
148
173
|
cookieTableIntro: string;
|
|
149
174
|
cookieTableName: string;
|
|
150
175
|
cookieTableProvider: string;
|
|
@@ -165,6 +190,7 @@ declare const TRANSLATIONS: {
|
|
|
165
190
|
introDescription2: string;
|
|
166
191
|
usageTrackingTitle: string;
|
|
167
192
|
usageTrackingDescription: string;
|
|
193
|
+
usageTrackingDescriptionTechnicalOnly: string;
|
|
168
194
|
managePreferencesTitle: string;
|
|
169
195
|
managePreferencesDescription1: string;
|
|
170
196
|
managePreferencesDescription2: string;
|
|
@@ -218,7 +244,10 @@ declare const TRANSLATIONS: {
|
|
|
218
244
|
bannerTitle: string;
|
|
219
245
|
bannerDescription: string;
|
|
220
246
|
bannerDescriptionMeasurement: string;
|
|
247
|
+
bannerDescriptionMarketing: string;
|
|
248
|
+
bannerDescriptionExternalContent: string;
|
|
221
249
|
bannerDescriptionEnd: string;
|
|
250
|
+
bannerDescriptionTechnicalOnly: string;
|
|
222
251
|
cookiePolicyLink: string;
|
|
223
252
|
decline: string;
|
|
224
253
|
customize: string;
|
|
@@ -233,6 +262,20 @@ declare const TRANSLATIONS: {
|
|
|
233
262
|
measurementDescription: string;
|
|
234
263
|
marketingTitle: string;
|
|
235
264
|
marketingDescription: string;
|
|
265
|
+
externalContentTitle: string;
|
|
266
|
+
externalContentDescription: string;
|
|
267
|
+
closeWithoutAccepting: string;
|
|
268
|
+
bannerCloseNotice: string;
|
|
269
|
+
reviewCookieChoices: string;
|
|
270
|
+
providersLabel: string;
|
|
271
|
+
retentionDay: string;
|
|
272
|
+
retentionDays: string;
|
|
273
|
+
retentionWeek: string;
|
|
274
|
+
retentionWeeks: string;
|
|
275
|
+
retentionMonth: string;
|
|
276
|
+
retentionMonths: string;
|
|
277
|
+
retentionYear: string;
|
|
278
|
+
retentionYears: string;
|
|
236
279
|
consentId: string;
|
|
237
280
|
consentDate: string;
|
|
238
281
|
consentPolicyVersion: string;
|
|
@@ -331,9 +374,13 @@ declare const TRANSLATIONS: {
|
|
|
331
374
|
lawfulBasisPublicTask: string;
|
|
332
375
|
lawfulBasisNotDeclared: string;
|
|
333
376
|
profilingTitle: string;
|
|
377
|
+
profilingMarketingNote: string;
|
|
334
378
|
profilingDeclaredYes: string;
|
|
335
379
|
profilingDeclaredNo: string;
|
|
336
380
|
cookieTableTitle: string;
|
|
381
|
+
consentRecordName: string;
|
|
382
|
+
consentRecordPurpose: string;
|
|
383
|
+
consentRecordDuration: string;
|
|
337
384
|
cookieTableIntro: string;
|
|
338
385
|
cookieTableName: string;
|
|
339
386
|
cookieTableProvider: string;
|
|
@@ -354,6 +401,7 @@ declare const TRANSLATIONS: {
|
|
|
354
401
|
introDescription2: string;
|
|
355
402
|
usageTrackingTitle: string;
|
|
356
403
|
usageTrackingDescription: string;
|
|
404
|
+
usageTrackingDescriptionTechnicalOnly: string;
|
|
357
405
|
managePreferencesTitle: string;
|
|
358
406
|
managePreferencesDescription1: string;
|
|
359
407
|
managePreferencesDescription2: string;
|
|
@@ -425,13 +473,30 @@ interface CookieDeclaration {
|
|
|
425
473
|
duration: string;
|
|
426
474
|
type: CookieType;
|
|
427
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Categoria di consenso gestita dal CMP.
|
|
478
|
+
*/
|
|
479
|
+
type ConsentCategory = "necessary" | "statistical" | "marketing" | "externalContent";
|
|
480
|
+
/**
|
|
481
|
+
* Sottoinsieme di categorie che possono "gating" lo script di un tracker.
|
|
482
|
+
* Esclude `necessary` perché i tracker tecnici non sono mai opt-in.
|
|
483
|
+
*/
|
|
484
|
+
type TrackableCategory = Exclude<ConsentCategory, "necessary">;
|
|
428
485
|
/**
|
|
429
486
|
* Tracker o servizio terzo dichiarato in cookie/privacy policy.
|
|
430
487
|
*/
|
|
431
488
|
interface LegalService {
|
|
432
489
|
id: string;
|
|
433
490
|
name: string;
|
|
491
|
+
/** Modalità di raccolta dei dati (non la categoria di consenso). */
|
|
434
492
|
category: "automatic" | "provided" | "marketing";
|
|
493
|
+
/**
|
|
494
|
+
* Categoria di consenso del banner che abilita il servizio: decide quali
|
|
495
|
+
* finalità citano banner e cookie policy. `necessary` = non serve consenso
|
|
496
|
+
* da banner (tecnico, o dati forniti tramite form). Se assente viene dedotta
|
|
497
|
+
* da `cookies[].type` e `lawfulBasis`.
|
|
498
|
+
*/
|
|
499
|
+
consentCategory?: ConsentCategory;
|
|
435
500
|
logo?: string;
|
|
436
501
|
purposes: string[];
|
|
437
502
|
dataCollected: string[];
|
|
@@ -531,21 +596,27 @@ interface CompanyConfig {
|
|
|
531
596
|
* Default: `false`.
|
|
532
597
|
*/
|
|
533
598
|
automatedDecisionMaking?: boolean;
|
|
599
|
+
/** Percorso della privacy policy. Default `/privacy-policy`. */
|
|
600
|
+
privacyPolicyPath?: string;
|
|
601
|
+
/** Percorso della cookie policy. Default `/cookie-policy`. */
|
|
602
|
+
cookiePolicyPath?: string;
|
|
534
603
|
}
|
|
535
604
|
/**
|
|
536
605
|
* Origine della scelta di consenso salvata. Utile per audit.
|
|
537
606
|
*/
|
|
538
607
|
type ConsentSource = "banner" | "modal" | "gpc-auto" | "api";
|
|
539
608
|
/**
|
|
540
|
-
* Stato di consenso persistito per categoria, con
|
|
609
|
+
* Stato di consenso persistito per categoria, con riferimenti della scelta e TTL.
|
|
541
610
|
*/
|
|
542
611
|
interface ConsentState {
|
|
543
612
|
necessary: boolean;
|
|
544
613
|
statistical: boolean;
|
|
545
614
|
marketing: boolean;
|
|
615
|
+
/** Mappe, video e altri contenuti ospitati da terzi. */
|
|
616
|
+
externalContent: boolean;
|
|
546
617
|
consentId?: string;
|
|
547
618
|
timestamp?: string;
|
|
548
|
-
/** Epoch ms oltre cui il consenso scade e va riproposto (
|
|
619
|
+
/** Epoch ms oltre cui il consenso scade e va riproposto (180 giorni). */
|
|
549
620
|
expiresAt?: number;
|
|
550
621
|
/** Versione delle policy al momento del consenso. */
|
|
551
622
|
policyVersion?: string;
|
|
@@ -574,21 +645,12 @@ interface ServiceGridProps {
|
|
|
574
645
|
*/
|
|
575
646
|
declare const ServiceGrid: ({ config: configProp, language: langProp, }?: ServiceGridProps) => react_jsx_runtime.JSX.Element | null;
|
|
576
647
|
|
|
577
|
-
/**
|
|
578
|
-
* Categoria di consenso gestita dal CMP.
|
|
579
|
-
*/
|
|
580
|
-
type ConsentCategory = "necessary" | "statistical" | "marketing";
|
|
581
|
-
/**
|
|
582
|
-
* Sottoinsieme di categorie che possono "gating" lo script di un tracker.
|
|
583
|
-
* Esclude `necessary` perché i tracker tecnici non sono mai opt-in.
|
|
584
|
-
*/
|
|
585
|
-
type TrackableCategory = Exclude<ConsentCategory, "necessary">;
|
|
586
648
|
/**
|
|
587
649
|
* Lingua corrente normalizzata, reattiva ai cambi via bridge i18n.
|
|
588
650
|
*/
|
|
589
651
|
declare const useLegalLanguage: () => Language;
|
|
590
652
|
/**
|
|
591
|
-
* Stato di consenso corrente (
|
|
653
|
+
* Stato di consenso corrente (categorie + riferimenti della scelta).
|
|
592
654
|
*/
|
|
593
655
|
declare const useConsent: () => ConsentState;
|
|
594
656
|
/**
|
|
@@ -631,14 +693,24 @@ interface ConsentGateProps {
|
|
|
631
693
|
*/
|
|
632
694
|
declare function ConsentGate({ category, children, fallback, renderWhileHydrating, }: ConsentGateProps): react_jsx_runtime.JSX.Element;
|
|
633
695
|
|
|
696
|
+
interface ConsentPreferencesLinkProps {
|
|
697
|
+
className?: string;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Link da mettere nel footer per rivedere le scelte in ogni momento
|
|
701
|
+
* (Garante 10/06/2021, par. 7.1).
|
|
702
|
+
*/
|
|
703
|
+
declare function ConsentPreferencesLink({ className, }: ConsentPreferencesLinkProps): react_jsx_runtime.JSX.Element;
|
|
704
|
+
|
|
634
705
|
interface Props {
|
|
635
706
|
language: Language;
|
|
636
707
|
primaryColor: string;
|
|
708
|
+
privacyPolicyPath?: string;
|
|
637
709
|
}
|
|
638
710
|
/**
|
|
639
711
|
* Card "centro preferenze" della cookie policy: gestisci o resetta consenso.
|
|
640
712
|
*/
|
|
641
|
-
declare function PreferenceCard({ language, primaryColor }: Props): react_jsx_runtime.JSX.Element;
|
|
713
|
+
declare function PreferenceCard({ language, primaryColor, privacyPolicyPath, }: Props): react_jsx_runtime.JSX.Element;
|
|
642
714
|
|
|
643
715
|
interface LegalConfigProviderProps {
|
|
644
716
|
config: CompanyConfig;
|
|
@@ -660,10 +732,15 @@ interface ClientState {
|
|
|
660
732
|
hydrated: boolean;
|
|
661
733
|
/** Versione delle policy attiva. Stampata nel consenso al save. */
|
|
662
734
|
activePolicyVersion?: string;
|
|
735
|
+
/**
|
|
736
|
+
* Categorie richieste dai tracker `*Legal` e dai `ConsentGate` montati: il
|
|
737
|
+
* banner le cita anche se il servizio manca da `services[]`.
|
|
738
|
+
*/
|
|
739
|
+
requestedCategories: readonly TrackableCategory[];
|
|
663
740
|
}
|
|
664
741
|
/**
|
|
665
742
|
* Durata di validità del consenso in millisecondi.
|
|
666
|
-
*
|
|
743
|
+
* 180 giorni, circa i 6 mesi indicati dal Garante (10/06/2021) per riproporre il banner.
|
|
667
744
|
*/
|
|
668
745
|
declare const CONSENT_TTL_MS: number;
|
|
669
746
|
/**
|
|
@@ -690,7 +767,7 @@ interface HydrateOptions {
|
|
|
690
767
|
*/
|
|
691
768
|
declare function hydrateFromStorage(opts?: HydrateOptions): void;
|
|
692
769
|
/**
|
|
693
|
-
* Persiste le preferenze
|
|
770
|
+
* Persiste le preferenze con i riferimenti della scelta (consentId + timestamp + TTL +
|
|
694
771
|
* policyVersion + source).
|
|
695
772
|
*/
|
|
696
773
|
declare function savePreferences(prefs: ConsentState, source?: ConsentSource): ConsentState;
|
|
@@ -957,7 +1034,7 @@ interface UseEmailJSOptions {
|
|
|
957
1034
|
}
|
|
958
1035
|
interface ConsentCheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "name"> {
|
|
959
1036
|
label?: ReactNode;
|
|
960
|
-
/** Link alla privacy policy. Default `/privacy-policy`. */
|
|
1037
|
+
/** Link alla privacy policy. Default `privacyPolicyPath` della config, poi `/privacy-policy`. */
|
|
961
1038
|
privacyHref?: string;
|
|
962
1039
|
/** Label del link policy. Default tradotta. */
|
|
963
1040
|
privacyLabel?: ReactNode;
|
|
@@ -991,6 +1068,19 @@ declare const SERVICE_PRESETS: Record<string, LegalService>;
|
|
|
991
1068
|
*/
|
|
992
1069
|
declare const resolveService: (ref: string | LegalService) => LegalService;
|
|
993
1070
|
|
|
1071
|
+
/**
|
|
1072
|
+
* Finalità soggette a consenso effettivamente in uso sul sito. Guidano il testo
|
|
1073
|
+
* di banner e cookie policy: l'informativa breve deve citare le finalità dei
|
|
1074
|
+
* tracker che richiedono consenso (Garante 10/06/2021).
|
|
1075
|
+
*/
|
|
1076
|
+
type TrackingPurpose = "measurement" | "marketing" | "externalContent";
|
|
1077
|
+
/**
|
|
1078
|
+
* Finalità in uso secondo i `services[]` dichiarati e le categorie richieste
|
|
1079
|
+
* dai tracker/gate montati. La misurazione sparisce solo se è certo che non
|
|
1080
|
+
* serve (nessun servizio ignoto). Lista vuota = solo finalità tecniche.
|
|
1081
|
+
*/
|
|
1082
|
+
declare function getTrackingPurposes(services?: ServiceReference[], requested?: readonly ConsentCategory[]): TrackingPurpose[];
|
|
1083
|
+
|
|
994
1084
|
declare const DEFAULT_PRIMARY_COLOR = "#2c5282";
|
|
995
1085
|
|
|
996
|
-
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, LinkedInInsightLegal, 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, useLinkedInInsightEvent, useMetaEvent, useModalOpen, useShowBanner, useT };
|
|
1086
|
+
export { CONSENT_TTL_MS, type CompanyConfig, ConsentBanner, type ConsentCategory, ConsentCheckbox, ConsentGate, ConsentModeBoot, ConsentPreferencesLink, type ConsentSource, type ConsentState, DEFAULT_PRIMARY_COLOR, type DpoInfo, EmailJSLegal, FloatingConsentToggle, GTMLegal, GoogleAdsLegal, GoogleAnalyticsLegal, HotjarLegal, type Language, LegalConfigProvider, type LegalService, LinkedInInsightLegal, 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, getTrackingPurposes, hydrateFromStorage, resetConsent, resolveService, savePreferences, setLanguage, setModalOpen, subscribe as subscribeConsent, useAdsConversion, useConsent, useConsentCategory, useEmailJS, useGAEvent, useHotjarEvent, useHotjarIdentify, useIsHydrated, useLegalConfig, useLegalConfigOptional, useLegalLanguage, useLinkedInInsightEvent, useMetaEvent, useModalOpen, useShowBanner, useT };
|