@c15t/react 3.0.0-alpha.2 → 3.0.0-alpha.3
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/AGENTS.md +6 -1
- package/dist/aggregate-components.js +1 -1
- package/dist/chunk-warming.js +1 -1
- package/dist/component-hooks/use-headless-iab-consent-ui.js +1 -1
- package/dist/component-hooks/use-panel-trigger.js +1 -1
- package/dist/components/consent-gate/consent-gate.js +1 -1
- package/dist/components/consent-preferences-link/consent-preferences-link.js +1 -1
- package/dist/components/iab-panel/atoms/purpose-item.js +1 -1
- package/dist/components/iab-panel/atoms/stack-item.js +1 -1
- package/dist/components/iab-panel/iab-panel.js +1 -1
- package/dist/components/iab-panel/index.js +1 -1
- package/dist/components/panel/atoms/overlay.js +1 -1
- package/dist/components/panel/atoms/root.js +1 -1
- package/dist/components/panel/index.js +1 -1
- package/dist/components/panel/panel.js +1 -1
- package/dist/components/panel-trigger/atoms/button.js +1 -1
- package/dist/components/panel-trigger/atoms/icon.js +1 -1
- package/dist/components/panel-trigger/atoms/root.js +1 -1
- package/dist/components/panel-trigger/atoms/trigger-icons.js +1 -0
- package/dist/components/panel-trigger/panel-trigger-toolbar.js +1 -1
- package/dist/components/preferences/atoms/accordion.js +1 -1
- package/dist/components/preferences/atoms/root.js +1 -1
- package/dist/components/preferences/atoms/vendor-list.js +1 -1
- package/dist/components/preferences/index.js +1 -1
- package/dist/components/prompt/policy-actions.js +1 -1
- package/dist/components/shared/primitives/button.js +1 -1
- package/dist/components/shared/ui/accordion/accordion.js +1 -1
- package/dist/components/shared/ui/collapsible/collapsible.js +1 -1
- package/dist/components/shared/ui/logo.js +1 -1
- package/dist/components/shared/ui/preference-item/preference-item.js +1 -1
- package/dist/components/shared/ui/switch/switch.js +1 -1
- package/dist/components/shared/ui/tabs/tabs.js +1 -1
- package/dist/consent-theme.js +1 -0
- package/dist/draft.js +1 -1
- package/dist/external-iab-context.js +1 -1
- package/dist/headless.js +1 -1
- package/dist/hooks/use-committed-ref.js +2 -0
- package/dist/hooks.js +1 -1
- package/dist/iab/styles.tw3.css +1 -41
- package/dist/iab-context.js +1 -1
- package/dist/index.js +1 -1
- package/dist/kernel-selector.js +1 -0
- package/dist/module-hooks/iframe-blocker.js +1 -1
- package/dist/module-hooks/network-blocker.js +1 -1
- package/dist/module-hooks/network-hold.js +2 -0
- package/dist/module-hooks/persistence.js +1 -1
- package/dist/panel.js +1 -1
- package/dist/preferences.js +1 -2
- package/dist/provider.js +1 -1
- package/dist/styles.tw3.css +0 -45
- package/dist/ui-save.js +1 -1
- package/dist/utils/deferred-module.js +1 -1
- package/dist/version.js +1 -1
- package/dist-types/chunk-warming.d.ts +41 -8
- package/dist-types/component-hooks/use-headless-iab-consent-ui.d.ts +1 -1
- package/dist-types/components/iab-panel/atoms/purpose-item.d.ts +4 -1
- package/dist-types/components/iab-panel/atoms/stack-item.d.ts +6 -1
- package/dist-types/components/iab-panel/index.d.ts +1 -0
- package/dist-types/components/panel/index.d.ts +1 -0
- package/dist-types/components/panel/panel.d.ts +1 -1
- package/dist-types/components/panel-trigger/atoms/trigger-icons.d.ts +20 -0
- package/dist-types/components/preferences/index.d.ts +1 -0
- package/dist-types/components/shared/ui/accordion/accordion.d.ts +1 -0
- package/dist-types/components/shared/ui/collapsible/collapsible.d.ts +1 -0
- package/dist-types/components/shared/ui/logo.d.ts +0 -10
- package/dist-types/components/shared/ui/preference-item/preference-item.d.ts +14 -0
- package/dist-types/components/shared/ui/switch/switch.d.ts +1 -0
- package/dist-types/components/shared/ui/tabs/tabs.d.ts +1 -0
- package/dist-types/consent-theme.d.ts +38 -0
- package/dist-types/draft.d.ts +43 -6
- package/dist-types/headless.d.ts +0 -1
- package/dist-types/hooks/use-committed-ref.d.ts +24 -0
- package/dist-types/hooks.d.ts +2 -0
- package/dist-types/index.d.ts +3 -2
- package/dist-types/kernel-selector.d.ts +66 -0
- package/dist-types/module-hooks/iframe-blocker.d.ts +27 -0
- package/dist-types/module-hooks/network-blocker.d.ts +23 -0
- package/dist-types/module-hooks/network-hold.d.ts +47 -0
- package/dist-types/panel.d.ts +13 -1
- package/dist-types/preferences.d.ts +12 -1
- package/dist-types/provider.d.ts +41 -8
- package/dist-types/ui-config-context.d.ts +2 -0
- package/dist-types/ui-save.d.ts +21 -1
- package/dist-types/utils/deferred-module.d.ts +3 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +6 -1
- package/docs/customization/overview.md +4 -3
- package/docs/customization/recipes.md +4 -2
- package/docs/customization/tokens.md +66 -3
- package/docs/frameworks/react/components/consent-dialog.md +45 -6
- package/docs/frameworks/react/components/consent-gate.md +8 -4
- package/docs/frameworks/react/components/consent-manager-provider.md +34 -14
- package/docs/frameworks/react/components/consent-widget.md +9 -0
- package/docs/frameworks/react/concepts/consent-categories.md +8 -1
- package/docs/frameworks/react/hooks/{use-consent-manager/overview.md → overview.md} +7 -5
- package/docs/frameworks/react/iab/overview.md +121 -1
- package/docs/frameworks/react/network-blocker.md +146 -0
- package/docs/frameworks/react/script-loader.md +6 -0
- package/docs/frameworks/react/styling/overview.md +71 -22
- package/docs/guides/consent-state.md +327 -0
- package/docs/guides/shared-consent-controls.md +158 -0
- package/docs/integrations/adobe-analytics.md +1 -1
- package/docs/integrations/ahrefs-analytics.md +1 -1
- package/docs/integrations/amplitude.md +1 -1
- package/docs/integrations/clearbit.md +1 -1
- package/docs/integrations/cloudflare-web-analytics.md +1 -1
- package/docs/integrations/cloudflare-zaraz.md +1 -1
- package/docs/integrations/crisp.md +1 -1
- package/docs/integrations/databuddy.md +1 -1
- package/docs/integrations/fathom-analytics.md +1 -1
- package/docs/integrations/front-chat.md +322 -0
- package/docs/integrations/google-maps.md +1 -1
- package/docs/integrations/google-tag-manager.md +1 -1
- package/docs/integrations/google-tag.md +1 -1
- package/docs/integrations/granular-consent.md +3 -1
- package/docs/integrations/heap.md +1 -1
- package/docs/integrations/hightouch.md +1 -1
- package/docs/integrations/hotjar.md +1 -1
- package/docs/integrations/intercom.md +1 -1
- package/docs/integrations/linkedin-insights.md +1 -1
- package/docs/integrations/logrocket.md +1 -1
- package/docs/integrations/matomo-analytics.md +1 -1
- package/docs/integrations/meta-pixel.md +1 -1
- package/docs/integrations/microsoft-clarity.md +1 -1
- package/docs/integrations/microsoft-uet.md +1 -1
- package/docs/integrations/mixpanel-analytics.md +1 -1
- package/docs/integrations/one-dollar-stats.md +305 -0
- package/docs/integrations/openai-pixel.md +1 -1
- package/docs/integrations/overview.md +17 -14
- package/docs/integrations/pinterest-tag.md +321 -0
- package/docs/integrations/pirsch.md +1 -1
- package/docs/integrations/plausible-analytics.md +1 -1
- package/docs/integrations/posthog.md +1 -1
- package/docs/integrations/promptwatch.md +1 -1
- package/docs/integrations/reddit-pixel.md +1 -1
- package/docs/integrations/rudderstack.md +1 -1
- package/docs/integrations/rybbit-analytics.md +1 -1
- package/docs/integrations/segment.md +1 -1
- package/docs/integrations/snapchat-pixel.md +1 -1
- package/docs/integrations/tiktok-pixel.md +1 -1
- package/docs/integrations/umami-analytics.md +1 -1
- package/docs/integrations/vercel-analytics.md +1 -1
- package/docs/integrations/x-pixel.md +1 -1
- package/docs/integrations/youtube.md +1 -1
- package/docs/upgrade-v3.md +129 -1
- package/package.json +7 -7
- package/dist/component-hooks/use-manager.js +0 -2
- package/dist-types/component-hooks/use-manager.d.ts +0 -45
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -206,7 +206,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
206
206
|
Export the scripts from that module:
|
|
207
207
|
|
|
208
208
|
```ts title="src/c15t.client.ts"
|
|
209
|
-
import type { C15tClientOptionsExtension } from '
|
|
209
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
210
210
|
import { scripts } from './consent-scripts';
|
|
211
211
|
|
|
212
212
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -203,7 +203,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
203
203
|
Export the scripts from that module:
|
|
204
204
|
|
|
205
205
|
```ts title="src/c15t.client.ts"
|
|
206
|
-
import type { C15tClientOptionsExtension } from '
|
|
206
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
207
207
|
import { scripts } from './consent-scripts';
|
|
208
208
|
|
|
209
209
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
194
194
|
Export the scripts from that module:
|
|
195
195
|
|
|
196
196
|
```ts title="src/c15t.client.ts"
|
|
197
|
-
import type { C15tClientOptionsExtension } from '
|
|
197
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
198
198
|
import { scripts } from './consent-scripts';
|
|
199
199
|
|
|
200
200
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -176,7 +176,7 @@ Add this component to pages using your consent-enabled base layout:
|
|
|
176
176
|
<c15t-consent-embed style="display: block"></c15t-consent-embed>
|
|
177
177
|
|
|
178
178
|
<script>
|
|
179
|
-
import { getConsentClient } from '
|
|
179
|
+
import { getConsentClient } from 'c15t/astro/client';
|
|
180
180
|
import { mountConsentEmbed } from '../consent-embed';
|
|
181
181
|
|
|
182
182
|
class ConsentEmbed extends HTMLElement {
|
package/docs/upgrade-v3.md
CHANGED
|
@@ -87,6 +87,115 @@ be true before a visitor acts. A notice dismissal updates `noticeDismissal` and
|
|
|
87
87
|
does not record consent. Global Privacy Control updates privacy signals and
|
|
88
88
|
configured opt-out directives without turning a browser signal into a choice.
|
|
89
89
|
|
|
90
|
+
## Replace `useConsentManager()`
|
|
91
|
+
|
|
92
|
+
`useConsentManager()` is gone from `c15t/react`, `c15t/next`,
|
|
93
|
+
`c15t/tanstack-start` and their `/headless` entries. It subscribed to the whole
|
|
94
|
+
consent snapshot, so every component that called it re-rendered on every
|
|
95
|
+
change, including changes to categories it never read. Call one hook per field
|
|
96
|
+
instead; each re-renders only when its own value changes.
|
|
97
|
+
|
|
98
|
+
Before, in v2 and earlier v3 alphas:
|
|
99
|
+
|
|
100
|
+
```tsx title="components/marketing-banner.tsx"
|
|
101
|
+
import { useConsentManager } from 'c15t/react';
|
|
102
|
+
|
|
103
|
+
export function MarketingBanner() {
|
|
104
|
+
const { activeUI, has, saveConsents } = useConsentManager();
|
|
105
|
+
if (activeUI !== 'banner' || has('marketing')) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return <button type="button" onClick={() => void saveConsents('all')}>Accept</button>;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
After:
|
|
113
|
+
|
|
114
|
+
```tsx title="components/marketing-banner.tsx"
|
|
115
|
+
import { useActiveUI, useConsent } from 'c15t/react';
|
|
116
|
+
import { useHeadlessConsentUI } from 'c15t/react/headless';
|
|
117
|
+
|
|
118
|
+
export function MarketingBanner() {
|
|
119
|
+
const activeUI = useActiveUI();
|
|
120
|
+
const marketing = useConsent('marketing');
|
|
121
|
+
const { performAction } = useHeadlessConsentUI();
|
|
122
|
+
if (activeUI !== 'banner' || marketing) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return <button type="button" onClick={() => void performAction('accept')}>Accept</button>;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Import hooks from the same entry you used for `useConsentManager()`:
|
|
130
|
+
`c15t/next` and `c15t/next/headless` in Next.js, `c15t/tanstack-start` and
|
|
131
|
+
`c15t/tanstack-start/headless` in TanStack Start.
|
|
132
|
+
|
|
133
|
+
| `useConsentManager()` field | v3 replacement |
|
|
134
|
+
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
135
|
+
| `activeUI` | `useActiveUI()`. It returns `null` before the kernel picks a surface; the old field reported `'none'`. |
|
|
136
|
+
| `setActiveUI(ui)` | `useSetActiveUI()` |
|
|
137
|
+
| `has(category)` | `useConsent(category)`, one call per category at the top of the component |
|
|
138
|
+
| `consents` | `useConsents()` |
|
|
139
|
+
| `effectivePermissions` | `useEffectivePermissions()` |
|
|
140
|
+
| `explicitChoice` | `useExplicitChoice()` |
|
|
141
|
+
| `promptRequirement` | `usePromptRequirement()` |
|
|
142
|
+
| `noticeDismissal` | `useNoticeDismissal()` |
|
|
143
|
+
| `privacySignals` | `usePrivacySignals()` |
|
|
144
|
+
| `optOutDirectives` | `useOptOutDirectives()` |
|
|
145
|
+
| `restrictions` | `useRestrictions()` |
|
|
146
|
+
| `resolution` | `usePolicyResolution()` |
|
|
147
|
+
| `policyRule` | `usePolicyRule()` |
|
|
148
|
+
| `policyCategories` | `usePolicyCategories()`. The old list started with `'necessary'`; this one does not. |
|
|
149
|
+
| `policyScopeMode` | `usePolicyScopeMode()` |
|
|
150
|
+
| `policyBanner` | `usePromptPresentation()` |
|
|
151
|
+
| `policyDialog` | `usePreferencesPresentation()` |
|
|
152
|
+
| `model` | `useModel()`. It returns `null` while no policy matches; the old field reported `'opt-in'`. |
|
|
153
|
+
| `branding` | `useBranding()`. It returns `null` when unset; the old field reported `'c15t'`. |
|
|
154
|
+
| `iab` | `useIABSnapshot()` |
|
|
155
|
+
| `vendors` | `useDeclaredVendors()` |
|
|
156
|
+
| `vendorChoice` | `useVendorChoice()` |
|
|
157
|
+
| `getDisplayedVendors(category)` | `useDeclaredVendors()`, filtered to vendors whose category condition names the category |
|
|
158
|
+
| `subscribeToConsentChanges(listener)` | `useSubscribeToConsentChanges()`, or the provider's `onPermissionsChanged` callback |
|
|
159
|
+
| `updateConsentCategories(categories)` | `useRegisterConsentCategories()` |
|
|
160
|
+
| `translationConfig` | `useTranslations()` for the active strings |
|
|
161
|
+
| `selectedConsents`, `selectedConsentTypes` | `useConsentDraft().values` |
|
|
162
|
+
| `setSelectedConsent(name, value)` | `useConsentDraft().set(name, value)` |
|
|
163
|
+
| `selectedVendors` | `useConsentDraft().vendors`, or `useVendorDraft().vendors` |
|
|
164
|
+
| `setSelectedVendor(id, granted)` | `useConsentDraft().setVendor(id, granted)` |
|
|
165
|
+
| `resetDraft()` | `useConsentDraft().reset()` |
|
|
166
|
+
| `draftIsStale` | `useConsentDraft().isStale` |
|
|
167
|
+
| `consentCategories`, `consentTypes`, `getDisplayedConsents()` | `useConsentDraft().displayedCategories`, with labels from `useTranslations().consentTypes` |
|
|
168
|
+
| `saveConsents('all')` | `useHeadlessConsentUI().performAction('accept')` |
|
|
169
|
+
| `saveConsents('necessary')` | `useHeadlessConsentUI().performAction('reject')` |
|
|
170
|
+
| `saveConsents('custom')` | `useHeadlessConsentUI().performAction('save')` |
|
|
171
|
+
| `manager` | Nothing. It was always `null` in v3. |
|
|
172
|
+
|
|
173
|
+
The old hook kept one private draft per component, shared by its selection and
|
|
174
|
+
its save. `useConsentDraft()` and `useHeadlessConsentUI()` read the nearest
|
|
175
|
+
`ConsentDraftProvider` instead. When one component stages choices and another
|
|
176
|
+
saves them, or one component calls both hooks, render them inside the same
|
|
177
|
+
`ConsentDraftProvider`; without one, each hook keeps its own draft and a custom
|
|
178
|
+
save commits nothing you staged. `ConsentWidget` already provides one.
|
|
179
|
+
|
|
180
|
+
`useHeadlessConsentUI()` saves the way the stock buttons do: it closes the
|
|
181
|
+
surface after a successful save and refuses a draft that the policy made stale.
|
|
182
|
+
`useSaveConsents()` calls the kernel directly and does neither.
|
|
183
|
+
|
|
184
|
+
The CLI rewrites the common destructuring forms for you:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
c15t codemods use-consent-manager-to-hooks --dry-run --json
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
It replaces each field that has a one-hook equivalent, turns `has('marketing')`
|
|
191
|
+
calls with a literal category into `useConsent('marketing')`, and maps
|
|
192
|
+
`saveConsents('all' | 'necessary' | 'custom')` calls to
|
|
193
|
+
`useHeadlessConsentUI().saveCustomPreferences()`. Fields it cannot rewrite stay
|
|
194
|
+
on a `useConsentManager()` call under a `TODO(c15t v3)` comment that names the
|
|
195
|
+
replacement, so the build fails at each place that needs manual work. It also
|
|
196
|
+
marks components that now need a shared `ConsentDraftProvider`. Review the
|
|
197
|
+
result, then run it without `--dry-run`.
|
|
198
|
+
|
|
90
199
|
## Replace choice callbacks
|
|
91
200
|
|
|
92
201
|
```tsx
|
|
@@ -191,7 +300,7 @@ Notice acknowledgement uses `common.acknowledge`, falling back to
|
|
|
191
300
|
|
|
192
301
|
```astro
|
|
193
302
|
---
|
|
194
|
-
import ConsentBanner from '
|
|
303
|
+
import ConsentBanner from 'c15t/astro/components/consent-banner.astro';
|
|
195
304
|
---
|
|
196
305
|
|
|
197
306
|
<ConsentBanner dismissButtonText="Got it" />
|
|
@@ -277,6 +386,25 @@ translation keys, `--frame-*` CSS custom properties and
|
|
|
277
386
|
`data-testid="frame-placeholder"`, so custom copy, styles and tests continue
|
|
278
387
|
to apply.
|
|
279
388
|
|
|
389
|
+
## Split dialog and widget entries are deferred
|
|
390
|
+
|
|
391
|
+
`c15t/react/consent-dialog` and `c15t/react/consent-widget` (and their
|
|
392
|
+
`@c15t/react/*` equivalents) now export the same deferred `ConsentDialog` and
|
|
393
|
+
`ConsentWidget` as `c15t/react`. The dialog's code loads when it first opens
|
|
394
|
+
instead of with every page. `<ConsentDialog />`, `<ConsentWidget />` and the
|
|
395
|
+
`ConsentDialog.<Part>` properties need no change.
|
|
396
|
+
|
|
397
|
+
The two entries no longer export the individual parts. Import those from the
|
|
398
|
+
component entries, which keep the old, eagerly bundled exports:
|
|
399
|
+
|
|
400
|
+
| Before | After |
|
|
401
|
+
| --------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
402
|
+
| `import { Card, Header } from 'c15t/react/consent-dialog'` | `import { Card, Header } from 'c15t/react/components/consent-dialog'` |
|
|
403
|
+
| `import { Accordion, Switch } from 'c15t/react/consent-widget'` | `import { Accordion, Switch } from 'c15t/react/components/consent-widget'` |
|
|
404
|
+
|
|
405
|
+
To keep the dialog in the first load so its first open needs no download,
|
|
406
|
+
import `ConsentDialog` from `c15t/react/components/consent-dialog`.
|
|
407
|
+
|
|
280
408
|
## Next.js RSC banner removal
|
|
281
409
|
|
|
282
410
|
The `@c15t/nextjs/rsc` entry (`c15t/next/rsc`) and its `RscConsentBanner`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c15t/react",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "React cookie banner, consent manager, preference center, and headless CMP components with IAB TCF and Consent Mode support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ccpa",
|
|
@@ -243,16 +243,16 @@
|
|
|
243
243
|
"test:watch": "bun prebuild && vitest"
|
|
244
244
|
},
|
|
245
245
|
"dependencies": {
|
|
246
|
-
"@c15t/core": "3.0.0-alpha.
|
|
247
|
-
"@c15t/dev-tools": "3.0.0-alpha.
|
|
248
|
-
"@c15t/iab": "3.0.0-alpha.
|
|
249
|
-
"@c15t/schema": "3.0.0-alpha.
|
|
246
|
+
"@c15t/core": "3.0.0-alpha.3",
|
|
247
|
+
"@c15t/dev-tools": "3.0.0-alpha.3",
|
|
248
|
+
"@c15t/iab": "3.0.0-alpha.3",
|
|
249
|
+
"@c15t/schema": "3.0.0-alpha.2",
|
|
250
250
|
"@c15t/translations": "3.0.0-alpha.2",
|
|
251
|
-
"@c15t/ui": "3.0.0-alpha.
|
|
251
|
+
"@c15t/ui": "3.0.0-alpha.3",
|
|
252
252
|
"@types/google.maps": "3.65.3"
|
|
253
253
|
},
|
|
254
254
|
"devDependencies": {
|
|
255
|
-
"@c15t/backend": "3.0.0-alpha.
|
|
255
|
+
"@c15t/backend": "3.0.0-alpha.3",
|
|
256
256
|
"@c15t/conformance": "0.0.1",
|
|
257
257
|
"@c15t/typescript-config": "0.0.1",
|
|
258
258
|
"@c15t/vitest-config": "1.0.0",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{evaluateConsent as e,vendorsListedUnder as a}from"@c15t/core";import{useCallback as i,useMemo as t}from"react";import{useConsentManagerDraft as n}from"../draft.js";import{useActiveUI as s,useBranding as r,useConsents as o,useDeclaredVendors as l,useModel as c,usePolicyCategories as p,usePolicyScopeMode as d,usePreferencesPresentation as u,usePromptPresentation as m,useRegisterConsentCategories as y,useSetActiveUI as f,useSnapshot as g,useSubscribeToConsentChanges as v,useTranslations as h}from"../hooks.js";import{defaultTranslationConfig as C}from"../utils/default-translation-config.js";let S={},T=[{defaultValue:!0,description:"Required for basic site functionality",disabled:!0,display:!0,gdprType:1,name:"necessary"},{defaultValue:!1,description:"Enables enhanced features",display:!0,gdprType:2,name:"functionality"},{defaultValue:!1,description:"Analytics and performance measurement",display:!0,gdprType:4,name:"measurement"},{defaultValue:!1,description:"Improves your experience",display:!0,gdprType:3,name:"experience"},{defaultValue:!1,description:"Advertising and marketing",display:!0,gdprType:5,name:"marketing"}],V=function(){let V=g(),b=o(),D=s(),x=r(),R=c(),P=m(),j=p(),k=u(),q=d(),{draft:w,save:I}=n(),A=l(),M=f(),O=v(),_=h(),B=t(()=>_?{...C,defaultLanguage:_.language,translations:{...C.translations,[_.language]:_.translations}}:C,[_]),E=t(()=>["necessary",...j],[j]),L=t(()=>["necessary",...V.evaluationPolicy.choiceScope??j],[V.evaluationPolicy.choiceScope,j]),U=i(()=>{let e=new Set(L);return T.filter(a=>e.has(a.name)).map(e=>({...e,display:!0}))},[L]),z=i(a=>e({category:a},V),[V]),F=i(e=>{M(e)},[M]),G=i(async(e,a)=>{"custom"===e?await I():await I("all"===e?"all":"none")},[I]),H=i((e,a)=>{L.includes(e)&&w.set(e,a)},[w,L]),J=i((e,a)=>{w.setVendor(e,a)},[w]),K=i(e=>a(A,e),[A]),N=y(),Q=i(e=>O(e),[O]);return{activeUI:D??"none",branding:x??"c15t",consentCategories:L,consentTypes:U(),consents:b,draftIsStale:w.isStale,effectivePermissions:V.effectivePermissions,explicitChoice:V.explicitChoice,getDisplayedConsents:U,getDisplayedVendors:K,has:z,iab:V.iab,manager:null,model:R??"opt-in",noticeDismissal:V.noticeDismissal,optOutDirectives:V.optOutDirectives,policyBanner:P??S,policyCategories:E,policyDialog:k??S,policyRule:V.policyRule,policyScopeMode:q,privacySignals:V.privacySignals,promptRequirement:V.promptRequirement,resetDraft:w.reset,resolution:V.resolution,restrictions:V.restrictions,saveConsents:G,selectedConsentTypes:w.values,selectedConsents:w.values,selectedVendors:w.vendors,setActiveUI:F,setSelectedConsent:H,setSelectedVendor:J,subscribeToConsentChanges:Q,translationConfig:B,updateConsentCategories:N,vendorChoice:V.vendorChoice,vendors:A}};export{V as useConsentManager};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ActiveUI, AllConsentNames, ConsentState, ConsentType, HasCondition, Model, PromptPresentation, TranslationConfig } from '@c15t/core';
|
|
2
|
-
type SaveType = 'all' | 'custom' | 'necessary';
|
|
3
|
-
export declare const useConsentManager: () => {
|
|
4
|
-
activeUI: ActiveUI;
|
|
5
|
-
branding: import("@c15t/core").KernelBranding;
|
|
6
|
-
consentCategories: AllConsentNames[];
|
|
7
|
-
consentTypes: ConsentType[];
|
|
8
|
-
consents: ConsentState;
|
|
9
|
-
draftIsStale: boolean;
|
|
10
|
-
effectivePermissions: Readonly<ConsentState>;
|
|
11
|
-
explicitChoice: Readonly<import("@c15t/core").ExplicitChoice> | null;
|
|
12
|
-
getDisplayedConsents: () => ConsentType[];
|
|
13
|
-
getDisplayedVendors: (category: AllConsentNames) => import("@c15t/core").ResolvedVendor[];
|
|
14
|
-
has: (condition: HasCondition<AllConsentNames>) => boolean;
|
|
15
|
-
iab: Readonly<import("@c15t/core").KernelIABState> | null;
|
|
16
|
-
manager: null;
|
|
17
|
-
model: Model;
|
|
18
|
-
noticeDismissal: Readonly<import("@c15t/core").NoticeDismissal> | null;
|
|
19
|
-
optOutDirectives: readonly import("@c15t/core").PrivacyOptOut[];
|
|
20
|
-
policyBanner: PromptPresentation;
|
|
21
|
-
policyCategories: AllConsentNames[];
|
|
22
|
-
policyDialog: import("@c15t/core").PreferencesPresentation;
|
|
23
|
-
policyRule: Readonly<import("@c15t/core").ResolvedPolicyRule>;
|
|
24
|
-
policyScopeMode: import("@c15t/core").PolicyScopeMode;
|
|
25
|
-
privacySignals: import("@c15t/core").KernelPrivacySignals;
|
|
26
|
-
promptRequirement: Readonly<import("@c15t/core").PromptRequirement>;
|
|
27
|
-
resetDraft: () => void;
|
|
28
|
-
resolution: Readonly<import("@c15t/core").PolicyResolution>;
|
|
29
|
-
restrictions: Readonly<Partial<Record<import("@c15t/core").OptionalConsentCategory, readonly import("@c15t/core").RestrictionReason[]>>>;
|
|
30
|
-
saveConsents: (type: SaveType, _options?: {
|
|
31
|
-
uiSource?: string;
|
|
32
|
-
}) => Promise<void>;
|
|
33
|
-
selectedConsentTypes: Readonly<ConsentState>;
|
|
34
|
-
selectedConsents: Readonly<ConsentState>;
|
|
35
|
-
selectedVendors: Readonly<Record<string, boolean>>;
|
|
36
|
-
setActiveUI: (ui: ActiveUI) => void;
|
|
37
|
-
setSelectedConsent: (name: AllConsentNames, value: boolean) => void;
|
|
38
|
-
setSelectedVendor: (vendorId: string, granted: boolean) => void;
|
|
39
|
-
subscribeToConsentChanges: (listener: (state: ConsentState) => void) => () => void;
|
|
40
|
-
translationConfig: TranslationConfig;
|
|
41
|
-
updateConsentCategories: (categories: readonly AllConsentNames[]) => void;
|
|
42
|
-
vendorChoice: Readonly<import("@c15t/core").VendorChoice> | null;
|
|
43
|
-
vendors: readonly import("@c15t/core").ResolvedVendor[];
|
|
44
|
-
};
|
|
45
|
-
export {};
|