@c15t/react 3.0.0-alpha.5 → 3.0.0-alpha.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/AGENTS.md +6 -4
- package/dist/component-hooks/use-headless-consent-ui.js +1 -1
- package/dist/components/iab-panel/atoms/vendor-list.js +1 -1
- package/dist/components/iab-panel/hooks/use-gvl-data.js +1 -1
- package/dist/components/iab-panel/index.js +1 -1
- package/dist/components/panel/index.js +1 -1
- package/dist/components/panel-trigger/atoms/toolbar.js +1 -1
- package/dist/components/panel-trigger/atoms/trigger-icons.js +1 -1
- package/dist/components/panel-trigger/panel-trigger.js +1 -1
- package/dist/components/preferences/index.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/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/devtools-launcher.js +2 -0
- package/dist/devtools.js +1 -1
- package/dist/hooks/use-headless-iab-consent-ui.js +1 -1
- package/dist/index-parts/core.js +1 -1
- package/dist/provider.js +1 -1
- package/dist/styles.tw3.css +27 -3
- package/dist/version.js +1 -1
- package/dist-types/component-hooks/use-headless-consent-ui.d.ts +4 -4
- package/dist-types/components/iab-panel/index.d.ts +0 -1
- package/dist-types/components/panel/index.d.ts +0 -1
- package/dist-types/components/panel-trigger/atoms/trigger-icons.d.ts +5 -0
- package/dist-types/components/panel-trigger/panel-trigger.d.ts +0 -8
- package/dist-types/components/preferences/index.d.ts +0 -1
- package/dist-types/components/shared/ui/accordion/accordion.d.ts +0 -1
- package/dist-types/components/shared/ui/collapsible/collapsible.d.ts +0 -1
- package/dist-types/components/shared/ui/preference-item/preference-item.d.ts +0 -1
- package/dist-types/components/shared/ui/switch/switch.d.ts +0 -1
- package/dist-types/components/shared/ui/tabs/tabs.d.ts +0 -1
- package/dist-types/devtools-launcher.d.ts +29 -0
- package/dist-types/hooks/use-iab-manager.d.ts +4 -4
- package/dist-types/hooks.d.ts +27 -5
- package/dist-types/index-parts/core.d.ts +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/provider.d.ts +12 -1
- package/dist-types/version.d.ts +1 -1
- package/docs/README.md +6 -4
- package/docs/concepts/choose-your-setup.md +22 -5
- package/docs/concepts/consent-state.md +41 -0
- package/docs/concepts/data-fetching.md +34 -11
- package/docs/customization/recipes.md +4 -5
- package/docs/customization/slots.md +3 -2
- package/docs/customization/stylesheets.md +29 -39
- package/docs/customization/tailwind.md +5 -5
- package/docs/customization/tokens.md +1 -1
- package/docs/customization/translations.md +32 -5
- package/docs/frameworks/react/components/consent-dialog-trigger.md +5 -0
- package/docs/frameworks/react/components/consent-dialog.md +2 -1
- package/docs/frameworks/react/components/dev-tools.md +23 -0
- package/docs/frameworks/react/headless.md +4 -4
- package/docs/frameworks/react/hooks.md +10 -5
- package/docs/frameworks/react/iab.md +24 -18
- package/docs/frameworks/react/quickstart.md +77 -16
- package/docs/frameworks/react/rendering.md +82 -11
- package/docs/frameworks/react/scripts.md +8 -3
- package/docs/frameworks/react/upgrade-v3.md +596 -0
- package/docs/frameworks/react/vendor-consent.md +6 -0
- package/docs/guides/banner-experiments.md +26 -5
- package/docs/guides/troubleshooting.md +3 -2
- package/docs/integrations/overview.md +28 -27
- package/docs/integrations/sentry.md +416 -0
- package/docs/upgrade-v3.md +201 -314
- package/package.json +8 -8
package/AGENTS.md
CHANGED
|
@@ -15,7 +15,7 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
15
15
|
- [How consent works](./docs/concepts/how-consent-works.md): What c15t decides on each page load, the difference between a permission and a recorded choice, and what happens when a visitor saves.
|
|
16
16
|
- [Customize the interface](./docs/customization/overview.md): Change c15t's consent banner and dialog one step at a time, from a prop to your own markup, and find where each step lives in your framework.
|
|
17
17
|
- [Verify consent](./docs/guides/verify-consent.md): Check in a production build that vendor requests wait for consent, rejection survives a reload, preferences reopen and privacy signals apply.
|
|
18
|
-
- [Migrate to v3](./docs/upgrade-v3.md): Upgrade
|
|
18
|
+
- [Migrate to v3](./docs/upgrade-v3.md): Upgrade from c15t v2 to v3. Pick the guide for the v2 package you use (@c15t/nextjs, @c15t/react or the c15t store), rename @c15t/scripts, keep visitors' choices, and upgrade a self-hosted backend and the Node.js SDK.
|
|
19
19
|
|
|
20
20
|
## More documentation
|
|
21
21
|
|
|
@@ -48,6 +48,7 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
48
48
|
- [Scripts](./docs/frameworks/react/scripts.md): Load vendor scripts by consent category in a React app with ConsentProvider, and clear stored data or reload the page when a visitor withdraws consent.
|
|
49
49
|
- [Translations](./docs/frameworks/react/translations.md): Where c15t banner and dialog copy comes from in a React app, how the browser picks the visitor's language, and how to override copy and switch languages with the provider's i18n option and hooks.
|
|
50
50
|
- [Troubleshooting](./docs/frameworks/react/troubleshooting.md): Fix a missing banner, early vendor requests, unstyled components and theme warnings in a React app that uses c15t/react.
|
|
51
|
+
- [Upgrade from v2](./docs/frameworks/react/upgrade-v3.md): Upgrade a React app from c15t v2 (@c15t/react) to v3. Covers packages, ConsentProvider and transports, the useConsentManager codemod, callbacks, policies, styles, IAB and stored consent.
|
|
51
52
|
- [Vendor consent](./docs/frameworks/react/vendor-consent.md): Let visitors allow a category such as marketing in a React app and still turn off one vendor in it, with the vendors option on ConsentProvider and useVendorAllowed.
|
|
52
53
|
|
|
53
54
|
## Concepts
|
|
@@ -55,7 +56,7 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
55
56
|
- [Choose your setup](./docs/concepts/choose-your-setup.md): Pick the c15t setup for your framework, rendering mode and hosting, and decide who runs the consent backend.
|
|
56
57
|
- [Consent categories](./docs/concepts/consent-categories.md): Assign scripts, embeds and features to c15t consent categories, and understand which categories the preference dialog shows.
|
|
57
58
|
- [Consent state reference](./docs/concepts/consent-state.md): How c15t saves choices, gates IAB vendors, hydrates server records and keeps browser tabs and storage in step.
|
|
58
|
-
- [Data fetching](./docs/concepts/data-fetching.md):
|
|
59
|
+
- [Data fetching](./docs/concepts/data-fetching.md): Choose the recommended build-time policy snapshot or runtime manifest fetching, backend /init, browser resolution or offline rules, and understand where consent choices are saved.
|
|
59
60
|
- [How consent works](./docs/concepts/how-consent-works.md): What c15t decides on each page load, the difference between a permission and a recorded choice, and what happens when a visitor saves.
|
|
60
61
|
- [Policies](./docs/concepts/policies.md): How policy models, prompts and scope decide what c15t asks visitors, where to change the rules, and why a banner may not appear.
|
|
61
62
|
|
|
@@ -73,7 +74,7 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
73
74
|
- [Customize the interface](./docs/customization/overview.md): Change c15t's consent banner and dialog one step at a time, from a prop to your own markup, and find where each step lives in your framework.
|
|
74
75
|
- [Banner designs](./docs/customization/recipes.md): Five consent banner designs built with c15t, from one prop to your own markup, with tested code for React, Vue, Svelte, Astro and plain HTML.
|
|
75
76
|
- [Component parts](./docs/customization/slots.md): Find every part of c15t's banner, dialog, widget, trigger and ConsentGate placeholder, its key in your framework's part API, and the data attributes to select on.
|
|
76
|
-
- [Stylesheets and CSS layers](./docs/customization/stylesheets.md): Load the right c15t stylesheet for your framework, see
|
|
77
|
+
- [Stylesheets and CSS layers](./docs/customization/stylesheets.md): Load the right c15t stylesheet for your framework, see which file holds the dialog's rules, order c15t's cascade layer against your own, and run c15t without its styles.
|
|
77
78
|
- [Tailwind CSS](./docs/customization/tailwind.md): Load c15t's styles next to Tailwind CSS 4 or 3 in every framework, put utilities on c15t component parts, and use Tailwind's dark variant with c15t.
|
|
78
79
|
- [Theme tokens](./docs/customization/tokens.md): Change c15t's colors, type, radius, spacing, shadows and motion with theme tokens, and see every --c15t-* variable with its default.
|
|
79
80
|
- [Copy and translations](./docs/customization/translations.md): Change consent wording through i18n and test the complete prompt and preferences flow.
|
|
@@ -118,6 +119,7 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
118
119
|
- [RudderStack](./docs/integrations/rudderstack.md): Load the RudderStack JavaScript SDK after measurement consent with the c15t rudderstack helper, or map c15t categories to destination consent IDs, and check each mode.
|
|
119
120
|
- [Rybbit Analytics](./docs/integrations/rybbit-analytics.md): Load Rybbit Analytics only after measurement consent with the c15t rybbitAnalytics helper, map its tracking options to data attributes, and check it in DevTools.
|
|
120
121
|
- [Segment](./docs/integrations/segment.md): Load Segment Analytics.js only after measurement consent with the c15t segment helper, guard your own track and identify calls, and check it in DevTools.
|
|
122
|
+
- [Sentry](./docs/integrations/sentry.md): Configure Sentry's CDN or your own SDK with consent for error monitoring, Session Replay and user data.
|
|
121
123
|
- [Snapchat Pixel](./docs/integrations/snapchat-pixel.md): Load the Snapchat Pixel only after marketing consent with the c15t snapchatPixel helper, guard snaptr event calls, and check it in DevTools.
|
|
122
124
|
- [TikTok Pixel](./docs/integrations/tiktok-pixel.md): Load the TikTok Pixel only after marketing consent with the c15t tiktokPixel helper, guard ttq event calls, and check it in DevTools.
|
|
123
125
|
- [Umami Analytics](./docs/integrations/umami-analytics.md): Load the Umami Analytics tracker only after measurement consent with the c15t umamiAnalytics helper, point it at a self-hosted instance, and check it in DevTools.
|
|
@@ -127,4 +129,4 @@ These docs describe c15t v3. Find your app's row in Choose your setup, then foll
|
|
|
127
129
|
|
|
128
130
|
## Reference
|
|
129
131
|
|
|
130
|
-
- [Migrate to v3](./docs/upgrade-v3.md): Upgrade
|
|
132
|
+
- [Migrate to v3](./docs/upgrade-v3.md): Upgrade from c15t v2 to v3. Pick the guide for the v2 package you use (@c15t/nextjs, @c15t/react or the c15t store), rename @c15t/scripts, keep visitors' choices, and upgrade a self-hosted backend and the Node.js SDK.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{actionAppearanceFromTheme as e,resolveConsentPresentation as r}from"@c15t/core";import{useCallback as o,useContext as s,useEffect as t,useMemo as c}from"react";import{GlobalThemeContext as n}from"../context/theme-context.js";import{useConsentSaveAction as a}from"../draft-context.js";import{useActiveUI as i,useDismissNotice as p,usePolicyRule as l,useResolvedPresentation as m,useSetActiveUI as u}from"../hooks.js";import{useTheme as f}from"../hooks/use-theme.js";let d=function(d){let g=i(),
|
|
2
|
+
import{actionAppearanceFromTheme as e,resolveConsentPresentation as r}from"@c15t/core";import{useCallback as o,useContext as s,useEffect as t,useMemo as c}from"react";import{GlobalThemeContext as n}from"../context/theme-context.js";import{useConsentSaveAction as a}from"../draft-context.js";import{useActiveUI as i,useDismissNotice as p,usePolicyRule as l,useResolvedPresentation as m,useSetActiveUI as u}from"../hooks.js";import{useTheme as f}from"../hooks/use-theme.js";let d=function(d){let g=i(),k=l(),h=m(),j=s(n),v=c(()=>({preferences:{scrollLock:j.scrollLock,trapFocus:j.trapFocus,...h?.preferences},prompt:{scrollLock:j.scrollLock,trapFocus:j.trapFocus,...h?.prompt}}),[h,j.scrollLock,j.trapFocus]),{theme:F}=f(),L=c(()=>e(F),[F]),_=a(),b=p(),x=u(),A=c(()=>({...r({actionAppearance:L,override:d?.prompt,policy:k,presentation:v,surface:"prompt"}),isVisible:"banner"===g}),[k,v,d?.prompt,g,L]),C=c(()=>({...r({actionAppearance:L,override:d?.preferences,policy:k,presentation:v,surface:"preferences"}),isVisible:"dialog"===g}),[k,v,d?.preferences,g,L]);t(()=>{if("production"!==process.env.NODE_ENV)for(let e of[...A.diagnostics,...C.diagnostics])console.warn(`c15t presentation: ${e.message}`,e.actions)},[A.diagnostics,C.diagnostics]);let V=o(()=>x("banner"),[x]),w=o(()=>x("dialog"),[x]),D=o(()=>x("none"),[x]),E=o(e=>{switch(e){case"accept":return _("all");case"reject":return _("none");case"save":return _();case"dismiss":return b();case"customize":return x("dialog");default:return}},[_,b,x]);return{activeUI:g,banner:A,closeUI:D,dialog:C,openBanner:V,openDialog:w,performAction:E,performBannerAction:E,performDialogAction:E,saveCustomPreferences:_}};export{d as useHeadlessConsentUI};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import n from"@c15t/ui/styles/components/iab-consent-dialog";import{useEffect as t,useState as s}from"react";import{useTheme as i}from"../../../hooks/use-theme.js";import{useUIConfig as o}from"../../../ui-config-context.js";import{mergeSlotProps as a}from"../../../utils/merge-slot-props.js";import{useIABTranslations as l}from"../use-iab-translations.js";import*as d from"../../shared/ui/preference-item/index.js";import*as c from"../../shared/ui/switch/index.js";let m=[],p={},h=({vendorData:h,purposes:u,vendorConsents:v,onVendorToggle:g,selectedVendorId:f,onClearSelection:N,customVendors:C=m,vendorLegitimateInterests:k=p,onVendorLegitimateInterestToggle:L})=>{let{components:y}=o(),{noStyle:S}=i(),[x,I]=s(""),[P,b]=s(new Set),M=l(),w=[...h?Object.entries(h.vendors).map(([e,r])=>({cookieMaxAgeSeconds:r.cookieMaxAgeSeconds,cookieRefresh:r.cookieRefresh,dataDeclaration:r.dataDeclaration||[],dataRetention:r.dataRetention,deviceStorageDisclosureUrl:r.deviceStorageDisclosureUrl??null,features:r.features||[],id:Number(e),isCustom:!1,legIntPurposes:r.legIntPurposes||[],legitimateInterestUrl:r.urls?.find(e=>e.legIntClaim)?.legIntClaim??null,name:r.name,policyUrl:r.policyUrl??"",purposes:r.purposes||[],specialFeatures:r.specialFeatures||[],specialPurposes:r.specialPurposes||[],usesCookies:r.usesCookies,usesNonCookieAccess:r.usesNonCookieAccess})):[],...C.map(e=>({cookieMaxAgeSeconds:e.cookieMaxAgeSeconds??null,cookieRefresh:void 0,dataDeclaration:e.dataCategories||[],dataRetention:void 0,deviceStorageDisclosureUrl:null,features:e.features||[],id:e.id,isCustom:!0,legIntPurposes:e.legIntPurposes||[],legitimateInterestUrl:null,name:e.name,policyUrl:e.privacyPolicyUrl,purposes:e.purposes||[],specialFeatures:e.specialFeatures||[],specialPurposes:[],usesCookies:e.usesCookies??!1,usesNonCookieAccess:e.usesNonCookieAccess??!1}))].sort((e,r)=>e.name.localeCompare(r.name));t(()=>{if(null!==f){let e=requestAnimationFrame(()=>{b(e=>new Set(e).add(f))}),r=setTimeout(()=>{let e=document.getElementById(`vendor-${String(f)}`);e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>{cancelAnimationFrame(e),clearTimeout(r)}}},[f]);let R=null===f?w.filter(e=>e.name.toLowerCase().includes(x.toLowerCase())):w.filter(e=>String(e.id)===String(f)),B=R.filter(e=>!e.isCustom),V=R.filter(e=>e.isCustom),A=a(y?.["iab-vendor-list"]?.root,{noStyle:S}),T=a(y?.["iab-vendor-list"]?.header,{baseClassName:n.vendorListHeader,noStyle:S}),D=a(y?.["iab-vendor-list"]?.search,{baseClassName:n.searchContainer,noStyle:S}),U=a(y?.["iab-vendor-list"]?.selectedVendor,{baseClassName:n.selectedVendorBanner,noStyle:S}),$=function(t){var s,i,o,l;let m,p,f,N,C=String(t.id),x=(s=t.id,(m=w.find(e=>String(e.id)===String(s)))?u.filter(e=>e.vendors.some(e=>String(e.id)===String(s))).map(e=>({...e,usesLegitimateInterest:m.legIntPurposes.includes(e.id)})):[]),I=(i=t.id,(p=w.find(e=>String(e.id)===String(i)))&&h?p.specialPurposes.map(e=>h.specialPurposes[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),R=(o=t.id,(f=w.find(e=>String(e.id)===String(o)))&&h?f.specialFeatures.map(e=>h.specialFeatures[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),B=(l=t.id,(N=w.find(e=>String(e.id)===String(l)))&&h?(N.features||[]).map(e=>h.features[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),V=P.has(t.id),A=x.filter(e=>e.usesLegitimateInterest).length,T=t.legIntPurposes.length>0,D=k[C]??!0,U=t.dataRetention?.stdRetention,$=null;t.cookieMaxAgeSeconds&&($=M.preferenceCenter.vendorList.maxAge.replace("{days}",String(Math.floor(t.cookieMaxAgeSeconds/86400))),t.cookieRefresh&&($=`${$} (refreshes)`));let j=a(y?.["iab-vendor-list"]?.rowHeader,{baseClassName:n.vendorListItemHeader,noStyle:S});return r(d.Root,{id:`vendor-${C}`,className:S?void 0:`${n.vendorListItem} ${t.isCustom?n.customVendorItem:""}`,noStyle:!0,onOpenChange:()=>{var e;return e=t.id,void b(r=>{let n=new Set(r);return n.has(e)?n.delete(e):n.add(e),n})},open:V,slotKey:"iab-vendor-list.row",children:[r("div",{...j,children:[r(d.Trigger,{className:n.vendorListTrigger,noStyle:!0,children:[r("div",{className:n.vendorListInfo,children:[r("h3",{className:n.vendorListName,children:[t.name,t.isCustom&&r("svg",{className:n.customVendorIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-label":M.common.customPartner,children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})]}),r("div",{className:n.vendorListMeta,children:[r("span",{className:n.vendorListMetaText,children:[x.length," purpose",1===x.length?"":"s",I.length>0&&`, ${I.length} special`,R.length>0&&`, ${R.length} feature${1===R.length?"":"s"}`]}),A>0&&r("span",{className:n.vendorListLiBadge,children:[e("svg",{style:{height:"0.625rem",width:"0.625rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),A," ",M.preferenceCenter.vendorList.legitimateInterest]})]})]}),e("svg",{className:n.purposeArrow,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:V?e("path",{d:"M19 15l-7-7-7 7"}):e("path",{d:"M19 9l-7 7-7-7"})})]}),e("div",{className:n.vendorConsentControl,children:e(c.Root,{"aria-label":`Consent for ${t.name}`,className:n.vendorConsentSwitch,checked:v[C]??!1,onCheckedChange:e=>g(t.id,e)})})]}),r(d.Content,{innerClassName:S?void 0:n.vendorListContent,innerSlotKey:"iab-vendor-list.rowContent",noStyle:S,children:[r("div",{className:n.vendorLinks,children:[r("a",{href:t.policyUrl,target:"_blank",rel:"noopener noreferrer",className:n.vendorLink,children:[r("svg",{className:n.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),M.preferenceCenter.vendorList.privacyPolicy]}),t.legitimateInterestUrl&&r("a",{href:t.legitimateInterestUrl,target:"_blank",rel:"noopener noreferrer",className:n.vendorLink,children:[r("svg",{className:n.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),M.preferenceCenter.purposeItem.legitimateInterest]}),t.deviceStorageDisclosureUrl&&r("a",{href:t.deviceStorageDisclosureUrl,target:"_blank",rel:"noopener noreferrer",className:n.vendorLink,children:[r("svg",{className:n.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),M.preferenceCenter.vendorList.storageDisclosure]})]}),r("div",{className:n.vendorBadges,children:[t.usesCookies&&e("span",{className:n.vendorBadge,children:M.preferenceCenter.vendorList.usesCookies}),t.usesNonCookieAccess&&e("span",{className:n.vendorBadge,children:M.preferenceCenter.vendorList.nonCookieAccess}),$&&e("span",{className:n.vendorBadge,children:$}),U&&e("span",{className:n.vendorBadge,children:M.preferenceCenter.vendorList.retention.replace("{days}",String(U))})]}),x.length>0&&r("div",{className:n.vendorPurposesList,children:[r("h4",{className:n.vendorPurposesTitle,children:[M.preferenceCenter.vendorList.purposes," (",x.length,")"]}),e("ul",{className:n.vendorPurposesItems,children:x.map(s=>{let i;return t.dataRetention?.purposes?.[s.id]?i=t.dataRetention.purposes[s.id]:t.dataRetention?.stdRetention&&(i=t.dataRetention.stdRetention),r("li",{className:`${n.vendorPurposeItem} ${s.usesLegitimateInterest?n.vendorPurposeItemLi:""}`,children:[r("span",{children:[s.name,i&&r("span",{className:n.vendorRetention,children:[" ","(Retained: ",i,"d)"]})]}),s.usesLegitimateInterest&&r("span",{className:n.vendorListLiBadge,children:[e("svg",{style:{height:"0.625rem",width:"0.625rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),M.preferenceCenter.vendorList.legitimateInterest]})]},s.id)})})]}),T&&L&&r("div",{className:n.vendorLiSection,children:[r("div",{className:n.vendorLiSectionHeader,children:[r("h4",{className:n.vendorPurposesTitle,children:[e("svg",{style:{height:"0.75rem",marginRight:"0.25rem",width:"0.75rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),M.preferenceCenter.purposeItem.legitimateInterest]}),e("button",{type:"button",onClick:()=>L(t.id,!D),className:`${n.objectButton} ${D?"":n.objectButtonActive}`,"aria-pressed":!D,children:D?M.preferenceCenter.purposeItem.objectButton:M.preferenceCenter.purposeItem.objected})]}),e("p",{className:n.liExplanation,children:M.preferenceCenter.purposeItem.rightToObject})]}),t.dataDeclaration&&t.dataDeclaration.length>0&&r("div",{className:n.vendorPurposesList,children:[r("h4",{className:n.vendorPurposesTitle,children:[M.preferenceCenter.vendorList.dataCategories," (",t.dataDeclaration.length,")"]}),e("ul",{className:n.vendorPurposesItems,children:t.dataDeclaration.map(r=>{let t=h?.dataCategories?.[r];return e("li",{className:n.vendorPurposeItem,title:t?.description,children:t?.name||`Data Category ${r}`},r)})})]}),I.length>0&&r("div",{className:n.vendorPurposesList,children:[r("h4",{className:n.vendorPurposesTitle,children:[r("svg",{"aria-hidden":"true",focusable:"false",style:{height:"0.75rem",marginRight:"0.25rem",width:"0.75rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("title",{children:M.preferenceCenter.vendorList.specialPurposes}),e("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),M.preferenceCenter.vendorList.specialPurposes," (",I.length,")"]}),e("ul",{className:n.vendorPurposesItems,children:I.map(s=>{let i;return t.dataRetention?.specialPurposes?.[s.id]?i=t.dataRetention.specialPurposes[s.id]:t.dataRetention?.stdRetention&&(i=t.dataRetention.stdRetention),e("li",{className:n.vendorPurposeItem,children:r("span",{children:[s.name,i&&r("span",{className:n.vendorRetention,children:[" ","(Retained: ",i,"d)"]})]})},s.id)})}),e("p",{className:n.vendorListMetaText,style:{fontStyle:"italic",marginTop:"0.25rem"},children:M.preferenceCenter.vendorList.requiredNotice})]}),R.length>0&&r("div",{className:n.vendorPurposesList,children:[r("h4",{className:n.vendorPurposesTitle,children:[M.preferenceCenter.vendorList.specialFeatures," (",R.length,")"]}),e("ul",{className:n.vendorPurposesItems,children:R.map(r=>e("li",{className:n.vendorPurposeItem,children:r.name},r.id))})]}),B.length>0&&r("div",{className:n.vendorPurposesList,children:[r("h4",{className:n.vendorPurposesTitle,children:[M.preferenceCenter.vendorList.features," (",B.length,")"]}),e("ul",{className:n.vendorPurposesItems,children:B.map(r=>e("li",{className:n.vendorPurposeItem,children:r.name},r.id))})]})]})]},t.id)};return r("div",{...A,children:[null===f?r("div",{...T,children:[r("div",{...D,children:[r("svg",{className:n.searchIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e("input",{type:"text",placeholder:M.preferenceCenter.vendorList.search,value:x,onChange:e=>I(e.target.value),className:n.searchInput})]}),e("p",{className:n.vendorCount,children:M.preferenceCenter.vendorList.showingCount.replace("{filtered}",String(R.length)).replace("{total}",String(w.length))})]}):r("div",{...U,children:[e("p",{className:n.selectedVendorText,children:M.common.showingSelectedVendor}),r("button",{type:"button",onClick:N,className:n.clearSelectionButton,children:[r("svg",{className:n.clearIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M.common.clearSelection]})]}),B.length>0&&r("div",{className:n.vendorSection,children:[r("div",{className:n.iabVendorSectionHeader,children:[r("h3",{className:n.vendorSectionHeading,children:[r("svg",{className:n.vendorSectionIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e("path",{d:"M2 17l10 5 10-5"}),e("path",{d:"M2 12l10 5 10-5"})]}),M.preferenceCenter.vendorList.iabVendorsHeading," (",B.length,")"]}),e("p",{className:n.iabVendorNotice,children:M.preferenceCenter.vendorList.iabVendorsNotice})]}),e("div",{children:B.map(e=>$(e))})]}),V.length>0&&r("div",{className:n.vendorSection,children:[r("div",{className:n.customVendorSectionHeader,children:[r("h3",{className:n.vendorSectionHeading,children:[r("svg",{className:n.vendorSectionIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),M.preferenceCenter.vendorList.customVendorsHeading," (",V.length,")"]}),e("p",{className:n.customVendorNotice,children:M.preferenceCenter.vendorList.customVendorsNotice})]}),e("div",{children:V.map(e=>$(e))})]}),0===R.length&&e("div",{className:n.emptyState,children:r("p",{className:n.emptyStateText,children:['No vendors found matching "',x,'"']})})]})};export{h as VendorList};
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{resolveIABVendorUrls as n}from"@c15t/iab/headless";import t from"@c15t/ui/styles/components/iab-consent-dialog";import{useEffect as s,useState as i}from"react";import{useTranslations as o}from"../../../hooks.js";import{useTheme as a}from"../../../hooks/use-theme.js";import{useUIConfig as l}from"../../../ui-config-context.js";import{mergeSlotProps as d}from"../../../utils/merge-slot-props.js";import{useIABTranslations as c}from"../use-iab-translations.js";import*as m from"../../shared/ui/preference-item/index.js";import*as p from"../../shared/ui/switch/index.js";let h=[],u={},v=({vendorData:v,purposes:g,vendorConsents:f,onVendorToggle:N,selectedVendorId:C,onClearSelection:k,customVendors:L=h,vendorLegitimateInterests:S=u,onVendorLegitimateInterestToggle:x})=>{let{components:y}=l(),{noStyle:I}=a(),[P,b]=i(""),[M,w]=i(new Set),R=c(),B=o()?.language,V=[...v?Object.entries(v.vendors).map(([e,r])=>({cookieMaxAgeSeconds:r.cookieMaxAgeSeconds,cookieRefresh:r.cookieRefresh,dataDeclaration:r.dataDeclaration||[],dataRetention:r.dataRetention,deviceStorageDisclosureUrl:r.deviceStorageDisclosureUrl??null,features:r.features||[],id:Number(e),isCustom:!1,legIntPurposes:r.legIntPurposes||[],...n(r,B),name:r.name,purposes:r.purposes||[],specialFeatures:r.specialFeatures||[],specialPurposes:r.specialPurposes||[],usesCookies:r.usesCookies,usesNonCookieAccess:r.usesNonCookieAccess})):[],...L.map(e=>({cookieMaxAgeSeconds:e.cookieMaxAgeSeconds??null,cookieRefresh:void 0,dataDeclaration:e.dataCategories||[],dataRetention:void 0,deviceStorageDisclosureUrl:null,features:e.features||[],id:e.id,isCustom:!0,legIntPurposes:e.legIntPurposes||[],legitimateInterestUrl:null,name:e.name,policyUrl:e.privacyPolicyUrl,purposes:e.purposes||[],specialFeatures:e.specialFeatures||[],specialPurposes:[],usesCookies:e.usesCookies??!1,usesNonCookieAccess:e.usesNonCookieAccess??!1}))].sort((e,r)=>e.name.localeCompare(r.name));s(()=>{if(null!==C){let e=requestAnimationFrame(()=>{w(e=>new Set(e).add(C))}),r=setTimeout(()=>{let e=document.getElementById(`vendor-${String(C)}`);e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>{cancelAnimationFrame(e),clearTimeout(r)}}},[C]);let A=null===C?V.filter(e=>e.name.toLowerCase().includes(P.toLowerCase())):V.filter(e=>String(e.id)===String(C)),T=A.filter(e=>!e.isCustom),j=A.filter(e=>e.isCustom),D=d(y?.["iab-vendor-list"]?.root,{noStyle:I}),$=d(y?.["iab-vendor-list"]?.header,{baseClassName:t.vendorListHeader,noStyle:I}),H=d(y?.["iab-vendor-list"]?.search,{baseClassName:t.searchContainer,noStyle:I}),W=d(y?.["iab-vendor-list"]?.selectedVendor,{baseClassName:t.selectedVendorBanner,noStyle:I}),U=function(n){var s,i,o,a;let l,c,h,u,C=String(n.id),k=(s=n.id,(l=V.find(e=>String(e.id)===String(s)))?g.filter(e=>e.vendors.some(e=>String(e.id)===String(s))).map(e=>({...e,usesLegitimateInterest:l.legIntPurposes.includes(e.id)})):[]),L=(i=n.id,(c=V.find(e=>String(e.id)===String(i)))&&v?c.specialPurposes.map(e=>v.specialPurposes[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),P=(o=n.id,(h=V.find(e=>String(e.id)===String(o)))&&v?h.specialFeatures.map(e=>v.specialFeatures[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),b=(a=n.id,(u=V.find(e=>String(e.id)===String(a)))&&v?(u.features||[]).map(e=>v.features[e]).filter(e=>null!=e).map(e=>({description:e.description,id:e.id,name:e.name})):[]),B=M.has(n.id),A=k.filter(e=>e.usesLegitimateInterest).length,T=n.legIntPurposes.length>0,j=S[C]??!0,D=n.dataRetention?.stdRetention,$=null;n.cookieMaxAgeSeconds&&($=R.preferenceCenter.vendorList.maxAge.replace("{days}",String(Math.floor(n.cookieMaxAgeSeconds/86400))),n.cookieRefresh&&($=`${$} (refreshes)`));let H=d(y?.["iab-vendor-list"]?.rowHeader,{baseClassName:t.vendorListItemHeader,noStyle:I});return r(m.Root,{id:`vendor-${C}`,className:I?void 0:`${t.vendorListItem} ${n.isCustom?t.customVendorItem:""}`,noStyle:!0,onOpenChange:()=>{var e;return e=n.id,void w(r=>{let n=new Set(r);return n.has(e)?n.delete(e):n.add(e),n})},open:B,slotKey:"iab-vendor-list.row",children:[r("div",{...H,children:[r(m.Trigger,{className:t.vendorListTrigger,noStyle:!0,children:[r("div",{className:t.vendorListInfo,children:[r("h3",{className:t.vendorListName,children:[n.name,n.isCustom&&r("svg",{className:t.customVendorIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-label":R.common.customPartner,children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})]}),r("div",{className:t.vendorListMeta,children:[r("span",{className:t.vendorListMetaText,children:[k.length," purpose",1===k.length?"":"s",L.length>0&&`, ${L.length} special`,P.length>0&&`, ${P.length} feature${1===P.length?"":"s"}`]}),A>0&&r("span",{className:t.vendorListLiBadge,children:[e("svg",{style:{height:"0.625rem",width:"0.625rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),A," ",R.preferenceCenter.vendorList.legitimateInterest]})]})]}),e("svg",{className:t.purposeArrow,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:B?e("path",{d:"M19 15l-7-7-7 7"}):e("path",{d:"M19 9l-7 7-7-7"})})]}),e("div",{className:t.vendorConsentControl,children:e(p.Root,{"aria-label":`Consent for ${n.name}`,className:t.vendorConsentSwitch,checked:f[C]??!1,onCheckedChange:e=>N(n.id,e)})})]}),r(m.Content,{innerClassName:I?void 0:t.vendorListContent,innerSlotKey:"iab-vendor-list.rowContent",noStyle:I,children:[r("div",{className:t.vendorLinks,children:[r("a",{href:n.policyUrl,target:"_blank",rel:"noopener noreferrer",className:t.vendorLink,children:[r("svg",{className:t.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),R.preferenceCenter.vendorList.privacyPolicy]}),n.legitimateInterestUrl&&r("a",{href:n.legitimateInterestUrl,target:"_blank",rel:"noopener noreferrer",className:t.vendorLink,children:[r("svg",{className:t.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),R.preferenceCenter.purposeItem.legitimateInterest]}),n.deviceStorageDisclosureUrl&&r("a",{href:n.deviceStorageDisclosureUrl,target:"_blank",rel:"noopener noreferrer",className:t.vendorLink,children:[r("svg",{className:t.vendorLinkIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e("polyline",{points:"15 3 21 3 21 9"}),e("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),R.preferenceCenter.vendorList.storageDisclosure]})]}),r("div",{className:t.vendorBadges,children:[n.usesCookies&&e("span",{className:t.vendorBadge,children:R.preferenceCenter.vendorList.usesCookies}),n.usesNonCookieAccess&&e("span",{className:t.vendorBadge,children:R.preferenceCenter.vendorList.nonCookieAccess}),$&&e("span",{className:t.vendorBadge,children:$}),D&&e("span",{className:t.vendorBadge,children:R.preferenceCenter.vendorList.retention.replace("{days}",String(D))})]}),k.length>0&&r("div",{className:t.vendorPurposesList,children:[r("h4",{className:t.vendorPurposesTitle,children:[R.preferenceCenter.vendorList.purposes," (",k.length,")"]}),e("ul",{className:t.vendorPurposesItems,children:k.map(s=>{let i;return n.dataRetention?.purposes?.[s.id]?i=n.dataRetention.purposes[s.id]:n.dataRetention?.stdRetention&&(i=n.dataRetention.stdRetention),r("li",{className:`${t.vendorPurposeItem} ${s.usesLegitimateInterest?t.vendorPurposeItemLi:""}`,children:[r("span",{children:[s.name,i&&r("span",{className:t.vendorRetention,children:[" ","(Retained: ",i,"d)"]})]}),s.usesLegitimateInterest&&r("span",{className:t.vendorListLiBadge,children:[e("svg",{style:{height:"0.625rem",width:"0.625rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),R.preferenceCenter.vendorList.legitimateInterest]})]},s.id)})})]}),T&&x&&r("div",{className:t.vendorLiSection,children:[r("div",{className:t.vendorLiSectionHeader,children:[r("h4",{className:t.vendorPurposesTitle,children:[e("svg",{style:{height:"0.75rem",marginRight:"0.25rem",width:"0.75rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e("path",{d:"M12 3v18M3 12h18M4.93 4.93l14.14 14.14M19.07 4.93L4.93 19.07"})}),R.preferenceCenter.purposeItem.legitimateInterest]}),e("button",{type:"button",onClick:()=>x(n.id,!j),className:`${t.objectButton} ${j?"":t.objectButtonActive}`,"aria-pressed":!j,children:j?R.preferenceCenter.purposeItem.objectButton:R.preferenceCenter.purposeItem.objected})]}),e("p",{className:t.liExplanation,children:R.preferenceCenter.purposeItem.rightToObject})]}),n.dataDeclaration&&n.dataDeclaration.length>0&&r("div",{className:t.vendorPurposesList,children:[r("h4",{className:t.vendorPurposesTitle,children:[R.preferenceCenter.vendorList.dataCategories," (",n.dataDeclaration.length,")"]}),e("ul",{className:t.vendorPurposesItems,children:n.dataDeclaration.map(r=>{let n=v?.dataCategories?.[r];return e("li",{className:t.vendorPurposeItem,title:n?.description,children:n?.name||`Data Category ${r}`},r)})})]}),L.length>0&&r("div",{className:t.vendorPurposesList,children:[r("h4",{className:t.vendorPurposesTitle,children:[r("svg",{"aria-hidden":"true",focusable:"false",style:{height:"0.75rem",marginRight:"0.25rem",width:"0.75rem"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("title",{children:R.preferenceCenter.vendorList.specialPurposes}),e("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),R.preferenceCenter.vendorList.specialPurposes," (",L.length,")"]}),e("ul",{className:t.vendorPurposesItems,children:L.map(s=>{let i;return n.dataRetention?.specialPurposes?.[s.id]?i=n.dataRetention.specialPurposes[s.id]:n.dataRetention?.stdRetention&&(i=n.dataRetention.stdRetention),e("li",{className:t.vendorPurposeItem,children:r("span",{children:[s.name,i&&r("span",{className:t.vendorRetention,children:[" ","(Retained: ",i,"d)"]})]})},s.id)})}),e("p",{className:t.vendorListMetaText,style:{fontStyle:"italic",marginTop:"0.25rem"},children:R.preferenceCenter.vendorList.requiredNotice})]}),P.length>0&&r("div",{className:t.vendorPurposesList,children:[r("h4",{className:t.vendorPurposesTitle,children:[R.preferenceCenter.vendorList.specialFeatures," (",P.length,")"]}),e("ul",{className:t.vendorPurposesItems,children:P.map(r=>e("li",{className:t.vendorPurposeItem,children:r.name},r.id))})]}),b.length>0&&r("div",{className:t.vendorPurposesList,children:[r("h4",{className:t.vendorPurposesTitle,children:[R.preferenceCenter.vendorList.features," (",b.length,")"]}),e("ul",{className:t.vendorPurposesItems,children:b.map(r=>e("li",{className:t.vendorPurposeItem,children:r.name},r.id))})]})]})]},n.id)};return r("div",{...D,children:[null===C?r("div",{...$,children:[r("div",{...H,children:[r("svg",{className:t.searchIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e("input",{type:"text",placeholder:R.preferenceCenter.vendorList.search,value:P,onChange:e=>b(e.target.value),className:t.searchInput})]}),e("p",{className:t.vendorCount,children:R.preferenceCenter.vendorList.showingCount.replace("{filtered}",String(A.length)).replace("{total}",String(V.length))})]}):r("div",{...W,children:[e("p",{className:t.selectedVendorText,children:R.common.showingSelectedVendor}),r("button",{type:"button",onClick:k,className:t.clearSelectionButton,children:[r("svg",{className:t.clearIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),R.common.clearSelection]})]}),T.length>0&&r("div",{className:t.vendorSection,children:[r("div",{className:t.iabVendorSectionHeader,children:[r("h3",{className:t.vendorSectionHeading,children:[r("svg",{className:t.vendorSectionIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e("path",{d:"M2 17l10 5 10-5"}),e("path",{d:"M2 12l10 5 10-5"})]}),R.preferenceCenter.vendorList.iabVendorsHeading," (",T.length,")"]}),e("p",{className:t.iabVendorNotice,children:R.preferenceCenter.vendorList.iabVendorsNotice})]}),e("div",{children:T.map(e=>U(e))})]}),j.length>0&&r("div",{className:t.vendorSection,children:[r("div",{className:t.customVendorSectionHeader,children:[r("h3",{className:t.vendorSectionHeading,children:[r("svg",{className:t.vendorSectionIcon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),R.preferenceCenter.vendorList.customVendorsHeading," (",j.length,")"]}),e("p",{className:t.customVendorNotice,children:R.preferenceCenter.vendorList.customVendorsNotice})]}),e("div",{children:j.map(e=>U(e))})]}),0===A.length&&e("div",{className:t.emptyState,children:r("p",{className:t.emptyStateText,children:['No vendors found matching "',P,'"']})})]})};export{v as VendorList};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{processGVLForDialog as t}from"@c15t/iab/headless";import{useMemo as a}from"react";import{useIAB as e}from"../../../iab-context.js";let r=function(){let r=e();return a(()=>t(r),[r])};export{r as useGVLData};
|
|
2
|
+
import{processGVLForDialog as t}from"@c15t/iab/headless";import{useMemo as a}from"react";import{useTranslations as o}from"../../../hooks.js";import{useIAB as e}from"../../../iab-context.js";let r=function(){let r=e(),s=o()?.language;return a(()=>t(r&&{...r,language:s}),[r,s])};export{r as useGVLData};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import{IABConsentDialogCard as o}from"./atoms/card.js";import{IABConsentDialogContent as t}from"./atoms/content.js";import{FeatureItem as e}from"./atoms/feature-item.js";import{IABConsentDialogFooter as s}from"./atoms/footer.js";import{IABConsentDialogHeader as a}from"./atoms/header.js";import{IABConsentDialogOverlay as r}from"./atoms/overlay.js";import{PurposeItem as m}from"./atoms/purpose-item.js";import{IABConsentDialogRoot as n}from"./atoms/root.js";import{StackItem as i}from"./atoms/stack-item.js";import{IABConsentDialogTabButton as p,IABConsentDialogTabs as l}from"./atoms/tabs.js";import{VendorList as f}from"./atoms/vendor-list.js";import{IABConsentDialog as I}from"./iab-panel.js";let j=Object.assign(I,{Card:o,Content:t,FeatureItem:e,Footer:s,Header:a,Overlay:r,PurposeItem:m,Root:n,StackItem:i,TabButton:p,Tabs:l,VendorList:f});export{useIABDisplayModel}from"./hooks/use-display-model.js";export{useGVLData}from"./hooks/use-gvl-data.js";export default j;export{e as FeatureItem,o as IABConsentDialogCard,t as IABConsentDialogContent,s as IABConsentDialogFooter,a as IABConsentDialogHeader,r as IABConsentDialogOverlay,n as IABConsentDialogRoot,p as IABConsentDialogTabButton,l as IABConsentDialogTabs,m as PurposeItem,i as StackItem,f as VendorList,j as IABConsentDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import{Card as o,ConsentCustomizationCard as e,ConsentDialogContent as t,ConsentDialogFooter as n,ConsentDialogHeader as a,ConsentDialogHeaderDescription as r,ConsentDialogHeaderTitle as i,Content as s,Footer as l,Header as C,HeaderDescription as d,HeaderTitle as D}from"./atoms/card.js";import{ConsentDialogOverlay as g,Overlay as m}from"./atoms/overlay.js";import{ConsentDialogRoot as p,Root as H}from"./atoms/root.js";import{ConsentDialog as c}from"./panel.js";let f=Object.assign(c,{Card:o,ConsentCustomizationCard:e,ConsentDialogContent:t,ConsentDialogFooter:n,ConsentDialogHeader:a,ConsentDialogHeaderDescription:r,ConsentDialogHeaderTitle:i,Content:s,Footer:l,Header:C,HeaderDescription:d,HeaderTitle:D,Overlay:m,Root:H});export default f;export{o as Card,e as ConsentCustomizationCard,t as ConsentDialogContent,n as ConsentDialogFooter,a as ConsentDialogHeader,r as ConsentDialogHeaderDescription,i as ConsentDialogHeaderTitle,g as ConsentDialogOverlay,p as ConsentDialogRoot,s as Content,l as Footer,C as Header,d as HeaderDescription,D as HeaderTitle,m as Overlay,H as Root,f as ConsentDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{createElement as t,useMemo as r,useRef as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{createElement as t,useLayoutEffect as o,useMemo as r,useRef as i,useState as n}from"react";import s from"@c15t/ui/styles/components/consent-dialog-trigger";import{followDevToolsDock as l}from"@c15t/ui/utils/devtools-launcher";import{useTranslations as a}from"../../../component-hooks/use-translations.js";import{useDevToolsLauncher as d}from"../../../devtools-launcher.js";import{usePolicyRule as c}from"../../../hooks.js";import{useTheme as f}from"../../../hooks/use-theme.js";import{useUIConfig as m}from"../../../ui-config-context.js";import{mergeSlotProps as g}from"../../../utils/merge-slot-props.js";import{TriggerIcon as u}from"./icon.js";import{useTriggerContext as p}from"./root.js";import{DevToolsIcon as b}from"./trigger-icons.js";let h={"bottom-left":s.bottomLeft,"bottom-right":s.bottomRight,"top-left":s.topLeft,"top-right":s.topRight},k={lg:s.lg,md:s.md,sm:s.sm},y={focusId:"devtools",icon:e(b,{}),id:"devtools",kind:"devtools",label:"c15t DevTools"},v=function(){let e=c(),{rights:t}=a();return r(()=>{let o=e.rights.includes("opt-out")?"opt-out":"preferences";return{label:"opt-out"===o&&e.i18n?.messageProfile!=="preferences"?t?.optOut??"Do not sell or share my data":t?.preferences??"Manage preferences",right:o,rights:e.rights.join(" ")}},[e.rights,e.i18n?.messageProfile,t])},I=function(e,t,o,r,i,n){let s=e.map(e=>({...e,focusId:`custom:${e.id}`,kind:"custom"}));return(n&&s.push(y),i)?[...s,{className:t.className,focusId:"preferences",icon:t.icon??"branding",id:"preferences",kind:"preferences",label:t.label??r,onSelect:t.onSelect,right:o,style:t.style}]:s},j=function(e,t,o){let r=e.find(e=>"preferences"===e.kind),i=e.find(e=>"devtools"===e.kind);if(!r&&!i)return e;let n=e.filter(e=>"custom"===e.kind),s="horizontal"===t?o.endsWith("left"):o.startsWith("top"),l=r?[r]:[],a=i?[i]:[];return s?[...l,...n,...a]:[...a,...n,...l]},N=({actions:a,preferences:c,size:b="md",orientation:y="horizontal",ariaLabel:N="Privacy controls",showPreferences:S=!0,className:w,style:x,noStyle:D=!1})=>{let{components:C}=m(),{disableAnimation:T,noStyle:A}=f(),{label:L,right:P,rights:R}=v(),{corner:z,isDragging:E,isSnapping:H,wasDragged:M,handlers:O,dragStyle:W,openDialog:B}=p(),F=d(),K=null!==F,U=F?.dock,V=i(null),$=r(()=>j(I(a,c,P,L,S,K),y,z),[a,z,L,y,c,P,K,S]);o(()=>{let e=V.current;if(U&&e&&!E)return l(e,z,U)},[z,U,E]);let q=$.find(e=>!e.disabled)?.focusId,[G,J]=n(q),Q=i(new Map),X=D||A,Y=g(C?.trigger?.toolbar,{baseClassName:[s.toolbar,"vertical"===y&&s.toolbarVertical,h[z],E&&s.dragging,H&&s.snapping],className:w,noStyle:X,style:x}),Z=g(C?.trigger?.toolbarItem,{baseClassName:[s.toolbarItem,k[b]],noStyle:X}),_=g(C?.trigger?.toolbarIcon,{baseClassName:s.toolbarIcon,noStyle:X}),ee=$.some(e=>e.focusId===G&&!e.disabled)?G:q;return e("div",{...Y,"aria-label":N,"aria-orientation":y,"data-corner":z,"data-c15t-trigger-toolbar":"true","data-c15t-trigger":"true","data-disable-animation":T?"":void 0,"data-dragging":E||void 0,"data-snapping":H||void 0,dir:"ltr",onKeyDown:e=>{let t,o="vertical"===y?"ArrowDown":"ArrowRight",r="vertical"===y?"ArrowUp":"ArrowLeft";if(e.key!==o&&e.key!==r&&"Home"!==e.key&&"End"!==e.key)return;let i=$.filter(e=>!e.disabled);if(0===i.length)return;e.preventDefault();let n=i.findIndex(e=>e.focusId===ee);t="Home"===e.key?0:"End"===e.key?i.length-1:e.key===o?(n+1)%i.length:(n-1+i.length)%i.length;let s=i[t];s&&(J(s.focusId),Q.current.get(s.focusId)?.focus())},ref:V,role:"toolbar",style:{...Y.style,...W},tabIndex:-1,...O,children:$.map(o=>t("button",{...Z,key:o.focusId,ref:e=>{e?Q.current.set(o.focusId,e):Q.current.delete(o.focusId)},"aria-label":o.label,"aria-expanded":"devtools"===o.kind?F?.isOpen:void 0,"aria-pressed":"custom"===o.kind?o.pressed:void 0,className:[Z.className,o.className].filter(Boolean).join(" "),"data-c15t-rights":"preferences"===o.kind?R:void 0,"data-c15t-trigger-action":o.kind,"data-c15t-trigger-item":o.id,"data-right":"preferences"===o.kind?o.right:void 0,disabled:o.disabled,onClick:e=>((e,t)=>{if(!(0!==e.detail&&M())){if("devtools"===t.kind)return void F?.toggle();t.onSelect?.(),"preferences"===t.kind&&B()}})(e,o),onFocus:()=>J(o.focusId),style:{...Z.style,...o.style},tabIndex:o.focusId===ee?0:-1,type:"button"},e("span",{..._,"aria-hidden":"true",children:e(u,{icon:o.icon,noStyle:X})})))})};N.displayName="ConsentDialogTriggerToolbar";export{N as TriggerToolbar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as a,jsxs as t}from"react/jsx-runtime";let e=({title:e="Privacy",titleId:
|
|
1
|
+
import{jsx as a,jsxs as t}from"react/jsx-runtime";let e=({title:e="Privacy",titleId:r="fingerprint-icon",...o})=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-labelledby":r,...o,children:[a("title",{id:r,children:e}),a("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),a("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),a("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),a("path",{d:"M2 12a10 10 0 0 1 18-6"}),a("path",{d:"M2 16h.01"}),a("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),a("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),a("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),a("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]}),r=({title:e="Settings",titleId:r="settings-icon",...o})=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-labelledby":r,...o,children:[a("title",{id:r,children:e}),a("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),a("circle",{cx:"12",cy:"12",r:"3"})]}),o=e=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:[a("path",{d:"m18 16 4-4-4-4"}),a("path",{d:"m6 8-4 4 4 4"}),a("path",{d:"m14.5 4-5 16"})]});export{o as DevToolsIcon,e as FingerprintIcon,r as SettingsIcon};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as o}from"react/jsx-runtime";import{
|
|
2
|
+
import{jsx as o}from"react/jsx-runtime";import{useMemo as t}from"react";import{useDevToolsLauncherAvailable as r}from"../../devtools-launcher.js";import{TriggerButton as e}from"./atoms/button.js";import{TriggerIcon as i}from"./atoms/icon.js";import{TriggerRoot as n,useTriggerContext as s}from"./atoms/root.js";import{TriggerText as a}from"./atoms/text.js";import{TriggerToolbar as m}from"./atoms/toolbar.js";let g=[],l=({icon:s="branding",defaultPosition:a="bottom-right",persistPosition:l=!0,ariaLabel:c="Open privacy settings",showWhen:p="always",size:f="md",className:T,noStyle:j,onClick:u,onPositionChange:b})=>{let d=r(),h=t(()=>({className:T,icon:s,label:c}),[c,T,s]);return o(n,{defaultPosition:a,persistPosition:l,showWhen:p,onClick:u,onPositionChange:b,children:d?o(m,{actions:g,noStyle:j,preferences:h,size:f}):o(e,{size:f,ariaLabel:c,className:T,noStyle:j,children:o(i,{icon:s,noStyle:j})})})};l.displayName="ConsentDialogTrigger";let c=Object.assign(l,{Button:e,Icon:i,Root:n,Text:a});export{c as ConsentDialogTrigger,e as TriggerButton,i as TriggerIcon,n as TriggerRoot,a as TriggerText,s as useTriggerContext};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import{Accordion as o,AccordionArrow as t,AccordionContent as n,AccordionItem as e,AccordionItems as r,AccordionTrigger as i,AccordionTriggerInner as c,ConsentWidgetAccordion as s,ConsentWidgetAccordionArrow as d,ConsentWidgetAccordionContent as A,ConsentWidgetAccordionItem as g,ConsentWidgetAccordionItems as m,ConsentWidgetAccordionTrigger as C,ConsentWidgetAccordionTriggerInner as u,ConsentWidgetSwitch as W,ConsentWidgetVendorList as p,Switch as a,VendorList as l}from"./atoms/accordion.js";import{AcceptAllButton as B,ConsentWidgetAcceptAllButton as f,ConsentWidgetCustomizeButton as j,ConsentWidgetRejectButton as I,ConsentWidgetSaveButton as S,CustomizeButton as w,RejectButton as F,SaveButton as R}from"./atoms/button.js";import{ConsentWidgetFooter as T,ConsentWidgetFooterSubGroup as b,Footer as y,FooterSubGroup as h}from"./atoms/footer.js";import{ConsentWidgetRoot as v,Root as z}from"./atoms/root.js";import{ConsentWidgetPolicyActions as G,PolicyActions as L}from"./policy-actions.js";import{ConsentWidget as P}from"./preferences.js";let V=Object.assign(P,{AcceptAllButton:B,Accordion:o,AccordionArrow:t,AccordionContent:n,AccordionItem:e,AccordionItems:r,AccordionTrigger:i,AccordionTriggerInner:c,CustomizeButton:w,Footer:y,FooterSubGroup:h,PolicyActions:L,RejectButton:F,Root:z,SaveButton:R,Switch:a,VendorList:l});export default V;export{B as AcceptAllButton,o as Accordion,t as AccordionArrow,n as AccordionContent,e as AccordionItem,r as AccordionItems,i as AccordionTrigger,c as AccordionTriggerInner,f as ConsentWidgetAcceptAllButton,s as ConsentWidgetAccordion,d as ConsentWidgetAccordionArrow,A as ConsentWidgetAccordionContent,g as ConsentWidgetAccordionItem,m as ConsentWidgetAccordionItems,C as ConsentWidgetAccordionTrigger,u as ConsentWidgetAccordionTriggerInner,j as ConsentWidgetCustomizeButton,T as ConsentWidgetFooter,b as ConsentWidgetFooterSubGroup,G as ConsentWidgetPolicyActions,I as ConsentWidgetRejectButton,v as ConsentWidgetRoot,S as ConsentWidgetSaveButton,W as ConsentWidgetSwitch,p as ConsentWidgetVendorList,w as CustomizeButton,y as Footer,h as FooterSubGroup,L as PolicyActions,F as RejectButton,z as Root,R as SaveButton,a as Switch,l as VendorList,V as ConsentWidget};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as o}from"react/jsx-runtime";import{isAccordionItemOpen as e,toggleAccordionValue as t}from"@c15t/ui/primitives/accordion";import{getDataDisabled as a}from"@c15t/ui/primitives/data-state";import r from"@c15t/ui/styles/components/accordion";import
|
|
2
|
+
import{jsx as o}from"react/jsx-runtime";import{isAccordionItemOpen as e,toggleAccordionValue as t}from"@c15t/ui/primitives/accordion";import{getDataDisabled as a}from"@c15t/ui/primitives/data-state";import r from"@c15t/ui/styles/components/accordion";import{createContext as n,forwardRef as i,useContext as c,useId as l,useMemo as d}from"react";import{useControllableState as s}from"../../libs/use-controllable-state.js";import{LucideIcon as m}from"../icon.js";import{useTheme as p}from"../../../../hooks/use-theme.js";let u=()=>({arrowClose:o=>[r.arrow,o?.class].filter(Boolean).join(" "),arrowOpen:o=>[r.arrow,o?.class].filter(Boolean).join(" "),content:o=>[r.content,o?.class].filter(Boolean).join(" "),contentInner:o=>[r.contentInner,o?.class].filter(Boolean).join(" "),contentViewport:o=>[r.contentViewport,o?.class].filter(Boolean).join(" "),icon:o=>[r.control,o?.class].filter(Boolean).join(" "),item:o=>[r.item,o?.class].filter(Boolean).join(" "),root:o=>[r.list,o?.class].filter(Boolean).join(" "),trigger:o=>[r.trigger,o?.class].filter(Boolean).join(" ")}),f=n(null),g=n(null),v=function(){let o=c(f);if(!o)throw Error("Accordion components must be used within AccordionRoot");return o},h=function(){let o=c(g);if(!o)throw Error("Accordion components must be used within AccordionItem");return o},A=i(({children:e,className:a,collapsible:r,defaultValue:n,noStyle:i,onValueChange:c,size:l="medium",type:m,value:g,variant:v="default",...h},A)=>{let{noStyle:y}=p(),w=u(),N=y||i,[I,b]=s({defaultValue:n??("multiple"===m?[]:void 0),onChange:o=>{void 0!==o&&c?.(o)},value:g}),j=N?a:w.root({class:a}),B=d(()=>({collapsible:r,noStyle:N,onItemToggle:o=>{b(t({collapsible:r,itemValue:o,type:m,value:I}))},type:m,value:I}),[r,I,N,b,m]);return o(f.Provider,{value:B,children:o("div",{ref:A,className:j,"data-size":N?void 0:l,"data-slot":"accordion-root","data-variant":N?void 0:v,...h,children:e})})});A.displayName="AccordionRoot";let y=i(({children:t,className:r,disabled:n,noStyle:i,value:c,...s},m)=>{let{noStyle:f}=p(),h=u(),A=v(),y=e(A.type,A.value,c),w=A.noStyle||f||i?r:h.item({class:r}),N=l().replace(/:/gu,""),I=`c15t-accordion-content-${N}`,b=`c15t-accordion-trigger-${N}`,j=d(()=>({contentId:I,disabled:n,open:y,triggerId:b,value:c}),[I,n,y,b,c]);return o(g.Provider,{value:j,children:o("div",{ref:m,className:w,"data-disabled":a(n),"data-slot":"accordion-item","data-state":y?"open":"closed",...s,children:t})})});y.displayName="AccordionItem";let w=i(({children:e,className:t,...a},r)=>o("div",{ref:r,className:t,"data-slot":"accordion-header",...a,children:e}));w.displayName="AccordionHeader";let N=i(({children:e,className:t,noStyle:n,onClick:i,...c},l)=>{let{noStyle:d}=p(),s=v(),m=h(),u=s.noStyle||d||n?t:[r.triggerRow,t].filter(Boolean).join(" ");return o("button",{ref:l,"aria-controls":m.contentId,"aria-disabled":m.disabled||void 0,"aria-expanded":m.open,className:u,"data-disabled":a(m.disabled),"data-slot":"accordion-trigger","data-state":m.open?"open":"closed",disabled:m.disabled,id:m.triggerId,onClick:o=>{s.onItemToggle(m.value),i?.(o)},type:"button",...c,children:e})});N.displayName="AccordionTrigger";let I=({className:e,noStyle:t,as:a,...r})=>{let n=u(),i="string"==typeof e?e:void 0;return o(a||"div",{className:t?i:n.icon({class:i}),"data-slot":"accordion-icon",...r})};I.displayName="AccordionIcon";let b=m({iconPath:o("path",{d:"M5 12h14M12 5v14"}),title:"Open"}),j=({children:e,closeIcon:t,className:a,noStyle:r,openIcon:n,...i})=>{let c=h(),l=u(),d=r?a:l.arrowOpen({class:a}),s=n??t,m=s?.Element??b;return o("span",{className:d,"data-slot":"accordion-arrow","data-state":c.open?"open":"closed",...i,children:e??o(m,{"aria-hidden":"true",className:s?.className,"data-slot":"accordion-arrow-icon"})})};j.displayName="AccordionArrow";let B=i(({children:e,className:t,innerClassName:a,noStyle:r,...n},i)=>{let{noStyle:c}=p(),l=u(),d=v(),s=h(),m=d.noStyle||c||r,f=m?t:l.content({class:t}),g=m?a:l.contentInner({class:a});return o("section",{ref:i,"aria-hidden":!s.open,"aria-labelledby":s.triggerId,className:f,"data-slot":"accordion-content","data-state":s.open?"open":"closed",id:s.contentId,...n,children:o("div",{className:m?void 0:l.contentViewport({class:void 0}),"data-slot":"accordion-content-viewport",children:o("div",{className:g,children:e})})})});B.displayName="AccordionContent";export{j as Arrow,B as Content,w as Header,I as Icon,y as Item,A as Root,N as Trigger,u as accordionVariants};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{getCollapsibleState as t,toggleCollapsibleValue as l}from"@c15t/ui/primitives/collapsible";import{getDataDisabled as o}from"@c15t/ui/primitives/data-state";import a from"@c15t/ui/styles/components/collapsible";import
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{getCollapsibleState as t,toggleCollapsibleValue as l}from"@c15t/ui/primitives/collapsible";import{getDataDisabled as o}from"@c15t/ui/primitives/data-state";import a from"@c15t/ui/styles/components/collapsible";import{createContext as i,forwardRef as r,useContext as n,useId as s,useMemo as c}from"react";import{useControllableState as d}from"../../libs/use-controllable-state.js";import{useTheme as p}from"../../../../hooks/use-theme.js";let m=()=>({content:e=>[a.content,e?.class].filter(Boolean).join(" "),contentInner:e=>[a.contentInner,e?.class].filter(Boolean).join(" "),contentViewport:e=>[a.contentViewport,e?.class].filter(Boolean).join(" "),root:e=>[a.root,e?.class].filter(Boolean).join(" "),trigger:e=>[a.trigger,e?.class].filter(Boolean).join(" ")}),b=i(null),u=function(){let e=n(b);if(!e)throw Error("Collapsible components must be used within CollapsibleRoot");return e},g=r(({children:l,className:a,defaultOpen:i=!1,disabled:r,noStyle:n,onOpenChange:u,open:g,...f},C)=>{let h=s().replace(/:/gu,""),{noStyle:v}=p(),y=m(),[j,N]=d({defaultValue:i,onChange:u,value:g}),w=v||n,S=c(()=>({contentId:`c15t-collapsible-content-${h}`,disabled:r,noStyle:w,open:j,setOpen:N,triggerId:`c15t-collapsible-trigger-${h}`}),[r,w,j,h,N]);return e(b.Provider,{value:S,children:e("div",{ref:C,className:w?a:y.root({class:a}),"data-disabled":o(r),"data-slot":"collapsible-root","data-state":t(j),...f,children:l})})});g.displayName="CollapsibleRoot";let f=r(({children:a,className:i,noStyle:r,onClick:n,...s},c)=>{let{noStyle:d}=p(),b=m(),{contentId:g,disabled:f,noStyle:C,open:h,setOpen:v,triggerId:y}=u();return e("button",{ref:c,"aria-controls":g,"aria-disabled":f||void 0,"aria-expanded":h,className:C||d||r?i:b.trigger({class:i}),"data-disabled":o(f),"data-slot":"collapsible-trigger","data-state":t(h),disabled:f,id:y,onClick:e=>{f||v(l(h)),n?.(e)},type:"button",...s,children:a})});f.displayName="CollapsibleTrigger";let C=r(({children:l,className:o,innerClassName:a,noStyle:i,...r},n)=>{let{noStyle:s}=p(),c=m(),{contentId:d,noStyle:b,open:g,triggerId:f}=u();return e("div",{ref:n,"aria-hidden":!g,"aria-labelledby":f,className:c.content({class:o}),"data-slot":"collapsible-content","data-state":t(g),id:d,inert:!g,...r,children:e("div",{className:c.contentViewport({class:void 0}),"data-slot":"collapsible-content-viewport",children:e("div",{className:c.contentInner({class:a}),children:l})})})});C.displayName="CollapsibleContent";export{C as Content,g as Root,f as Trigger,m as collapsibleVariants};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{getDataDisabled as t}from"@c15t/ui/primitives/data-state";import{PREFERENCE_ITEM_INTERNAL_SLOTS as r,PREFERENCE_ITEM_SLOTS as n,getPreferenceItemState as a,togglePreferenceItemValue as o}from"@c15t/ui/primitives/preference-item";import l from"@c15t/ui/styles/components/preference-item";import
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{getDataDisabled as t}from"@c15t/ui/primitives/data-state";import{PREFERENCE_ITEM_INTERNAL_SLOTS as r,PREFERENCE_ITEM_SLOTS as n,getPreferenceItemState as a,togglePreferenceItemValue as o}from"@c15t/ui/primitives/preference-item";import l from"@c15t/ui/styles/components/preference-item";import{createContext as i,forwardRef as s,useContext as c,useId as m,useMemo as d,useState as f}from"react";import{useControllableState as p}from"../../libs/use-controllable-state.js";import{useTheme as u}from"../../../../hooks/use-theme.js";import{useUIConfig as y}from"../../../../ui-config-context.js";import{getSlotProps as g,mergeSlotProps as I}from"../../../../utils/merge-slot-props.js";let P=()=>({auxiliary:e=>[l.auxiliary,e?.class].filter(Boolean).join(" "),content:e=>[l.content,e?.class].filter(Boolean).join(" "),contentInner:e=>[l.contentInner,e?.class].filter(Boolean).join(" "),contentViewport:e=>[l.contentViewport,e?.class].filter(Boolean).join(" "),control:e=>[l.control,e?.class].filter(Boolean).join(" "),header:e=>[l.header,e?.class].filter(Boolean).join(" "),leading:e=>[l.leading,e?.class].filter(Boolean).join(" "),meta:e=>[l.meta,e?.class].filter(Boolean).join(" "),root:e=>[l.root,e?.class].filter(Boolean).join(" "),title:e=>[l.title,e?.class].filter(Boolean).join(" "),trigger:e=>[l.trigger,e?.class].filter(Boolean).join(" ")}),b=i(null),h=function(){let e=c(b);if(!e)throw Error("PreferenceItem components must be used within PreferenceItemRoot");return e},S=s(({children:r,className:o,defaultOpen:l=!1,disabled:i,noStyle:s,onOpenChange:c,open:f,slotKey:h,...S},j)=>{let{components:C}=y(),{noStyle:N}=u(),v=P(),[x,B]=p({defaultValue:l,onChange:c,value:f}),w=m().replace(/:/gu,""),T=s??N,V=I(g(C,h),{baseClassName:v.root(),className:o,noStyle:T,...S}),R=d(()=>({contentId:`c15t-preference-item-content-${w}`,disabled:i,noStyle:T,open:x,setOpen:B,triggerId:`c15t-preference-item-trigger-${w}`}),[i,T,x,w,B]);return e(b.Provider,{value:R,children:e("div",{...V,ref:j,"data-disabled":t(i),"data-slot":n.root,"data-state":a(x),children:r})})});S.displayName="PreferenceItemRoot";let j=s(({children:r,className:l,noStyle:i,onClick:s,slotKey:c,...m},d)=>{let{components:f}=y(),{noStyle:p}=u(),b=P(),{contentId:S,disabled:j,noStyle:C,open:N,setOpen:v,triggerId:x}=h();return e("button",{...I(g(f,c),{baseClassName:b.trigger(),className:l,noStyle:i??C??p,...m}),ref:d,"aria-controls":S,"aria-disabled":j||void 0,"aria-expanded":N,"data-disabled":t(j),"data-slot":n.trigger,"data-state":a(N),disabled:j,id:x,onClick:e=>{j||v(o(N)),s?.(e)},type:"button",children:r})});j.displayName="PreferenceItemTrigger";let C=function(t,r,n){let a=s(({className:t,noStyle:a,slotKey:o,...l},i)=>{let{components:s}=y(),{noStyle:c}=u(),{noStyle:m}=h(),d=P();return e("div",{...I(g(s,o),{baseClassName:d[n](),className:t,noStyle:a??m??c,...l}),ref:i,"data-slot":r})});return a.displayName=t,a},N=C("PreferenceItemLeading",n.leading,"leading"),v=C("PreferenceItemHeader",n.header,"header"),x=C("PreferenceItemMeta",n.meta,"meta"),B=C("PreferenceItemAuxiliary",n.auxiliary,"auxiliary"),w=C("PreferenceItemControl",n.control,"control"),T=s(({children:t,className:r,noStyle:a,...o},l)=>{let{components:i}=y(),{noStyle:s}=u(),{noStyle:c}=h(),m=P(),{slotKey:d,...f}=o;return e("h3",{...I(g(i,d),{baseClassName:m.title(),className:r,noStyle:a??c??s,...f}),ref:l,"data-slot":n.title,children:t})});T.displayName="PreferenceItemTitle";let V=s(({children:t,className:o,forceMount:l=!1,innerClassName:i,innerSlotKey:s,noStyle:c,slotKey:m,viewportClassName:d,viewportSlotKey:p,...b},S)=>{let{components:j}=y(),{noStyle:C}=u(),N=P(),{contentId:v,noStyle:x,open:B,triggerId:w}=h(),[T,V]=f(B);B&&!T&&V(!0);let R=l||B||T,A=c??x??C,H=I(g(j,m),{baseClassName:N.content(),className:o,noStyle:A,...b}),L=I(g(j,p),{baseClassName:N.contentViewport(),className:d,noStyle:A}),M=I(g(j,s),{baseClassName:N.contentInner(),className:i,noStyle:A});return e("div",{...H,ref:S,"aria-hidden":!B,"aria-labelledby":w,"data-slot":n.content,"data-state":a(B),id:v,inert:!B,children:e("div",{...L,"data-slot":r.contentViewport,children:e("div",{...M,"data-slot":r.contentInner,children:R?t:null})})})});V.displayName="PreferenceItemContent";export{B as Auxiliary,V as Content,w as Control,v as Header,N as Leading,x as Meta,S as Root,T as Title,j as Trigger,P as preferenceItemVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{getDataDisabled as o}from"@c15t/ui/primitives/data-state";import{getSwitchState as e,toggleSwitchValue as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{getDataDisabled as o}from"@c15t/ui/primitives/data-state";import{getSwitchState as e,toggleSwitchValue as a}from"@c15t/ui/primitives/switch";import s from"@c15t/ui/styles/components/switch";import{forwardRef as i}from"react";import{useControllableState as r}from"../../libs/use-controllable-state.js";import{useTheme as l}from"../../../../hooks/use-theme.js";import{useUIConfig as m}from"../../../../ui-config-context.js";import{mergeSlotProps as c}from"../../../../utils/merge-slot-props.js";let n=()=>({root:t=>[s.root,t?.class].filter(Boolean).join(" "),thumb:t=>[s.thumb,t?.class].filter(Boolean).join(" "),track:t=>[s.track,t?.class].filter(Boolean).join(" ")}),h=i(({checked:s,className:i,defaultChecked:h=!1,disabled:u,noStyle:p,onCheckedChange:d,onClick:f,onKeyDown:b,size:w="medium",type:y="button",...k},j)=>{let{components:S}=m(),{noStyle:v}=l(),C=n(),[N,g]=r({defaultValue:h,onChange:d,value:s}),x=p??v,B=c(S?.switch?.root,{baseClassName:C.root(),className:i,noStyle:x,...k}),D=c(S?.switch?.track,{baseClassName:C.track(),noStyle:x}),R=c(S?.switch?.thumb,{baseClassName:C.thumb(),noStyle:x}),V=e(N),z=o(u),E=()=>{u||g(a(N))};return t("button",{...B,ref:j,"aria-checked":N,"data-disabled":z,"data-size":x?void 0:w,"data-slot":"switch","data-state":V,disabled:u,onClick:t=>{E(),f?.(t)},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),E()),b?.(t)},role:"switch",type:"button",children:t("span",{...D,"data-slot":"switch-track",children:t("span",{...R,"data-slot":"switch-thumb"})})})});h.displayName="SwitchRoot";export{h as Root,n as switchVariants};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t}from"react/jsx-runtime";import{getDataDisabled as e}from"@c15t/ui/primitives/data-state";import{getNextTabValue as a,getTabPanelState as r,getTabState as o}from"@c15t/ui/primitives/tabs";import l from"@c15t/ui/styles/components/tabs";import
|
|
2
|
+
import{jsx as t}from"react/jsx-runtime";import{getDataDisabled as e}from"@c15t/ui/primitives/data-state";import{getNextTabValue as a,getTabPanelState as r,getTabState as o}from"@c15t/ui/primitives/tabs";import l from"@c15t/ui/styles/components/tabs";import{createContext as n,forwardRef as s,useContext as i,useId as d,useMemo as c,useRef as u}from"react";import{useControllableState as b}from"../../libs/use-controllable-state.js";import{useTheme as m}from"../../../../hooks/use-theme.js";let g=()=>({content:t=>[l.content,t?.class].filter(Boolean).join(" "),list:t=>[l.list,t?.class].filter(Boolean).join(" "),root:t=>[l.root,t?.class].filter(Boolean).join(" "),trigger:t=>[l.trigger,t?.class].filter(Boolean).join(" ")}),f=n(null),p=function(){let t=i(f);if(!t)throw Error("Tabs components must be used within TabsRoot");return t},y=s(({children:a,className:r,defaultValue:o,disabled:l,loop:n=!0,noStyle:s,onValueChange:i,orientation:p="horizontal",value:y,...T},$)=>{let h=d().replace(/:/gu,""),{noStyle:v}=m(),S=g(),[N,j]=b({defaultValue:o??"",onChange:i,value:y}),k=u(new Map),B=v||s,C=c(()=>({baseId:`c15t-tabs-${h}`,disabled:l,loop:n,noStyle:B,onValueChange:j,orientation:p,registerTrigger:(t,e)=>{k.current.set(t,e)},value:N}),[N,l,B,n,p,h,j]);return t(f.Provider,{value:C,children:t("div",{ref:$,className:B?r:S.root({class:r}),"data-disabled":e(l),"data-orientation":p,"data-slot":"tabs-root",...T,children:a})})});y.displayName="TabsRoot";let T=s(({className:a,noStyle:r,orientation:o,...l},n)=>{let{noStyle:s}=m(),{disabled:i,noStyle:d,orientation:c}=p(),u=o??c,b=g();return t("div",{ref:n,"aria-orientation":u,className:d||s||r?a:b.list({class:a}),"data-disabled":e(i),"data-orientation":u,"data-slot":"tabs-list",role:"tablist",...l})});T.displayName="TabsList";let $=s(({children:r,className:l,noStyle:n,onClick:s,onKeyDown:i,value:d,...c},b)=>{let{noStyle:f}=m(),y=g(),{baseId:T,disabled:$,loop:h,noStyle:v,onValueChange:S,orientation:N,registerTrigger:j,value:k}=p(),B=k===d,C=u(null);return t("button",{ref:t=>{C.current=t,j(d,t),"function"==typeof b?b(t):b&&(b.current=t)},"aria-controls":`${T}-content-${d}`,"aria-selected":B,className:v||f||n?l:y.trigger({class:l}),"data-disabled":e($),"data-slot":"tabs-trigger","data-state":o(B),disabled:$,id:`${T}-trigger-${d}`,onClick:t=>{S(d),s?.(t)},onKeyDown:t=>{let e=a({currentValue:d,key:t.key,loop:h,orientation:N,triggerValues:Array.from(document.querySelectorAll(`[data-slot="tabs-trigger"][id^="${T}-trigger-"]`)).map(t=>t.id.replace(`${T}-trigger-`,""))});if(e!==d||"Home"===t.key||"End"===t.key){let a;t.preventDefault(),S(e),(a=document.getElementById(`${T}-trigger-${e}`)??null)instanceof HTMLButtonElement&&a.focus()}i?.(t)},role:"tab",tabIndex:B?0:-1,type:"button",...c,children:r})});$.displayName="TabsTrigger";let h=s(({children:e,className:a,forceMount:o=!1,noStyle:l,value:n,...s},i)=>{let{noStyle:d}=m(),c=g(),{baseId:u,noStyle:b,value:f}=p(),y=f===n;return o||y?t("div",{ref:i,"aria-labelledby":`${u}-trigger-${n}`,className:b||d||l?a:c.content({class:a}),"data-slot":"tabs-content","data-state":r(y),hidden:!y,id:`${u}-content-${n}`,role:"tabpanel",tabIndex:0,...s,children:e}):null});h.displayName="TabsContent";export{h as Content,T as List,y as Root,$ as Trigger,g as tabsVariants};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{EMPTY_DEVTOOLS_LAUNCHER_SNAPSHOT as e,claimDevToolsLauncher as o,getDevToolsLauncherSnapshot as l,publishDevToolsLauncher as t,subscribeDevToolsLauncher as r}from"@c15t/ui/utils/devtools-launcher";import{useCallback as n,useContext as u,useId as i,useLayoutEffect as s,useMemo as c,useSyncExternalStore as a}from"react";import{KernelContext as m}from"./context.js";let v=()=>e,h=o=>a(n(e=>o?r(o,e):()=>void 0,[o]),n(()=>o?l(o):e,[o]),v),p=()=>null!==h(u(m)).instance,f=()=>{let e=u(m),l=i(),t=h(e);s(()=>{if(e)return o(e,l)},[e,l]);let r=t.owner===l?t.instance:null,{isOpen:a}=t,v=n(e=>r?.dock(e),[r]),p=n(()=>r?.toggle(),[r]);return c(()=>r?{dock:v,isOpen:a,toggle:p}:null,[r,v,a,p])};export{t as publishDevToolsLauncher,f as useDevToolsLauncher,p as useDevToolsLauncherAvailable};
|
package/dist/devtools.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import{createDevTools as t}from"@c15t/dev-tools";import{createElement as r,forwardRef as o,useCallback as n,useContext as s,useEffect as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{createDevTools as t}from"@c15t/dev-tools";import{createElement as r,forwardRef as o,useCallback as n,useContext as s,useEffect as l,useLayoutEffect as i,useMemo as c,useRef as u}from"react";import{KernelContext as d,ProviderServicesContext as a}from"./context.js";import{publishDevToolsLauncher as f}from"./devtools-launcher.js";import{useIsHydrated as m}from"./hooks/use-is-hydrated.js";let v=e=>{if(!e)throw Error("c15t: DevTools must be rendered inside <ConsentProvider> from @c15t/react.");return e},g=(e,t)=>{let r=m(),o=u(e);i(()=>{o.current=e},[e]);let n=r&&!t&&e?JSON.stringify([...new Set(e())].sort()):void 0;return c(()=>{if(void 0===n)return;let e=JSON.parse(n);return()=>o.current?.()??e},[n])},C=(e,t)=>{let r=u({clearRecords:e,getPresentation:t});i(()=>{r.current={clearRecords:e,getPresentation:t}},[e,t]);let o=void 0!==e,n=void 0!==t;return c(()=>({clearRecords:o?()=>r.current.clearRecords?.():void 0,getPresentation:n?()=>r.current.getPresentation?.():void 0}),[o,n])},h=({disabled:e=!1,clearRecords:r,getPresentation:o,defaultOpen:n,defaultTab:i,getConsentCategories:c,maxEvents:u,position:m,shadow:h})=>{let p=s(a),y=C(r??p?.clearRecords,o??p?.getPresentation),D=s(d),P=e?null:v(D),T=g(c??p?.getConsentCategories,e);return l(()=>{if(!P)return;let e=t({...y,defaultOpen:n,defaultTab:i,getConsentCategories:T,kernel:P,maxEvents:u,position:m,shadow:h}),r=f(P,e);return()=>{r(),e.destroy()}},[n,i,T,y,P,u,m,h]),null},p=h,y=h,D={height:"100%",minHeight:0,width:"100%"},P=o(function({disabled:r=!1,clearRecords:o,getPresentation:l,defaultTab:c,getConsentCategories:f,maxEvents:m,style:h,theme:p,...y},P){let T=s(a),S=C(o??T?.clearRecords,l??T?.getPresentation),j=s(d),R=r?null:v(j),k=g(f??T?.getConsentCategories,r),w=u(null),x=n(e=>{w.current=e;let t=((e,t)=>{if("function"==typeof e)return e(t);e&&(e.current=t)})(P,e);if("function"==typeof t)return()=>{w.current=null,t()}},[P]);return i(()=>{let e=w.current;if(!R||!e)return;let r=t({...S,container:e,defaultTab:c,embedded:!0,getConsentCategories:k,kernel:R,maxEvents:m});return()=>r.destroy()},[c,k,S,R,m]),e("div",{...y,ref:x,style:{...D,...p?{"--c15t-dev-tools-color-scheme":p}:void 0,...h}})}),T=(e={})=>{let{id:t="c15t",name:o="c15t",defaultOpen:n=!1,...s}=e;return{defaultOpen:n,id:t,name:o,render:(e,t)=>r(P,{...s,theme:("string"==typeof t?t:t?.theme)??s.theme})}},S=T;export{y as C15TDevTools,h as ConsentDevTools,p as DevTools,T as c15tDevtools,S as c15tDevtoolsPlugin,P as C15tTanStackDevtoolsPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{
|
|
2
|
+
import{saveIABConsentSurface as e}from"@c15t/core/surface-actions";import{resolveIABBannerSummary as r}from"@c15t/iab/headless";import{useCallback as a,useMemo as t}from"react";import{useKernel as c}from"../kernel-selector.js";import{useIABConsentManager as s}from"./use-iab-manager.js";let o=function(){let{activeUI:o,model:n,iab:i,policyBanner:{scrollLock:l},policyDialog:{scrollLock:u},setActiveUI:b}=s(),p=!!i?.config.enabled,d=c(),m=t(()=>r(i),[i]),f=a(e=>{b("banner",e)},[b]),g=a(e=>{e?.tab&&i?.setPreferenceCenterTab(e.tab),b("dialog")},[i,b]),j=a(()=>{g({tab:"purposes"})},[g]),L=a(()=>{g({tab:"vendors"})},[g]),k=a(()=>{b("none")},[b]),_=a(async r=>{i&&("accept"===r?i.acceptAll():"reject"===r&&i.rejectAll(),await e(d,i.save))},[i,d]),h=a(()=>_("accept"),[_]),v=a(()=>_("reject"),[_]),A=a(()=>_(),[_]),C=a(e=>{switch(e){case"accept":return h();case"reject":return v();case"customize":return j();default:return}},[h,j,v]),I=a(e=>{switch(e){case"accept":return h();case"reject":return v();case"customize":return A();default:return}},[h,v,A]);return{acceptAll:h,activeUI:o,banner:{...m,isVisible:"banner"===o&&"iab"===n&&p,scrollLock:l},closeUI:k,dialog:{activeTab:i?.preferenceCenterTab??"purposes",isLoading:!!(i?.isLoadingGVL||!i?.gvl),isVisible:"dialog"===o&&"iab"===n&&p,scrollLock:u},iab:i,isIABEnabled:p,model:n,openBanner:f,openDialog:g,openPurposesDialog:j,openVendorsDialog:L,performBannerAction:C,performDialogAction:I,rejectAll:v,savePreferences:A}};export{o as useHeadlessIABConsentUI};
|
package/dist/index-parts/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{createConsentKernel,custom,hosted}from"@c15t/core";export{offline}from"../transports/offline.js";
|
|
1
|
+
export{createConsentKernel,custom,hosted,policyRulePresets}from"@c15t/core";export{offline}from"../transports/offline.js";
|
package/dist/provider.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
let e,t;import{jsx as o,jsxs as r}from"react/jsx-runtime";import{applyExperimentAssignment as n,applyExperimentTheme as i,hostExperiment as c,watchRevocationReload as s}from"@c15t/core";import{createPersistence as l}from"@c15t/core/modules/persistence";import{createWindowDebug as a}from"@c15t/core/modules/window-debug";import{createConsentProviderRuntime as m,hostedModes as u,lazyRuntimeModule as d,lazyStreamPrefetch as p,streamPrefetchWith as h}from"@c15t/core/runtime/provider";import{applyThemeSlots as f}from"@c15t/ui/utils";import{useCallback as g,useEffect as y,useLayoutEffect as k,useMemo as v,useReducer as S,useState as b,useSyncExternalStore as w}from"react";import{KernelContext as C,ProviderServicesContext as x}from"./context.js";import{ExternalIABProvider as L}from"./external-iab-context.js";import{useColorScheme as N}from"./hooks/use-color-scheme.js";import{useIsHydrated as O}from"./hooks/use-is-hydrated.js";import{createIframeBlockerOnDemand as j}from"./module-hooks/iframe-blocker.js";import{UNCOMMITTED_HOLD_MS as P}from"./module-hooks/network-hold.js";import{V3ThemeProvider as D}from"./theme-provider.js";let R=(e,t)=>{let o,r=!1;return(async()=>{try{let{connectConsentSource:n}=await import("@c15t/core/runtime/controls");r||(o=n(e,t))}catch{}})(),()=>{r=!0,o?.()}},_=async()=>(await import("@c15t/core/modules/script-loader")).createScriptLoader,E=function(e){let t=e.__resolveStreamedInit;return{connectConsentSource:R,createClearOnRevocation:d(async()=>(await import("@c15t/core/modules/clear-on-revocation")).createClearOnRevocation),createIframeBlocker:j,createNetworkBlocker:d(async()=>(await import("@c15t/core/modules/network-blocker")).createNetworkBlocker),createPersistence:l,createScriptLoader:d(_),createWindowDebug:a,preloadScriptLoader:e.__preloadScriptLoader?.(_),streamPrefetch:t?h(t):p,watchRevocationReload:s}},T=new WeakMap,J=new Set,q=(e,t)=>e.fetch===t.fetch&&e.initialData===t.initialData&&JSON.stringify(e)===JSON.stringify(t),B=function(o){if("function"!=typeof o)return o;let r=T.get(o);return r||(r=Object.assign(r=>e=(t=()=>o(Object.create(r,{iabEnabled:{value:void 0}})))(),{kind:o.kind}),T.set(o,r)),r},K=function(e){return{...e,mode:B(e.mode),pkg:e.__debugPkg??"@c15t/react"}},A=new Set,F=0,I=function(o,r){let n,i,c,{mode:s,networkBlocker:l}=o,a=m(K(o),E(o)),d=o,p=!1,h=!1,f=0,g=e;F+=1;let y={expire(){J.delete(c),A.delete(y),clearTimeout(n),p=!0,a.dispose()},holdKey:!1!==o.enabled&&l&&!1!==l.enabled?JSON.stringify(l.rules):null,sequence:F};if("u"<typeof window)h=!0;else{A.add(y),n=setTimeout(y.expire,P);let e=a.kernel.getSnapshot(),l=u.get(s),m=l&&{...l,fetch:l.fetch??globalThis.fetch};if(r&&m&&e.policyPending&&!(o.prefetch||o.experiment)){let o={overrides:e.overrides,user:e.user},r=JSON.stringify(o);for(let e of J)e.key===r&&q(e.options,m)&&(i=e);if(!i){let e=t(),n=e.init,s=n(o);s.catch(()=>void 0);let l=!1;e.init=e=>{let t=!l&&JSON.stringify(e)===r;return l=!0,t?s:n(e)},i=c={key:r,options:m,transport:e},J.add(c)}}}let k=function(){if(p)return!1;if(h)return!0;if(h=!0,J.delete(i)&&Object.assign(g,i?.transport),A.delete(y),clearTimeout(n),null!==y.holdKey)for(let e of A)e.sequence<y.sequence&&e.holdKey===y.holdKey&&e.expire();return!0};return{apply(e){e!==d&&(d=e,a.update(K(e)).catch(()=>void 0))},mount(){if(!k())return null;let e=f+=1;return a.start(),()=>{queueMicrotask(()=>{f===e&&a.dispose()})}},runtime:a}},M=function(){let e=null;return{get:(t,o)=>e??=I(t,o),reset(){e=null}}},V=e=>e+1,W=()=>()=>void 0,z=function(e){let[t]=b(M),[,o]=S(V,0),r=O(),n=g(()=>{t.reset(),o()},[t]);return e?{entry:t.get(e,r),rebuild:n}:void 0},G="u"<typeof document?y:k,H=({entry:e,options:t,rebuild:o})=>(G(()=>e.apply(t),[e,t]),y(()=>{let t=e.mount();return t||void o()},[e,o]),null),Q=e=>{let{children:t}=e,s=e.options??{},[l]=b(()=>e.runtime),a=z(l?void 0:s),m=a?.entry.runtime,u=l?e.runtime??l:void 0,d=m??u,p=w(m?m.subscribe:W,()=>d.kernel,()=>d.kernel),[h]=b(()=>{var e;return l?l.experiment??c(s.experiment,(e=s.prefetch,"function"==typeof e?.then)?void 0:s.prefetch):void 0}),g=m?m.experiment:h,k=u?s.consentCategories:void 0;y(()=>{u&&void 0!==k&&u.setConsentCategories(k)},[u,k]);let{presentation:S}=s,O=v(()=>({clearRecords:()=>d.clearRecords(),getConsentCategories:()=>d.consentCategories,getPresentation:()=>n(S,g,p.getSnapshot().experiment),setLanguage:e=>d.setLanguage(e)}),[g,p,S,d]),j=!!u&&void 0!==s.callbacks;y(()=>{"production"!==process.env.NODE_ENV&&j&&console.warn("c15t ConsentProvider: `options.callbacks` is ignored when you pass `runtime`. Pass them to createConsentRuntime({ callbacks }) instead.")},[j]);let P=w(e=>p.subscribe(e),()=>p.getSnapshot().experiment,()=>p.getServerSnapshot().experiment),R=v(()=>i(s.theme,g,P),[s.theme,g,P]);y(()=>{"production"===process.env.NODE_ENV||!R||!["colors","dark","motion","radius","shadows","spacing","typography"].some(e=>e in R)||document.getElementById("c15t-theme")||console.warn("c15t: `theme` tokens are no longer turned into CSS in the browser. Render <ConsentTheme theme={theme} /> on the server, or put the CSS from generateThemeCSS() in your stylesheet. See https://c15t.com/docs/frameworks/react/customize")},[R]);let _=v(()=>({colorScheme:s.colorScheme,disableAnimation:s.disableAnimation,noStyle:s.noStyle,scrollLock:s.scrollLock,theme:R,trapFocus:s.trapFocus}),[R,s.noStyle,s.disableAnimation,s.scrollLock,s.trapFocus,s.colorScheme]),E=v(()=>({components:f(R?.slots,s.components,"className"),experiment:g,legalLinks:s.legalLinks,preloadDialog:s.preloadDialog,presentation:s.presentation,theme:s.theme}),[R?.slots,s.components,g,s.legalLinks,s.preloadDialog,s.presentation,s.theme]);return N(s.colorScheme),o(C.Provider,{value:p,children:o(x.Provider,{value:O,children:r(D,{themeConfig:_,uiConfig:E,children:[a?o(H,{entry:a.entry,options:s,rebuild:a.rebuild}):null,u?o(L,{runtime:u,children:t}):t]})})})};export{Q as ConsentProvider};
|