@expo/styleguide-cookie-consent 0.1.1 → 0.1.2

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.
@@ -0,0 +1,5 @@
1
+ export { CookieConsentProvider } from './src/CookieConsentProvider';
2
+ export { PrivacyChoicesButton } from './src/PrivacyChoicesButton';
3
+ export { isConsentEnabled, shouldSkipBannerForAuth, getAnalyticsConsentStatus, getMarketingConsentStatus, isAnalyticsConsented, isMarketingConsented, enqueueAnalyticsEvent, enqueueMarketingEvent, setAnalyticsReplayFn, setMarketingReplayFn, setAnalyticsConsent, setMarketingConsent, resetConsentState, MAX_QUEUE_SIZE, } from './src/consent';
4
+ export type { ConsentStatus, QueuedEvent, CookieConsentProviderProps } from './src/types';
5
+ export type { GoogleTagManagerOptions } from '@c15t/scripts/google-tag-manager';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react/compiler-runtime"),t=require("@c15t/react"),n=require("@c15t/scripts/google-tag-manager"),o=require("@c15t/scripts/google-tag"),r=require("@expo/styleguide"),a=require("react"),i=require("react/jsx-runtime");let s="pending",c="pending";const l=[],d=[];let u=null,g=null;const x="undefined"!=typeof process&&"true"===process.env.NEXT_PUBLIC_SKIP_CONSENT_BANNER_FOR_AUTHENTICATED,p="undefined"==typeof process||"false"!==process.env.NEXT_PUBLIC_COOKIE_CONSENT_ENABLED;function m(){return p}function h(e,t){e.length>=200||e.push(t)}function f(e){const t=s;s=e,"granted"===e&&"pending"===t?(u&&l.length>0&&u([...l]),l.length=0):"denied"===e&&(l.length=0)}function b(e){const t=c;c=e,"granted"===e&&"pending"===t?(g&&d.length>0&&g([...d]),d.length=0):"denied"===e&&(d.length=0)}function y(n){const o=e.c(13),{children:r}=n,{has:s,hasConsented:c}=t.useConsentManager();let l;o[0]!==s?(l=s("measurement"),o[0]=s,o[1]=l):l=o[1];const d=l;let u;o[2]!==s?(u=s("marketing"),o[2]=s,o[3]=u):u=o[3];const g=u;let x;o[4]!==c?(x=c(),o[4]=c,o[5]=x):x=o[5];const p=x;let m,h,y;return o[6]!==g||o[7]!==d||o[8]!==p?(m=()=>{p&&(b(g?"granted":"denied"),f(d?"granted":"denied"))},h=[p,d,g],o[6]=g,o[7]=d,o[8]=p,o[9]=m,o[10]=h):(m=o[9],h=o[10]),a.useEffect(m,h),o[11]!==r?(y=i.jsx(i.Fragment,{children:r}),o[11]=r,o[12]=y):y=o[12],y}const v={"banner.card":{className:"!bg-screen !border-palette-gray4 !shadow-lg !max-w-[500px] [&>:not([hidden])~:not([hidden])]:!border-palette-gray4"},"banner.footer":"!bg-element !flex-row","banner.header.title":{noStyle:!0,className:"heading-base font-semibold text-default"},"banner.header.description":{noStyle:!0,className:"text-xs text-secondary"},"dialog.root":{style:{"--dialog-max-width":"500px","--dialog-height":"100%","overflow-y":"scroll"}},"dialog.card":{className:"!bg-screen !border-palette-gray4 [&>:not([hidden])~:not([hidden])]:!border-palette-gray4"},"dialog.title":{noStyle:!0,className:"heading-base font-semibold text-default"},"dialog.description":{noStyle:!0,className:"text-xs text-secondary"},"banner.footer.sub-group":{noStyle:!0,className:"gap-2 flex"},"widget.accordion.item":{style:{"--accordion-background-color":"var(--expo-theme-background-element)","--accordion-border-color":"transparent","--widget-accordion-background-color":"var(--expo-theme-background-element)","--widget-accordion-border-color":"var(--expo-theme-border-secondary)","--accordion-background-hover":"var(--expo-theme-background-subtle)","--widget-accordion-background-hover":"var(--expo-theme-background-subtle)"}},"widget.accordion.trigger":{style:{"--accordion-text-color":"var(--expo-theme-text-default)","--widget-accordion-text-color":"var(--expo-theme-text-default)"}},"widget.accordion.content":{style:{"--accordion-content-color":"var(--expo-theme-text-secondary)","--widget-accordion-content-color":"var(--expo-theme-text-secondary)"}},"widget.switch.track":{style:{"--switch-background-color":"var(--expo-theme-border-default)","--switch-background-color-hover":"var(--expo-theme-text-quaternary)","--switch-background-color-checked":"var(--expo-theme-text-link)"}},"widget.branding":{noStyle:!0,className:"hidden"},"dialog.footer":{noStyle:!0,className:"hidden"},"banner.footer.accept-button":{noStyle:!0,className:"order-1 inline-flex h-9 cursor-pointer items-center rounded-full border border-button-primary bg-button-primary px-4 text-xs font-medium text-button-primary transition active:scale-98 hocus:bg-button-primary-hover"},"banner.footer.reject-button":{noStyle:!0,className:"order-2 inline-flex h-9 cursor-pointer items-center rounded-full border border-button-secondary bg-button-secondary px-4 text-xs font-medium text-button-secondary transition active:scale-98 hocus:bg-button-secondary-hover"},"banner.footer.customize-button":{noStyle:!0,className:"order-3 inline-flex h-9 cursor-pointer items-center rounded-full border border-default bg-default px-4 text-xs font-medium text-default transition active:scale-98 hocus:bg-element"},"widget.footer":"!flex-row","widget.footer.sub-group":{noStyle:!0,className:"gap-2 flex"},"widget.footer.accept-button":{noStyle:!0,className:"order-1 inline-flex h-9 cursor-pointer items-center rounded-full border border-button-primary bg-button-primary px-4 text-xs font-medium text-button-primary transition active:scale-98 hocus:bg-button-primary-hover"},"widget.footer.reject-button":{noStyle:!0,className:"order-2 inline-flex h-9 cursor-pointer items-center rounded-full border border-button-secondary bg-button-secondary px-4 text-xs font-medium text-button-secondary transition active:scale-98 hocus:bg-button-secondary-hover"},"widget.footer.save-button":{noStyle:!0,className:"order-3 inline-flex h-9 cursor-pointer items-center rounded-full border border-default bg-default px-4 text-xs font-medium text-default transition active:scale-98 hocus:bg-element"}};function C(){const t=e.c(1);let n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsxs("svg",{width:"30",height:"16",viewBox:"0 0 743 376",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[i.jsx("rect",{width:"742.6",height:"376",rx:"188",fill:"white"}),i.jsx("rect",{x:"14.2146",y:"14.2146",width:"714.171",height:"347.571",rx:"173.785",stroke:"#405D96",strokeWidth:"28.4292"}),i.jsx("path",{d:"M421.723 0H554.6C658.43 0 742.6 84.1705 742.6 188C742.6 291.83 658.43 376 554.6 376H320.877L421.723 0Z",fill:"#405D96"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M315.783 112.736C321.683 117.519 322.591 126.181 317.809 132.084L216.494 257.149C207.93 267.721 192.099 268.548 182.48 258.926L123.211 199.638C117.84 194.266 117.84 185.556 123.211 180.184C128.581 174.812 137.288 174.812 142.659 180.184L198.33 235.873L296.44 114.763C301.222 108.86 309.882 107.953 315.783 112.736Z",fill:"#405D96"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M456.576 106.585C462.095 101.365 470.799 101.608 476.017 107.129L608.556 247.338C613.774 252.858 613.531 261.565 608.013 266.785C602.494 272.005 593.79 271.761 588.572 266.241L456.033 126.031C450.814 120.511 451.058 111.804 456.576 106.585Z",fill:"white"}),i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M610.222 108.733C615.592 114.106 615.592 122.815 610.222 128.188L473.815 264.636C468.445 270.008 459.738 270.008 454.367 264.636C448.997 259.264 448.997 250.554 454.367 245.182L590.774 108.733C596.144 103.361 604.851 103.361 610.222 108.733Z",fill:"white"})]}),t[0]=n):n=t[0],n}exports.CookieConsentProvider=function(a){const s=e.c(18),{children:c,gtmId:l,ga4Id:d}=a;if(!m()){let e;return s[0]!==c?(e=i.jsx(i.Fragment,{children:c}),s[0]=c,s[1]=e):e=s[1],e}let u,g,x,p,h,f,b,C,w,k;return s[2]===Symbol.for("react.memo_cache_sentinel")?(u=["necessary","measurement","marketing"],s[2]=u):u=s[2],s[3]!==d||s[4]!==l?(g=function(e,t){const r=[];return e&&r.push({...n.googleTagManager({id:e,script:{category:"marketing"}}),alwaysLoad:!1}),t&&r.push(o.gtag({id:t,category:"measurement"})),r}(l,d),s[3]=d,s[4]=l,s[5]=g):g=s[5],s[6]===Symbol.for("react.memo_cache_sentinel")?(x={storageKey:"expo-c15t",crossSubdomain:!0,defaultExpiryDays:365},p={colorScheme:void 0,theme:v},s[6]=x,s[7]=p):(x=s[6],p=s[7]),s[8]!==g?(h={mode:"offline",ignoreGeoLocation:!0,consentCategories:u,experimental_globalPrivacyControl:!0,scripts:g,storageConfig:x,react:p},s[8]=g,s[9]=h):h=s[9],s[10]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(r.LinkBase,{href:"https://expo.dev/privacy",className:"underline text-link",children:"Privacy Policy"}),s[10]=f):f=s[10],s[11]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(t.CookieBanner,{title:"We use cookies",description:i.jsxs(i.Fragment,{children:["We use cookies to improve your experience, analyze traffic, and serve relevant ads. You can manage your preferences at any time. See our"," ",f," ","and"," ",i.jsx(r.LinkBase,{href:"https://expo.dev/privacy/cookies",className:"underline text-link",children:"Cookie Policy"}),"."]}),rejectButtonText:"Reject All",customizeButtonText:"Customize",acceptButtonText:"Accept All"}),C=i.jsx(t.ConsentManagerDialog,{}),s[11]=b,s[12]=C):(b=s[11],C=s[12]),s[13]!==c?(w=i.jsx(y,{children:c}),s[13]=c,s[14]=w):w=s[14],s[15]!==h||s[16]!==w?(k=i.jsxs(t.ConsentManagerProvider,{options:h,children:[b,C,w]}),s[15]=h,s[16]=w,s[17]=k):k=s[17],k},exports.MAX_QUEUE_SIZE=200,exports.PrivacyChoicesButton=function(){let e;try{const n=t.useConsentManager();e=n.setIsPrivacyDialogOpen}catch{return null}return i.jsxs("button",{type:"button",onClick:()=>{e?.(!0)},className:"inline-flex items-center gap-1.5 text-xs text-secondary transition-colors hocus:text-default","aria-label":"Your Privacy Choices",children:[i.jsx(C,{}),i.jsx("span",{className:"font-semibold",children:"Your Privacy Choices"})]})},exports.enqueueAnalyticsEvent=function(e){h(l,e)},exports.enqueueMarketingEvent=function(e){h(d,e)},exports.getAnalyticsConsentStatus=function(){return s},exports.getMarketingConsentStatus=function(){return c},exports.isAnalyticsConsented=function(){return!p||"granted"===s},exports.isConsentEnabled=m,exports.isMarketingConsented=function(){return!p||"granted"===c},exports.resetConsentState=function(){s="pending",c="pending",l.length=0,d.length=0,u=null,g=null},exports.setAnalyticsConsent=f,exports.setAnalyticsReplayFn=function(e){u=e},exports.setMarketingConsent=b,exports.setMarketingReplayFn=function(e){g=e},exports.shouldSkipBannerForAuth=function(){return x};
@@ -0,0 +1,2 @@
1
+ import type { CookieConsentProviderProps } from './types';
2
+ export declare function CookieConsentProvider({ children, gtmId, ga4Id }: CookieConsentProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * CCPA/CPRA "Your Privacy Choices" link with the standard opt-out toggle icon.
3
+ * Opens the c15t preference center dialog when clicked.
4
+ */
5
+ export declare function PrivacyChoicesButton(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Consent-aware analytics event queueing module.
3
+ *
4
+ * Implements a 3-state consent model (pending | granted | denied) with
5
+ * event queueing for the pending state. When consent transitions to granted,
6
+ * queued events are replayed. When denied, they are dropped.
7
+ */
8
+ import type { ConsentStatus, QueuedEvent } from './types';
9
+ declare const MAX_QUEUE_SIZE = 200;
10
+ export declare function isConsentEnabled(): boolean;
11
+ export declare function shouldSkipBannerForAuth(): boolean;
12
+ export declare function getAnalyticsConsentStatus(): ConsentStatus;
13
+ export declare function getMarketingConsentStatus(): ConsentStatus;
14
+ export declare function isAnalyticsConsented(): boolean;
15
+ export declare function isMarketingConsented(): boolean;
16
+ export declare function enqueueAnalyticsEvent(event: QueuedEvent): void;
17
+ export declare function enqueueMarketingEvent(event: QueuedEvent): void;
18
+ export declare function setAnalyticsReplayFn(fn: (events: QueuedEvent[]) => void): void;
19
+ export declare function setMarketingReplayFn(fn: (events: QueuedEvent[]) => void): void;
20
+ export declare function setAnalyticsConsent(status: ConsentStatus): void;
21
+ export declare function setMarketingConsent(status: ConsentStatus): void;
22
+ /**
23
+ * Reset all consent state. Useful for testing.
24
+ */
25
+ export declare function resetConsentState(): void;
26
+ export { MAX_QUEUE_SIZE };
@@ -0,0 +1,13 @@
1
+ export type ConsentStatus = 'pending' | 'granted' | 'denied';
2
+ export type QueuedEvent = {
3
+ type: 'track' | 'identify' | 'group' | 'gtag' | 'adwords';
4
+ args: unknown[];
5
+ timestamp: number;
6
+ };
7
+ export type CookieConsentProviderProps = {
8
+ children: React.ReactNode;
9
+ /** Google Tag Manager container ID (e.g. 'GTM-XXXXXXX'). Loaded when marketing consent is granted. */
10
+ gtmId?: string;
11
+ /** Google Analytics 4 measurement ID (e.g. 'G-XXXXXXXXXX'). Loaded when measurement consent is granted. */
12
+ ga4Id?: string;
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/styleguide-cookie-consent",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Cookie consent provider for Expo websites with c15t integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,5 +29,6 @@
29
29
  },
30
30
  "eslintConfig": {
31
31
  "extends": "universe/web"
32
- }
32
+ },
33
+ "gitHead": "898f2856fdccc450df8196890424696fc271629b"
33
34
  }