@usequeek/theme-kit 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -540,16 +540,57 @@ export default function Footer() {
540
540
  - Style only: the link emits `core-powered-by` with a
541
541
  `core-powered-by__brand` hook on the `Queek` wordmark; an optional
542
542
  `className` passthrough lets a footer position it (e.g.
543
- `<PoweredByQueek className="my-footer__powered" />`). No kit CSS ships for
544
- it — style the classes in your theme.
543
+ `<PoweredByQueek className="my-footer__powered" />`). It goes on the link
544
+ itself and styles it; to position the credit in the footer row, style
545
+ `.core-powered-by-group`, the one element `PoweredByQueek` renders (an
546
+ inline-flex `span`), so a footer row keeps its child count. Style the
547
+ `core-powered-by` classes in your theme.
548
+ - The same group holds the shopper's cookie preferences button
549
+ (`core-consent-link`), shown only when the store uses analytics or an ad
550
+ pixel, the shopper has chosen, and the browser does not send Global Privacy
551
+ Control. It is how a shopper withdraws consent, so a footer cannot opt out of
552
+ it. The kit ships a neutral style for the group and the button (no
553
+ positioning, logical properties); restyle `core-consent-link` in your
554
+ `theme.css` if the footer needs it. The label is the string
555
+ `consent.preferences`.
545
556
  - The href (`https://usequeek.com/business`), `target="_blank"` and
546
557
  `rel="noopener noreferrer"` are the contract — never re-implement the
547
558
  markup by hand. The href is tagged for attribution by `poweredByQueekUrl`
548
559
  (`utm_source=powered_by&utm_medium=storefront&utm_campaign=<store slug>`,
549
560
  campaign omitted when the store has no slug); the component reads the slug
550
561
  from the storefront context, so themes pass nothing.
551
- - `hidden` (default false) takes the component's visibility from a prop.
552
- There is no merchant-facing toggle for it — always render it visible.
562
+ - `hidden` (default false) takes the attribution link's visibility from a prop;
563
+ it never hides the cookie preferences button. There is no merchant-facing
564
+ toggle for it — always render it visible.
565
+
566
+ ## Cookie consent
567
+
568
+ A store that uses Google Analytics or an ad pixel asks its shoppers for
569
+ consent, and the shopper can change their mind from the footer. The state and
570
+ the footer control live in the kit so every theme gets them:
571
+
572
+ - `ConsentPreferencesLink` (`@usequeek/theme-kit/apps/consent-preferences-link`)
573
+ is the footer button. `PoweredByQueek` renders it, so a theme places nothing.
574
+ It renders only when the store offers a consent category, the shopper has
575
+ answered every question the store asks, and the browser does not send Global
576
+ Privacy Control. A click forgets this store's choice and brings the banner
577
+ back. It renders nothing on the server, without a provider, and for a store
578
+ with no consent category. The label is `consent.preferences`.
579
+ - `useAnalyticsConsent(vendorId)` (`.../apps/use-analytics-consent`) returns
580
+ `{ decision, marketing, gpc, decide, reset }`. `decision` (analytics) and
581
+ `marketing` are `null` until the shopper has chosen, `gpc` is true when the
582
+ browser sends Global Privacy Control (both decisions then read `false`).
583
+ The record is kept in `localStorage` per store, so stores that share an origin
584
+ never share a choice. `readStoredMarketingConsent(vendorId)` reads the stored
585
+ marketing decision without React.
586
+ - `consentOffers(config)`, `buildConsentOffers(gaId, pixels)` and
587
+ `consentPending(offers, decision, marketing)` (`.../apps/consent-offers`,
588
+ pure and server-safe) say which categories the store uses and whether a
589
+ question is still open. `resolveGaId` and `resolveAdPixelIds` validate the
590
+ ids from `config.apps.analytics` (the patterns are exported too); an id that
591
+ fails its pattern counts as not set.
592
+
593
+ Style the button through `core-consent-link`; the kit ships a neutral style.
553
594
 
554
595
  ## Locales
555
596
 
package/apps/apps.css CHANGED
@@ -537,8 +537,10 @@
537
537
  flex-shrink: 0;
538
538
  }
539
539
 
540
- .core-consent-banner__decline,
541
- .core-consent-banner__accept {
540
+ /* Two classes deep on purpose: a theme's own `button { background: none; color: inherit }` reset (one class and an element) would otherwise beat
541
+ these and leave the Accept label the page's text colour on the primary fill, or on no fill at all. */
542
+ .core-consent-banner .core-consent-banner__decline,
543
+ .core-consent-banner .core-consent-banner__accept {
542
544
  padding: 0.55rem 1.1rem;
543
545
  font: inherit;
544
546
  font-size: 0.8125rem;
@@ -549,38 +551,41 @@
549
551
  transition: opacity 0.15s ease;
550
552
  }
551
553
 
552
- .core-consent-banner__decline {
554
+ .core-consent-banner .core-consent-banner__decline {
553
555
  background: transparent;
554
556
  border-color: var(--brand-border, rgba(0, 0, 0, 0.18));
555
557
  color: inherit;
556
558
  }
557
559
 
558
- .core-consent-banner__accept {
560
+ .core-consent-banner .core-consent-banner__accept {
559
561
  background: var(--brand-primary, #00a884);
560
562
  color: var(--brand-on-primary, #fff);
561
563
  }
562
564
 
563
- .core-consent-banner__decline:hover,
564
- .core-consent-banner__accept:hover { opacity: 0.85; }
565
+ .core-consent-banner .core-consent-banner__decline:hover,
566
+ .core-consent-banner .core-consent-banner__accept:hover { opacity: 0.85; }
565
567
 
566
- .core-consent-settings-link {
567
- position: fixed;
568
- z-index: 150;
569
- left: 0.75rem;
570
- bottom: 0.5rem;
571
- padding: 0.25rem 0.5rem;
572
- font: inherit;
573
- font-size: 0.6875rem;
574
- color: var(--brand-text-muted, #888);
575
- background: transparent;
568
+ /* The footer attribution slot: the cookie preferences link, then "Powered by Queek". No positioning, so a footer row keeps its layout. */
569
+ .core-powered-by-group {
570
+ display: inline-flex;
571
+ align-items: baseline;
572
+ flex-wrap: wrap;
573
+ gap: 0.75em;
574
+ }
575
+
576
+ /* Inherits size and colour from the footer row around it, not from the credit link: a theme whose credit has its own rule for them restyles this in its own theme.css. */
577
+ .core-consent-link {
578
+ background: none;
576
579
  border: 0;
577
- cursor: pointer;
578
- opacity: 0.6;
580
+ padding: 0;
581
+ margin: 0;
582
+ font: inherit;
583
+ color: inherit;
584
+ text-align: start;
579
585
  text-decoration: underline;
586
+ cursor: pointer;
580
587
  }
581
588
 
582
- .core-consent-settings-link:hover { opacity: 1; }
583
-
584
589
  @media (max-width: 600px) {
585
590
  .core-consent-banner {
586
591
  flex-direction: column;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Which cookie-consent categories a store uses, resolved from its analytics app
3
+ * config. Pure and server-safe: the banner, the footer preferences link and the
4
+ * analytics loader all read the same answer, so they cannot drift.
5
+ *
6
+ * Every id is validated against a strict pattern before it can reach a script
7
+ * URL or an inline snippet: an id that fails its pattern is treated as not set.
8
+ */
9
+
10
+ /** Mirrors the backend rule on analytics.meta_pixel_id (digits only). */
11
+ export const META_PIXEL_ID_PATTERN = /^\d{8,20}$/;
12
+ /** Mirrors the backend rule on analytics.tiktok_pixel_id (uppercase alphanumerics). */
13
+ export const TIKTOK_PIXEL_ID_PATTERN = /^[A-Z0-9]{5,30}$/;
14
+ /** Mirrors the backend rule on analytics.pinterest_tag_id (digits only). */
15
+ export const PINTEREST_TAG_ID_PATTERN = /^\d{8,20}$/;
16
+ /** Mirrors the backend rule on analytics.ga_id: G-/GT- measurement ids or a UA- property id, nothing else. */
17
+ export const GA_ID_PATTERN = /^(?:(?:G|GT)-[A-Z0-9]{4,26}|UA-\d{4,10}-\d{1,4})$/;
18
+
19
+ /** The GA id when it has the documented shape, else null (GA absent): it is spliced into an inline script and a script URL, so nothing else may pass. */
20
+ export function resolveGaId(gaId: unknown): string | null {
21
+ return typeof gaId === 'string' && GA_ID_PATTERN.test(gaId) ? gaId : null;
22
+ }
23
+
24
+ /** The validated ad-pixel ids; `null` for a provider the store does not use. */
25
+ export interface AdPixelIds {
26
+ meta: string | null;
27
+ tiktok: string | null;
28
+ pinterest: string | null;
29
+ }
30
+
31
+ /** The ids `config.apps.analytics` carries; each is present only while its app is installed. */
32
+ export interface AnalyticsAppIds {
33
+ ga_id?: unknown;
34
+ meta_pixel_id?: unknown;
35
+ tiktok_pixel_id?: unknown;
36
+ pinterest_tag_id?: unknown;
37
+ }
38
+
39
+ /** An id that fails its pattern is treated as not set: it never reaches a script URL. */
40
+ export function resolveAdPixelIds(analytics: AnalyticsAppIds | undefined | null): AdPixelIds {
41
+ const meta = analytics?.meta_pixel_id;
42
+ const tiktok = analytics?.tiktok_pixel_id;
43
+ const pinterest = analytics?.pinterest_tag_id;
44
+ return {
45
+ meta: typeof meta === 'string' && META_PIXEL_ID_PATTERN.test(meta) ? meta : null,
46
+ tiktok: typeof tiktok === 'string' && TIKTOK_PIXEL_ID_PATTERN.test(tiktok) ? tiktok : null,
47
+ pinterest: typeof pinterest === 'string' && PINTEREST_TAG_ID_PATTERN.test(pinterest) ? pinterest : null,
48
+ };
49
+ }
50
+
51
+ /** Which consent categories this store actually uses; the banner asks only about those. */
52
+ export interface ConsentOffers {
53
+ analytics: boolean;
54
+ /** Ad pixels (Meta/TikTok/Pinterest). `marketingLabel` names them, e.g. "Meta, TikTok and Pinterest". */
55
+ marketing: boolean;
56
+ marketingLabel?: string;
57
+ }
58
+
59
+ /** "Meta", "Meta and TikTok", "Meta, TikTok and Pinterest". */
60
+ export function joinNames(names: Array<string | null>): string {
61
+ const present = names.filter((name): name is string => Boolean(name));
62
+ return present.length > 1 ? `${present.slice(0, -1).join(', ')} and ${present[present.length - 1]}` : present.join('');
63
+ }
64
+
65
+ /** The offers for already-resolved ids; `null` when the store has neither Google Analytics nor an ad pixel. */
66
+ export function buildConsentOffers(gaId: string | null, pixels: AdPixelIds): ConsentOffers | null {
67
+ const hasPixels = pixels.meta !== null || pixels.tiktok !== null || pixels.pinterest !== null;
68
+ if (gaId === null && !hasPixels) return null;
69
+ return {
70
+ analytics: gaId !== null,
71
+ marketing: hasPixels,
72
+ marketingLabel: joinNames([pixels.meta && 'Meta', pixels.tiktok && 'TikTok', pixels.pinterest && 'Pinterest']),
73
+ };
74
+ }
75
+
76
+ /** The offers for a store's `config`, read from `config.apps.analytics`; `null` when the store uses no consent category. */
77
+ export function consentOffers(
78
+ config: { apps?: { analytics?: AnalyticsAppIds | undefined } | undefined } | null | undefined,
79
+ ): ConsentOffers | null {
80
+ const analytics = config?.apps?.analytics;
81
+ return buildConsentOffers(resolveGaId(analytics?.ga_id), resolveAdPixelIds(analytics));
82
+ }
83
+
84
+ /**
85
+ * Whether the shopper still has a question to answer: a category the store
86
+ * offers whose decision is `null`. The banner shows exactly while this is true,
87
+ * and the footer preferences link shows only once it is false.
88
+ */
89
+ export function consentPending(offers: ConsentOffers, decision: boolean | null, marketing: boolean | null): boolean {
90
+ return (offers.analytics && decision === null) || (offers.marketing && marketing === null);
91
+ }
@@ -0,0 +1,40 @@
1
+ 'use client';
2
+
3
+ import { useContext, type JSX } from 'react';
4
+ import { StorefrontContext, useThemeStrings } from '../provider';
5
+ import { consentOffers, consentPending } from './consent-offers';
6
+ import { useAnalyticsConsent } from './use-analytics-consent';
7
+
8
+ function ConsentPreferencesButton({ onReset }: { onReset: () => void }): JSX.Element {
9
+ const t = useThemeStrings();
10
+
11
+ return (
12
+ <button type="button" className="core-consent-link" onClick={onReset}>
13
+ {t('consent.preferences')}
14
+ </button>
15
+ );
16
+ }
17
+
18
+ /**
19
+ * The shopper's way back into their cookie choice, rendered by
20
+ * `PoweredByQueek` in every theme footer (withdrawing consent must be as easy
21
+ * as giving it). A plain inline button, never a floating one.
22
+ *
23
+ * Shown only when the store uses analytics or an ad pixel, the shopper has
24
+ * answered every question it asks, and the browser is not sending Global
25
+ * Privacy Control (that is already a decline: there is nothing to reopen).
26
+ * Clicking it forgets this store's choice only, which brings the banner back.
27
+ * Renders nothing on the server and while hydrating (the decision is read from
28
+ * the browser), outside a `StorefrontProvider`, and for a store with no consent
29
+ * category. Reads the context directly so it never throws without a provider.
30
+ */
31
+ export function ConsentPreferencesLink(): JSX.Element | null {
32
+ const context = useContext(StorefrontContext);
33
+ const vendorId = context?.vendor?.id;
34
+ const { decision, marketing, gpc, reset } = useAnalyticsConsent(vendorId);
35
+ const offers = consentOffers(context?.config);
36
+
37
+ if (!vendorId || !offers || gpc || consentPending(offers, decision, marketing)) return null;
38
+
39
+ return <ConsentPreferencesButton onReset={reset} />;
40
+ }
@@ -0,0 +1,162 @@
1
+ 'use client';
2
+
3
+ import { useCallback, useSyncExternalStore } from 'react';
4
+
5
+ /**
6
+ * Consent is keyed by vendor id inside one shared localStorage record — the
7
+ * storefront is path-routed, so multiple vendors can share a single browser
8
+ * origin. A flat per-origin flag would leak one vendor's consent choice onto
9
+ * another's storefront. Mirrors FollowCard's DISMISS_KEY vendor-id-list
10
+ * pattern (see follow-card.tsx) for the same reason.
11
+ */
12
+ const STORAGE_KEY = 'queek_consent';
13
+
14
+ /**
15
+ * Bump when the consent question itself changes shape — invalidates old records.
16
+ * Adding the marketing category did NOT bump it: a record without a `marketing`
17
+ * field reads as marketing "not asked yet" (never granted), so analytics-only
18
+ * stores keep their shoppers' answers and only stores with an ad pixel re-ask.
19
+ */
20
+ const CONSENT_VERSION = 1;
21
+
22
+ interface ConsentRecord {
23
+ analytics?: boolean;
24
+ marketing?: boolean;
25
+ version: number;
26
+ decidedAt: string;
27
+ }
28
+
29
+ /** Categories a decision can set; a category left out keeps its earlier answer. */
30
+ export interface ConsentChoice {
31
+ analytics?: boolean;
32
+ marketing?: boolean;
33
+ }
34
+
35
+ type ConsentStore = Record<string, ConsentRecord>;
36
+
37
+ function readStore(): ConsentStore {
38
+ try {
39
+ return JSON.parse(localStorage.getItem(STORAGE_KEY) || '{}');
40
+ } catch {
41
+ return {};
42
+ }
43
+ }
44
+
45
+ function writeStore(store: ConsentStore): void {
46
+ try {
47
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(store));
48
+ } catch {
49
+ /* noop */
50
+ }
51
+ }
52
+
53
+ /**
54
+ * CCPA/CPRA requires honoring this browser-level opt-out signal as a valid
55
+ * "do not sell/share" request — treated as an immediate decline, no banner
56
+ * and no preferences link, since there's nothing left to ask or withdraw.
57
+ */
58
+ function hasGlobalPrivacyControl(): boolean {
59
+ return (
60
+ typeof navigator !== 'undefined'
61
+ && (navigator as Navigator & { globalPrivacyControl?: boolean }).globalPrivacyControl === true
62
+ );
63
+ }
64
+
65
+ /** Fired on every same-tab write, so each hook instance re-reads the one stored record. */
66
+ const CHANGE_EVENT = 'queek:consent-change';
67
+
68
+ /** Same-tab writes announce themselves; `storage` covers another tab deciding. */
69
+ function subscribe(onChange: () => void): () => void {
70
+ window.addEventListener(CHANGE_EVENT, onChange);
71
+ window.addEventListener('storage', onChange);
72
+ return () => {
73
+ window.removeEventListener(CHANGE_EVENT, onChange);
74
+ window.removeEventListener('storage', onChange);
75
+ };
76
+ }
77
+
78
+ function readDecision(vendorId: string, category: keyof ConsentChoice): boolean | null {
79
+ if (hasGlobalPrivacyControl()) return false;
80
+ const record = readStore()[vendorId];
81
+ if (!record || record.version !== CONSENT_VERSION) return null;
82
+ return typeof record[category] === 'boolean' ? record[category] : null;
83
+ }
84
+
85
+ /**
86
+ * The STORED marketing decision, read synchronously (no React): true only for
87
+ * an explicit accept (GPC counts as a decline). The ad-pixel event subscribers
88
+ * use it so the first event on a page, which can fire before any hook has
89
+ * re-rendered, is judged by what the shopper actually chose.
90
+ */
91
+ export function readStoredMarketingConsent(vendorId: string | undefined): boolean {
92
+ if (!vendorId || typeof window === 'undefined') return false;
93
+ return readDecision(vendorId, 'marketing') === true;
94
+ }
95
+
96
+ /**
97
+ * Per-vendor consent in two independent categories. `decision` (analytics) and
98
+ * `marketing` are each `null` until the visitor has chosen (or GPC decided for
99
+ * them) — the banner and Consent Mode's default state both key off that.
100
+ * Granting analytics never grants marketing. Marketing (ad pixels) is denied by
101
+ * default and stays denied until an explicit accept. `reset` forgets this
102
+ * vendor's record only, which reopens the banner.
103
+ */
104
+ export function useAnalyticsConsent(vendorId: string | undefined): {
105
+ decision: boolean | null;
106
+ marketing: boolean | null;
107
+ /**
108
+ * The browser sends Global Privacy Control. Both decisions then read `false`
109
+ * (a decline), indistinguishable from a shopper's own "no", so a caller that
110
+ * must tell the two apart (the footer preferences link) reads this. `false`
111
+ * on the server and during hydration.
112
+ */
113
+ gpc: boolean;
114
+ decide: (choice: ConsentChoice) => void;
115
+ reset: () => void;
116
+ } {
117
+ // localStorage IS the store; every consumer (banner, footer preferences
118
+ // link, analytics loader) reads the same record and re-renders on the same
119
+ // change event — a decision in the banner reaches the analytics loader
120
+ // without a reload, which per-instance state never did. `null` on the
121
+ // server and during hydration.
122
+ const decision = useSyncExternalStore(
123
+ subscribe,
124
+ () => (vendorId ? readDecision(vendorId, 'analytics') : null),
125
+ () => null,
126
+ );
127
+ const marketing = useSyncExternalStore(
128
+ subscribe,
129
+ () => (vendorId ? readDecision(vendorId, 'marketing') : null),
130
+ () => null,
131
+ );
132
+
133
+ const gpc = useSyncExternalStore(subscribe, hasGlobalPrivacyControl, () => false);
134
+
135
+ const decide = useCallback(
136
+ (choice: ConsentChoice) => {
137
+ if (!vendorId) return;
138
+ const store = readStore();
139
+ const previous = store[vendorId]?.version === CONSENT_VERSION ? store[vendorId] : undefined;
140
+ store[vendorId] = {
141
+ ...(previous?.analytics !== undefined ? { analytics: previous.analytics } : {}),
142
+ ...(previous?.marketing !== undefined ? { marketing: previous.marketing } : {}),
143
+ ...choice,
144
+ version: CONSENT_VERSION,
145
+ decidedAt: new Date().toISOString(),
146
+ };
147
+ writeStore(store);
148
+ window.dispatchEvent(new Event(CHANGE_EVENT));
149
+ },
150
+ [vendorId],
151
+ );
152
+
153
+ const reset = useCallback(() => {
154
+ if (!vendorId) return;
155
+ const store = readStore();
156
+ delete store[vendorId];
157
+ writeStore(store);
158
+ window.dispatchEvent(new Event(CHANGE_EVENT));
159
+ }, [vendorId]);
160
+
161
+ return { decision, marketing, gpc, decide, reset };
162
+ }
package/client.ts CHANGED
@@ -28,6 +28,8 @@ export * from './components/checkout/default-checkout-shell';
28
28
  export * from './components/checkout/checkout-contact';
29
29
  export * from './components/checkout/policy-links';
30
30
  export * from './apps/follow-card';
31
+ export * from './apps/use-analytics-consent';
32
+ export * from './apps/consent-preferences-link';
31
33
  export * from './apps/storefront-events';
32
34
  export * from './apps/subscribe-form';
33
35
  export * from './api/collections';
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { useContext, type JSX } from 'react';
4
4
  import { StorefrontContext } from '../provider';
5
+ import { ConsentPreferencesLink } from '../apps/consent-preferences-link';
5
6
  import { poweredByQueekUrl } from '../utils/powered-by';
6
7
 
7
8
  /** Props for {@link PoweredByQueek}. */
@@ -9,8 +10,9 @@ export interface PoweredByQueekProps {
9
10
  /** Extra class so a footer can position the link — styling stays theme-owned. */
10
11
  className?: string;
11
12
  /**
12
- * Lets a caller hide the link from a prop. Defaults to false; themes always
13
- * render it visible — there is no merchant-facing toggle for it.
13
+ * Lets a caller hide the attribution link from a prop. Defaults to false;
14
+ * themes always render it visible — there is no merchant-facing toggle for
15
+ * it. It never hides the cookie preferences link, which is not attribution.
14
16
  */
15
17
  hidden?: boolean;
16
18
  }
@@ -26,21 +28,35 @@ export interface PoweredByQueekProps {
26
28
  * `utm_medium=storefront`, `utm_campaign=<store slug>` via `poweredByQueekUrl`
27
29
  * (read from the storefront context, so themes pass nothing; no provider means
28
30
  * no campaign, never an error). Markup carries `core-powered-by` classes so each theme
29
- * styles it in its own `theme.css`; no kit CSS ships for it.
31
+ * styles it in its own `theme.css`; `className` goes on the link itself.
32
+ *
33
+ * It also carries the shopper's cookie preferences link
34
+ * ({@link ConsentPreferencesLink}), so the one footer slot every theme already
35
+ * has is also where a shopper reopens their cookie choice. That is why the
36
+ * output is one `core-powered-by-group` element holding both: a footer row
37
+ * keeps its child count, and the preferences link sits directly before the
38
+ * attribution. The link renders only when the store uses analytics or an ad
39
+ * pixel and the shopper has chosen; otherwise the group holds just the
40
+ * attribution. A footer needs no extra markup, and a theme may restyle
41
+ * `core-consent-link` in its own `theme.css` (the kit gives it a neutral
42
+ * look).
30
43
  */
31
44
  export function PoweredByQueek({ className, hidden = false }: PoweredByQueekProps): JSX.Element | null {
32
45
  const vendor = useContext(StorefrontContext)?.vendor;
33
46
 
34
- if (hidden) return null;
47
+ if (hidden) return <ConsentPreferencesLink />;
35
48
 
36
49
  return (
37
- <a
38
- href={poweredByQueekUrl(vendor?.slug)}
39
- target="_blank"
40
- rel="noopener noreferrer"
41
- className={className ? `core-powered-by ${className}` : 'core-powered-by'}
42
- >
43
- Powered by <strong className="core-powered-by__brand">Queek</strong>
44
- </a>
50
+ <span className="core-powered-by-group">
51
+ <ConsentPreferencesLink />
52
+ <a
53
+ href={poweredByQueekUrl(vendor?.slug)}
54
+ target="_blank"
55
+ rel="noopener noreferrer"
56
+ className={className ? `core-powered-by ${className}` : 'core-powered-by'}
57
+ >
58
+ Powered by <strong className="core-powered-by__brand">Queek</strong>
59
+ </a>
60
+ </span>
45
61
  );
46
62
  }
@@ -97,6 +97,8 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
97
97
  const [step, setStep] = useState<AuthStep>('email-otp');
98
98
  const [otp, setOtp] = useState('');
99
99
  const [verifiedToken, setVerifiedToken] = useState(''); // email OTP flow: server-issued token
100
+ // Password sign-up: the address is proven by the same email code first; the typed name/password wait here until it is.
101
+ const [passwordSignup, setPasswordSignup] = useState(false);
100
102
  const [firstName, setFirstName] = useState('');
101
103
  const [lastName, setLastName] = useState('');
102
104
  const [email, setEmail] = useState('');
@@ -146,6 +148,23 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
146
148
  }
147
149
  };
148
150
 
151
+ // The proven address is the only way to name an email at register-password: the server refuses a password sign-up without it.
152
+ const registerWithPassword = async (client: ReturnType<typeof getQueekClient>, proof: string): Promise<void> => {
153
+ const res = await client.post<PasswordAuthData>('/client/auth/email/register-password', {
154
+ first_name: firstName.trim(),
155
+ last_name: lastName.trim() || undefined,
156
+ email: email.trim(),
157
+ password,
158
+ phone: '',
159
+ platform: 'client_web',
160
+ verified_token: proof,
161
+ });
162
+ setAuthTokens(res.data.access_token, res.data.refresh_token);
163
+ applyUser(res.data.user);
164
+ setPasswordSignup(false);
165
+ closeModal();
166
+ };
167
+
149
168
  const submitEmailVerifyOtp = async (): Promise<void> => {
150
169
  if (blockPreview()) return;
151
170
  if (otp.length < EMAIL_OTP_LENGTH) return;
@@ -158,12 +177,17 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
158
177
  otpCode: otp,
159
178
  });
160
179
  if (data.needs_registration) {
180
+ if (passwordSignup) {
181
+ await registerWithPassword(client, data.verified_token);
182
+ return;
183
+ }
161
184
  setVerifiedToken(data.verified_token);
162
185
  setStep('signup');
163
186
  return;
164
187
  }
165
188
  // tokens already persisted by SDK
166
189
  applyUser(data.user);
190
+ setPasswordSignup(false);
167
191
  closeModal();
168
192
  } catch (err) {
169
193
  setError(mapEmailError(err, t));
@@ -231,17 +255,10 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
231
255
  setLoading(true);
232
256
  try {
233
257
  const client = getQueekClient(vendor.slug ?? undefined);
234
- const res = await client.post<PasswordAuthData>('/client/auth/email/register-password', {
235
- first_name: firstName.trim(),
236
- last_name: lastName.trim() || undefined,
237
- email: email.trim(),
238
- password,
239
- phone: '',
240
- platform: 'client_web',
241
- });
242
- setAuthTokens(res.data.access_token, res.data.refresh_token);
243
- applyUser(res.data.user);
244
- closeModal();
258
+ await client.auth.emailRequestOtp({ email: email.trim() });
259
+ setOtp('');
260
+ setPasswordSignup(true);
261
+ setStep('email-otp-verify');
245
262
  } catch (err) {
246
263
  setError(mapEmailError(err, t));
247
264
  } finally {
@@ -291,6 +308,7 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
291
308
  setStep('email-otp');
292
309
  setOtp('');
293
310
  setVerifiedToken('');
311
+ setPasswordSignup(false);
294
312
  setFirstName('');
295
313
  setLastName('');
296
314
  setEmail('');
@@ -303,16 +321,19 @@ export function AuthFlowProvider({ children }: { children: ReactNode }): JSX.Ele
303
321
  setStep('email-otp');
304
322
  setOtp('');
305
323
  setVerifiedToken('');
324
+ setPasswordSignup(false);
306
325
  setError(null);
307
326
  };
308
327
 
309
328
  const goToEmailLogin = (): void => {
310
329
  setStep('email-login');
330
+ setPasswordSignup(false);
311
331
  setError(null);
312
332
  };
313
333
 
314
334
  const goToEmailRegister = (): void => {
315
335
  setStep('email-register');
336
+ setPasswordSignup(false);
316
337
  setError(null);
317
338
  };
318
339
 
package/index.ts CHANGED
@@ -50,6 +50,9 @@ export * from './utils/locale';
50
50
  export * from './utils/locale-switch';
51
51
  export * from './utils/market';
52
52
 
53
+ // Which cookie-consent categories a store uses (pure, server-safe).
54
+ export * from './apps/consent-offers';
55
+
53
56
  // Theme strings — the pure/server-safe i18n core (no next/*, no React).
54
57
  export * from './strings/theme-strings';
55
58
  // Pseudo-locale QA — dev/test-only dictionary transform + English-leak scan
@@ -191,6 +191,9 @@
191
191
  "label": "Currency",
192
192
  "named": "Currency: {name}"
193
193
  },
194
+ "consent": {
195
+ "preferences": "Cookie preferences"
196
+ },
194
197
  "follow": {
195
198
  "aria": "Follow this store",
196
199
  "dismiss": "Don't show again",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The runtime a Queek storefront theme is built on: hooks, stores, page renderer, navigation, shared blocks and locale strings.",