@c1m-public/dash-site-kit 0.15.0 → 0.17.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
@@ -267,7 +267,7 @@ before relying on it.
267
267
 
268
268
  ## Peer dependencies
269
269
 
270
- `@c1m-public/channel-client` (>=0.35.0), `next` 16, `react` 19.
270
+ `@c1m-public/channel-client` (>=0.36.0), `next` 16, `react` 19.
271
271
 
272
272
  The moving quote form, validation, server data layer and customer lead portal
273
273
  are shared across Dash sites. A site supplies its own channel client and
@@ -1,4 +1,9 @@
1
1
  /**
2
+ * Brand assets (`/api/v1/public/assets/{id}/image`) are deliberately NOT
3
+ * optimised: that route answers with a 302 to storage, and the optimizer only
4
+ * checks the allow-list against the first URL, not the redirect target. They
5
+ * render directly instead; logos and marks are small.
6
+ *
2
7
  * Only known SaaSDash origins use the Next image proxy. Absolute media URLs are a
3
8
  * valid Channel API shape; unknown HTTPS hosts still render through next/image
4
9
  * with optimization bypassed instead of becoming a runtime hostname error.
@@ -10,6 +10,11 @@ function origin(value) {
10
10
  }
11
11
  }
12
12
  /**
13
+ * Brand assets (`/api/v1/public/assets/{id}/image`) are deliberately NOT
14
+ * optimised: that route answers with a 302 to storage, and the optimizer only
15
+ * checks the allow-list against the first URL, not the redirect target. They
16
+ * render directly instead; logos and marks are small.
17
+ *
13
18
  * Only known SaaSDash origins use the Next image proxy. Absolute media URLs are a
14
19
  * valid Channel API shape; unknown HTTPS hosts still render through next/image
15
20
  * with optimization bypassed instead of becoming a runtime hostname error.
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export { formatMoney } from "./format.js";
37
37
  export { SIGN_IN_HINT_COOKIE, hasSignInHint } from "@c1m-public/platform-auth";
38
38
  export * from "./url-policy.js";
39
39
  export * from "./image-policy.js";
40
- export { canonicalUrl, createSiteConfig, safeLocale, } from "./site-config.js";
40
+ export { canonicalUrl, createSiteConfig, headerLogo, safeLocale, } from "./site-config.js";
41
41
  export type { SiteConfig, SiteConfigOptions, SiteDefaults, SiteMeta, SiteMetaBootstrap, } from "./site-config.js";
42
42
  export { ChannelSiteSentryConfigurationError, resolveChannelSiteSentryOptions, } from "./sentry.js";
43
43
  export type { ChannelSiteSentryConfiguration, ChannelSiteSentryOptions, } from "./sentry.js";
package/dist/index.js CHANGED
@@ -8,5 +8,5 @@ export { formatMoney } from "./format.js";
8
8
  export { SIGN_IN_HINT_COOKIE, hasSignInHint } from "@c1m-public/platform-auth";
9
9
  export * from "./url-policy.js";
10
10
  export * from "./image-policy.js";
11
- export { canonicalUrl, createSiteConfig, safeLocale, } from "./site-config.js";
11
+ export { canonicalUrl, createSiteConfig, headerLogo, safeLocale, } from "./site-config.js";
12
12
  export { ChannelSiteSentryConfigurationError, resolveChannelSiteSentryOptions, } from "./sentry.js";
@@ -13,6 +13,8 @@ export interface DashBootstrap {
13
13
  branding: {
14
14
  primaryColor?: string;
15
15
  logoUrl?: string;
16
+ /** Wide logo for dark surfaces, when the dash uploaded one. */
17
+ logoDarkUrl?: string;
16
18
  logoSquareUrl?: string;
17
19
  faviconUrl?: string;
18
20
  coverUrl?: string;
@@ -3,6 +3,8 @@ export interface LeadInput {
3
3
  email: string;
4
4
  phone?: string;
5
5
  message?: string;
6
+ /** Bot trap, forwarded unchanged as `_gotcha`. */
7
+ _gotcha?: string;
6
8
  }
7
9
  /**
8
10
  * `invalid` is the server rejecting the submission (bad email, missing field
@@ -1,5 +1,8 @@
1
1
  import type { DashMovingQuoteInput, DashMovingQuoteReceipt, DashMovingAddressList, DashMovingAddress, DashMovingDistance } from "@c1m-public/channel-client";
2
- export type MovingQuoteInput = DashMovingQuoteInput;
2
+ /** `_gotcha` is the bot trap, forwarded unchanged. */
3
+ export type MovingQuoteInput = DashMovingQuoteInput & {
4
+ _gotcha?: string;
5
+ };
3
6
  export type MovingQuoteReceipt = DashMovingQuoteReceipt;
4
7
  export type MovingAddressList = DashMovingAddressList;
5
8
  export type MovingAddressResult = DashMovingAddress;
@@ -8,6 +8,8 @@ export interface DashWaitlistSubmission {
8
8
  email: string;
9
9
  name?: string;
10
10
  marketingOptIn?: boolean;
11
+ /** Bot trap, forwarded unchanged as `_gotcha`. */
12
+ _gotcha?: string;
11
13
  /** Which placement captured the signup. */
12
14
  source?: "waitlist_page" | "waitlist_block";
13
15
  /** First-touch context; the server bounds and may drop any field. */
@@ -32,7 +32,7 @@ export interface DashDataLayer {
32
32
  getDirectoryProfile(idOrSlug: string): Promise<DirectoryProfileResult>;
33
33
  loadDashPlans(): Promise<PlanCatalog>;
34
34
  submitLead(input: LeadInput, attemptId: string): Promise<LeadOutcome>;
35
- requestPortalLink(email: string): Promise<RequestLinkOutcome>;
35
+ requestPortalLink(email: string, gotcha?: string): Promise<RequestLinkOutcome>;
36
36
  viewPortal(token: string): Promise<ViewOutcome>;
37
37
  submitMovingQuote(input: MovingQuoteInput, attemptId: string): Promise<MovingQuoteOutcome>;
38
38
  lookupMovingAddresses(query: string): Promise<MovingAddressList>;
@@ -50,7 +50,7 @@ export function createDashDataLayer(options) {
50
50
  },
51
51
  loadDashPlans: cache(() => plansProvider.loadCatalog()),
52
52
  submitLead: (input, attemptId) => leadsProvider.create(input, attemptId),
53
- requestPortalLink: (email) => leadPortalProvider.requestLink(email),
53
+ requestPortalLink: (email, gotcha) => leadPortalProvider.requestLink(email, gotcha),
54
54
  viewPortal: (token) => leadPortalProvider.view(token),
55
55
  submitMovingQuote,
56
56
  lookupMovingAddresses,
@@ -1,4 +1,5 @@
1
1
  import { normalizeSignals } from "@c1m-public/channel-client/site";
2
+ import { absoluteHttpsUrl } from "../url-policy.js";
2
3
  function text(value) {
3
4
  const trimmed = value?.trim();
4
5
  return trimmed || undefined;
@@ -7,18 +8,23 @@ function text(value) {
7
8
  /** One flat shell object from ONE wire read: `dash.init`. */
8
9
  export function normalizeDashBootstrap(init) {
9
10
  const signals = normalizeSignals(init);
10
- const name = text(init.tenant.display_name) ?? init.tenant.id;
11
+ // The backend's resolved brand name wins; older backends omit it.
12
+ const name = text(init.branding?.name) ?? text(init.tenant.display_name) ?? init.tenant.id;
11
13
  const siteUrl = text(signals.site?.url)?.replace(/\/+$/, "") ?? null;
12
14
  return {
13
15
  id: init.tenant.id,
14
16
  name,
15
17
  description: text(init.seo?.description) ?? text(init.public_profile.short_description),
18
+ // No public_profile fallbacks: branding.* is the one resolver's output
19
+ // (dash-brand.md), public_profile.logo_url is the same value, and
20
+ // header_media_url is the about hero, not the cover slot.
16
21
  branding: {
17
22
  primaryColor: text(init.branding?.primary_color),
18
- logoUrl: text(init.branding?.logo_url) ?? text(init.public_profile.logo_url),
19
- logoSquareUrl: text(init.branding?.logo_square_url),
20
- faviconUrl: text(init.branding?.favicon_url),
21
- coverUrl: text(init.branding?.cover_url) ?? text(init.public_profile.header_media_url),
23
+ logoUrl: absoluteHttpsUrl(init.branding?.logo_url),
24
+ logoDarkUrl: absoluteHttpsUrl(init.branding?.logo_dark_url),
25
+ logoSquareUrl: absoluteHttpsUrl(init.branding?.logo_square_url),
26
+ faviconUrl: absoluteHttpsUrl(init.branding?.favicon_url),
27
+ coverUrl: absoluteHttpsUrl(init.branding?.cover_url),
22
28
  },
23
29
  locale: {
24
30
  region: text(init.locale?.region),
@@ -31,10 +31,10 @@ function normalizeView(view) {
31
31
  }
32
32
  export function createC1MLeadPortalProvider(resolveClient = getVisitorDashChannelClient) {
33
33
  return {
34
- async requestLink(email) {
34
+ async requestLink(email, gotcha) {
35
35
  try {
36
36
  const client = await resolveClient();
37
- await client.dash.leadPortal.requestLink({ email });
37
+ await client.dash.leadPortal.requestLink({ email, ...(gotcha !== undefined ? { _gotcha: gotcha } : {}) });
38
38
  return { state: "requested" };
39
39
  }
40
40
  catch (error) {
@@ -20,6 +20,7 @@ export function createC1MLeadsProvider(leadSource, resolveClient = getVisitorDas
20
20
  ...(input.name ? { name: input.name } : {}),
21
21
  ...(input.phone ? { phone: input.phone } : {}),
22
22
  ...(input.message ? { message: input.message } : {}),
23
+ ...(input._gotcha !== undefined ? { _gotcha: input._gotcha } : {}),
23
24
  source,
24
25
  }, { idempotencyKey: attemptId });
25
26
  return { state: "created", id: lead.id };
@@ -15,6 +15,7 @@ export function createC1MWaitlistProvider(resolveClient = getDashChannelClient,
15
15
  email: input.email,
16
16
  name: input.name,
17
17
  marketing_opt_in: input.marketingOptIn === true,
18
+ ...(input._gotcha !== undefined ? { _gotcha: input._gotcha } : {}),
18
19
  source: input.source ?? "waitlist_page",
19
20
  attribution: input.attribution ?? (await attribution()),
20
21
  }, { idempotencyKey: attemptId });
@@ -1,6 +1,7 @@
1
1
  import "server-only";
2
2
  import type { RequestLinkOutcome, ViewOutcome } from "../models/lead-portal.js";
3
3
  export interface LeadPortalProvider {
4
- requestLink(email: string): Promise<RequestLinkOutcome>;
4
+ /** `gotcha` is the form's bot-trap value, forwarded unchanged as `_gotcha`. */
5
+ requestLink(email: string, gotcha?: string): Promise<RequestLinkOutcome>;
5
6
  view(token: string): Promise<ViewOutcome>;
6
7
  }
@@ -18,7 +18,14 @@ export interface SiteDefaults {
18
18
  adminUrl?: string;
19
19
  }
20
20
  export interface SiteMeta {
21
+ /** The `<title>` / OpenGraph site name: the SEO title, else the site name. */
21
22
  name: string;
23
+ /**
24
+ * The Dash's brand name (`bootstrap.name`, the backend's resolved
25
+ * `branding.name`), else the site name. Use it for the header wordmark so
26
+ * the header and the page title can share one source.
27
+ */
28
+ brandName: string;
22
29
  description: string;
23
30
  baseUrl: string | null;
24
31
  locale: string;
@@ -28,6 +35,7 @@ export interface SiteMeta {
28
35
  }
29
36
  /** The bootstrap fields site metadata reads. Structural, so the full DashBootstrap satisfies it. */
30
37
  export interface SiteMetaBootstrap {
38
+ name?: string | null;
31
39
  seo: {
32
40
  title?: string | null;
33
41
  description?: string | null;
@@ -57,7 +65,26 @@ export interface SiteConfig {
57
65
  resolveSiteMeta(): Promise<SiteMeta>;
58
66
  /** A URL on the Dash's admin host, or null when the site has none configured. */
59
67
  adminUrl(path?: string): string | null;
68
+ /** Sign-in on the admin host, or null when the site has none configured. */
69
+ loginUrl(): string | null;
70
+ /** Sign-up on the admin host, carrying a plan choice when it is a safe id. */
71
+ providerSignupUrl(plan?: string | null): string | null;
72
+ /**
73
+ * The first step of the admin workspace wizard (`/workspace/new`) with a
74
+ * plan already chosen; payment happens later on SaaSDash. Null when there is
75
+ * no admin host or the id is not a safe plan id.
76
+ */
77
+ planStartUrl(planId: string, interval?: "monthly" | "yearly"): string | null;
60
78
  }
79
+ /**
80
+ * The header logo chain: wide logo, then the square mark (dash-brand.md).
81
+ * Brand media is absolute https only; anything else is undefined so the site
82
+ * renders the brand name as text.
83
+ */
84
+ export declare function headerLogo(branding: {
85
+ logoUrl?: string | null;
86
+ logoSquareUrl?: string | null;
87
+ }): string | undefined;
61
88
  export declare function canonicalUrl(baseUrl: string | null, pathname: string): string | undefined;
62
89
  export declare function safeLocale(value: string | null | undefined): string;
63
90
  export interface SiteConfigOptions {
@@ -1,4 +1,14 @@
1
1
  import { formatMoney } from "./format.js";
2
+ import { absoluteHttpsUrl } from "./url-policy.js";
3
+ const SAFE_PLAN_ID = /^[A-Za-z0-9_-]{1,64}$/;
4
+ /**
5
+ * The header logo chain: wide logo, then the square mark (dash-brand.md).
6
+ * Brand media is absolute https only; anything else is undefined so the site
7
+ * renders the brand name as text.
8
+ */
9
+ export function headerLogo(branding) {
10
+ return absoluteHttpsUrl(branding.logoUrl) ?? absoluteHttpsUrl(branding.logoSquareUrl);
11
+ }
2
12
  export function canonicalUrl(baseUrl, pathname) {
3
13
  if (!baseUrl)
4
14
  return undefined;
@@ -48,6 +58,7 @@ export function createSiteConfig(defaults, options = {}) {
48
58
  async function resolveSiteMeta() {
49
59
  const fallback = {
50
60
  name: siteName,
61
+ brandName: siteName,
51
62
  description: siteDescription,
52
63
  baseUrl: resolveSiteBaseUrl(),
53
64
  locale: "en",
@@ -56,17 +67,19 @@ export function createSiteConfig(defaults, options = {}) {
56
67
  return fallback;
57
68
  try {
58
69
  const bootstrap = await options.loadBootstrap();
70
+ // Absolute https only: a relative or legacy value would 404 on the
71
+ // site's own origin, so it falls through to the site's own fallback.
72
+ const brand = bootstrap.branding;
73
+ const iconUrl = absoluteHttpsUrl(brand.faviconUrl) ?? absoluteHttpsUrl(brand.logoSquareUrl);
74
+ const imageUrl = absoluteHttpsUrl(brand.coverUrl) ?? absoluteHttpsUrl(brand.logoUrl);
59
75
  return {
60
76
  name: bootstrap.seo.title || siteName,
77
+ brandName: bootstrap.name?.trim() || siteName,
61
78
  description: bootstrap.seo.description || siteDescription,
62
79
  baseUrl: bootstrap.site.url ?? resolveSiteBaseUrl(),
63
80
  locale: safeLocale(bootstrap.locale.locale),
64
- ...(bootstrap.branding.faviconUrl ?? bootstrap.branding.logoSquareUrl
65
- ? { iconUrl: (bootstrap.branding.faviconUrl ?? bootstrap.branding.logoSquareUrl) }
66
- : {}),
67
- ...(bootstrap.branding.coverUrl ?? bootstrap.branding.logoUrl
68
- ? { imageUrl: (bootstrap.branding.coverUrl ?? bootstrap.branding.logoUrl) }
69
- : {}),
81
+ ...(iconUrl ? { iconUrl } : {}),
82
+ ...(imageUrl ? { imageUrl } : {}),
70
83
  ...(bootstrap.branding.primaryColor ? { primaryColor: bootstrap.branding.primaryColor } : {}),
71
84
  };
72
85
  }
@@ -86,6 +99,30 @@ export function createSiteConfig(defaults, options = {}) {
86
99
  return null;
87
100
  }
88
101
  }
102
+ function loginUrl() {
103
+ return adminUrl("/login");
104
+ }
105
+ function providerSignupUrl(plan) {
106
+ const url = adminUrl("/signup");
107
+ if (!url)
108
+ return null;
109
+ const choice = plan?.trim();
110
+ if (!choice || !SAFE_PLAN_ID.test(choice))
111
+ return url;
112
+ const withPlan = new URL(url);
113
+ withPlan.searchParams.set("plan", choice);
114
+ return withPlan.toString();
115
+ }
116
+ function planStartUrl(planId, interval = "monthly") {
117
+ const url = adminUrl("/workspace/new");
118
+ const choice = planId?.trim();
119
+ if (!url || !choice || !SAFE_PLAN_ID.test(choice))
120
+ return null;
121
+ const start = new URL(url);
122
+ start.searchParams.set("plan_id", choice);
123
+ start.searchParams.set("interval", interval);
124
+ return start.toString();
125
+ }
89
126
  return {
90
127
  siteName,
91
128
  siteDescription,
@@ -96,5 +133,8 @@ export function createSiteConfig(defaults, options = {}) {
96
133
  formatMoney: (cents, currency) => formatMoney(cents, currency, defaultCurrency),
97
134
  resolveSiteMeta,
98
135
  adminUrl,
136
+ loginUrl,
137
+ providerSignupUrl,
138
+ planStartUrl,
99
139
  };
100
140
  }
@@ -0,0 +1,10 @@
1
+ /** Name of the bot-trap field the API's intake guard looks for. */
2
+ export declare const HONEYPOT_FIELD_NAME = "_gotcha";
3
+ /**
4
+ * Bot trap for public capture forms: a visually hidden text input (not
5
+ * `type="hidden"`, which bots skip) that people never fill in. Forward its
6
+ * value as `_gotcha`; the API silently drops submissions where it is non-blank.
7
+ */
8
+ export declare function DashHoneypotField(): import("react").JSX.Element;
9
+ /** The trap's value from a submitted form; "" when untouched. */
10
+ export declare function readHoneypot(form: FormData): string;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** Name of the bot-trap field the API's intake guard looks for. */
3
+ export const HONEYPOT_FIELD_NAME = "_gotcha";
4
+ /**
5
+ * Bot trap for public capture forms: a visually hidden text input (not
6
+ * `type="hidden"`, which bots skip) that people never fill in. Forward its
7
+ * value as `_gotcha`; the API silently drops submissions where it is non-blank.
8
+ */
9
+ export function DashHoneypotField() {
10
+ return (_jsx("div", { "aria-hidden": "true", className: "sr-only", style: { position: "absolute", left: "-10000px" }, children: _jsx("input", { "aria-hidden": "true", autoComplete: "off", defaultValue: "", name: HONEYPOT_FIELD_NAME, tabIndex: -1, type: "text" }) }));
11
+ }
12
+ /** The trap's value from a submitted form; "" when untouched. */
13
+ export function readHoneypot(form) {
14
+ const value = form.get(HONEYPOT_FIELD_NAME);
15
+ return typeof value === "string" ? value : "";
16
+ }
@@ -1,7 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useActionState } from "react";
4
+ import { DashHoneypotField } from "./honeypot-field.js";
4
5
  export function DashPortalLinkForm({ action }) {
5
6
  const [state, formAction, pending] = useActionState(action, { status: "idle" });
6
- return _jsxs("form", { action: formAction, className: "rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx("label", { className: "block text-sm font-semibold text-ink", htmlFor: "portal-email", children: "Your email address" }), _jsx("input", { className: "mt-3 min-h-12 w-full rounded-xl border border-border px-4", id: "portal-email", name: "email", type: "email", autoComplete: "email", maxLength: 254, required: true }), _jsx("button", { className: "mt-5 min-h-12 rounded-full bg-accent px-6 font-semibold text-accent-foreground disabled:opacity-50", disabled: pending, children: pending ? "Sending…" : "Email my link" }), state.status === "requested" && _jsx("p", { className: "mt-4 text-sm text-ink", role: "status", children: "If we found requests for that address, a secure link is on its way." }), state.status === "invalid" && _jsx("p", { className: "mt-4 text-sm text-amber-950", role: "alert", children: "Enter a valid email address." }), state.status === "error" && _jsx("p", { className: "mt-4 text-sm text-amber-950", role: "alert", children: "We could not send a link right now. Try again shortly." })] });
7
+ return _jsxs("form", { action: formAction, className: "rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx(DashHoneypotField, {}), _jsx("label", { className: "block text-sm font-semibold text-ink", htmlFor: "portal-email", children: "Your email address" }), _jsx("input", { className: "mt-3 min-h-12 w-full rounded-xl border border-border px-4", id: "portal-email", name: "email", type: "email", autoComplete: "email", maxLength: 254, required: true }), _jsx("button", { className: "mt-5 min-h-12 rounded-full bg-accent px-6 font-semibold text-accent-foreground disabled:opacity-50", disabled: pending, children: pending ? "Sending…" : "Email my link" }), state.status === "requested" && _jsx("p", { className: "mt-4 text-sm text-ink", role: "status", children: "If we found requests for that address, a secure link is on its way." }), state.status === "invalid" && _jsx("p", { className: "mt-4 text-sm text-amber-950", role: "alert", children: "Enter a valid email address." }), state.status === "error" && _jsx("p", { className: "mt-4 text-sm text-amber-950", role: "alert", children: "We could not send a link right now. Try again shortly." })] });
7
8
  }
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useActionState, useEffect, useState } from "react";
4
+ import { DashHoneypotField } from "./honeypot-field.js";
4
5
  export function DashMovingQuoteForm({ action, initialPickup = "", }) {
5
6
  const [state, formAction, pending] = useActionState(action, { status: "idle" });
6
7
  const [attemptId, setAttemptId] = useState("");
@@ -73,7 +74,7 @@ export function DashMovingQuoteForm({ action, initialPickup = "", }) {
73
74
  }
74
75
  }
75
76
  }
76
- return _jsxs("form", { action: formAction, className: "space-y-8 rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx("input", { type: "hidden", name: "attempt_id", value: attemptId }), _jsx("input", { type: "hidden", name: "distance_miles", value: distance?.distanceMiles ?? "" }), _jsx("input", { type: "hidden", name: "duration_minutes", value: distance?.durationMinutes ?? "" }), ["from", "to"].map((side) => _jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-lg font-semibold text-ink", children: side === "from" ? "Collection" : "Delivery" }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_postcode`, children: "Postcode" }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { className: "min-h-12 min-w-0 flex-1 rounded-xl border border-border px-4", defaultValue: side === "from" ? initialPickup : "", id: `${side}_postcode`, name: `${side}_postcode`, autoComplete: "postal-code", required: true, maxLength: 16 }), _jsx("button", { className: "rounded-xl border border-border px-4 font-medium text-ink", type: "button", onClick: (event) => lookup(side, event.currentTarget.form), children: "Find address" })] }), searchState[side] && _jsx("p", { className: "text-sm text-muted", role: "status", children: searchState[side] }), addresses[side].length > 0 && _jsx("ul", { className: "max-h-48 overflow-auto rounded-xl border border-border", "aria-label": `${side} address suggestions`, children: addresses[side].map((result) => _jsx("li", { children: _jsx("button", { className: "w-full px-4 py-2 text-left text-sm hover:bg-subtle", type: "button", onClick: (event) => selectAddress(side, result, event.currentTarget.form), children: result.display }) }, `${result._udprn ?? result.display}`)) }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_address`, children: "Address" }), _jsx("input", { className: "min-h-12 w-full rounded-xl border border-border px-4", id: `${side}_address`, name: `${side}_address`, required: true, maxLength: 500, placeholder: "Select an address or enter it manually" })] }, side)), distance && _jsxs("p", { className: "text-sm text-muted", children: ["Approximate driving distance: ", distance.distanceMiles, " miles."] }), distanceUnavailable && _jsx("p", { className: "text-sm text-muted", children: "Distance is unavailable. You can still submit your request." }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Move details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Preferred date", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "date", name: "move_date" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Property size", _jsxs("select", { className: "min-h-12 rounded-xl border border-border px-4", name: "property_size", defaultValue: "2-bed", children: [_jsx("option", { value: "studio", children: "Studio" }), _jsx("option", { value: "1-bed", children: "1 bedroom" }), _jsx("option", { value: "2-bed", children: "2 bedrooms" }), _jsx("option", { value: "3-bed", children: "3 bedrooms" }), _jsx("option", { value: "4+-bed", children: "4 or more bedrooms" }), _jsx("option", { value: "other", children: "Other" })] })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Collection floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_from", min: "0", max: "99", defaultValue: "0" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Delivery floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_to", min: "0", max: "99", defaultValue: "0" })] }), [["flexible_date", "My date is flexible"], ["has_lift_from", "Collection has a lift"], ["has_lift_to", "Delivery has a lift"], ["packing_required", "I need packing"], ["storage_required", "I need storage"], ["dismantling_required", "I need dismantling"]].map(([key, label]) => _jsxs("label", { className: "flex items-center gap-2 text-sm text-ink", children: [_jsx("input", { type: "checkbox", name: key }), label] }, key)), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Special items, separated by commas", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "special_items", maxLength: 1000 })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Other details", _jsx("textarea", { className: "min-h-28 rounded-xl border border-border p-4", name: "additional_notes", maxLength: 4000 })] })] }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Your contact details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Name", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "name", required: true, maxLength: 255, autoComplete: "name" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Email", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "email", type: "email", required: true, maxLength: 320, autoComplete: "email" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Phone (optional)", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "phone", type: "tel", maxLength: 64, autoComplete: "tel" })] })] }), state.status === "invalid" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "Check your details and try again." }), state.status === "error" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "We could not submit your request. Please try again." }), reviewing && _jsx("p", { className: "rounded-xl bg-subtle p-4 text-sm text-ink", role: "status", children: "Review your addresses, move details, and contact email above. Submit when everything looks right." }), reviewing ? _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground disabled:opacity-50", type: "submit", disabled: pending, children: pending ? "Submitting…" : "Submit request" })
77
+ return _jsxs("form", { action: formAction, className: "space-y-8 rounded-3xl border border-border bg-white p-6 shadow-xl shadow-slate-900/5 sm:p-9", children: [_jsx(DashHoneypotField, {}), _jsx("input", { type: "hidden", name: "attempt_id", value: attemptId }), _jsx("input", { type: "hidden", name: "distance_miles", value: distance?.distanceMiles ?? "" }), _jsx("input", { type: "hidden", name: "duration_minutes", value: distance?.durationMinutes ?? "" }), ["from", "to"].map((side) => _jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-lg font-semibold text-ink", children: side === "from" ? "Collection" : "Delivery" }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_postcode`, children: "Postcode" }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { className: "min-h-12 min-w-0 flex-1 rounded-xl border border-border px-4", defaultValue: side === "from" ? initialPickup : "", id: `${side}_postcode`, name: `${side}_postcode`, autoComplete: "postal-code", required: true, maxLength: 16 }), _jsx("button", { className: "rounded-xl border border-border px-4 font-medium text-ink", type: "button", onClick: (event) => lookup(side, event.currentTarget.form), children: "Find address" })] }), searchState[side] && _jsx("p", { className: "text-sm text-muted", role: "status", children: searchState[side] }), addresses[side].length > 0 && _jsx("ul", { className: "max-h-48 overflow-auto rounded-xl border border-border", "aria-label": `${side} address suggestions`, children: addresses[side].map((result) => _jsx("li", { children: _jsx("button", { className: "w-full px-4 py-2 text-left text-sm hover:bg-subtle", type: "button", onClick: (event) => selectAddress(side, result, event.currentTarget.form), children: result.display }) }, `${result._udprn ?? result.display}`)) }), _jsx("label", { className: "block text-sm font-medium text-ink", htmlFor: `${side}_address`, children: "Address" }), _jsx("input", { className: "min-h-12 w-full rounded-xl border border-border px-4", id: `${side}_address`, name: `${side}_address`, required: true, maxLength: 500, placeholder: "Select an address or enter it manually" })] }, side)), distance && _jsxs("p", { className: "text-sm text-muted", children: ["Approximate driving distance: ", distance.distanceMiles, " miles."] }), distanceUnavailable && _jsx("p", { className: "text-sm text-muted", children: "Distance is unavailable. You can still submit your request." }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Move details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Preferred date", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "date", name: "move_date" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Property size", _jsxs("select", { className: "min-h-12 rounded-xl border border-border px-4", name: "property_size", defaultValue: "2-bed", children: [_jsx("option", { value: "studio", children: "Studio" }), _jsx("option", { value: "1-bed", children: "1 bedroom" }), _jsx("option", { value: "2-bed", children: "2 bedrooms" }), _jsx("option", { value: "3-bed", children: "3 bedrooms" }), _jsx("option", { value: "4+-bed", children: "4 or more bedrooms" }), _jsx("option", { value: "other", children: "Other" })] })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Collection floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_from", min: "0", max: "99", defaultValue: "0" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Delivery floor", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", type: "number", name: "floor_to", min: "0", max: "99", defaultValue: "0" })] }), [["flexible_date", "My date is flexible"], ["has_lift_from", "Collection has a lift"], ["has_lift_to", "Delivery has a lift"], ["packing_required", "I need packing"], ["storage_required", "I need storage"], ["dismantling_required", "I need dismantling"]].map(([key, label]) => _jsxs("label", { className: "flex items-center gap-2 text-sm text-ink", children: [_jsx("input", { type: "checkbox", name: key }), label] }, key)), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Special items, separated by commas", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "special_items", maxLength: 1000 })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Other details", _jsx("textarea", { className: "min-h-28 rounded-xl border border-border p-4", name: "additional_notes", maxLength: 4000 })] })] }), _jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx("legend", { className: "mb-3 text-lg font-semibold text-ink", children: "Your contact details" }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Name", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "name", required: true, maxLength: 255, autoComplete: "name" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink", children: ["Email", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "email", type: "email", required: true, maxLength: 320, autoComplete: "email" })] }), _jsxs("label", { className: "grid gap-2 text-sm font-medium text-ink sm:col-span-2", children: ["Phone (optional)", _jsx("input", { className: "min-h-12 rounded-xl border border-border px-4", name: "phone", type: "tel", maxLength: 64, autoComplete: "tel" })] })] }), state.status === "invalid" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "Check your details and try again." }), state.status === "error" && _jsx("p", { className: "rounded-xl bg-amber-50 p-4 text-sm text-amber-950", role: "alert", children: "We could not submit your request. Please try again." }), reviewing && _jsx("p", { className: "rounded-xl bg-subtle p-4 text-sm text-ink", role: "status", children: "Review your addresses, move details, and contact email above. Submit when everything looks right." }), reviewing ? _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground disabled:opacity-50", type: "submit", disabled: pending, children: pending ? "Submitting…" : "Submit request" })
77
78
  : _jsx("button", { className: "min-h-12 rounded-full bg-accent px-7 font-semibold text-accent-foreground", type: "button", disabled: !attemptId, onClick: (event) => { if (event.currentTarget.form?.reportValidity())
78
79
  setReviewing(true); }, children: "Review request" })] });
79
80
  }
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useState } from "react";
4
+ import { DashHoneypotField, readHoneypot } from "./honeypot-field.js";
4
5
  export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, placement = "page", privacyHref, submit, }) {
5
6
  const id = useId();
6
7
  const [ready, setReady] = useState(false);
@@ -20,6 +21,7 @@ export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, pl
20
21
  email: String(values.get("email") ?? "").trim(),
21
22
  name: String(values.get("name") ?? "").trim(),
22
23
  marketingOptIn: collectMarketingConsent && values.get("marketing_opt_in") === "on",
24
+ _gotcha: readHoneypot(values),
23
25
  source: placement === "block" ? "waitlist_block" : "waitlist_page",
24
26
  });
25
27
  if (receipt.accepted !== true)
@@ -37,5 +39,5 @@ export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, pl
37
39
  return _jsx("p", { role: "status", children: "Thanks. Check your inbox to confirm your place." });
38
40
  if (!acceptingEntries)
39
41
  return _jsx("p", { role: "status", children: "The waitlist is currently closed." });
40
- return (_jsxs("form", { className: "space-y-4", onSubmit: onSubmit, children: [_jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-name`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Name (optional)" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-name`, maxLength: 255, name: "name", autoComplete: "name" })] }), _jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-email`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Email" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-email`, maxLength: 254, name: "email", type: "email", autoComplete: "email", required: true })] }), collectMarketingConsent ? (_jsxs("label", { className: "flex items-start gap-2 text-sm leading-6 text-muted", children: [_jsx("input", { className: "mt-1", disabled: !ready || pending, name: "marketing_opt_in", type: "checkbox" }), _jsx("span", { children: "I would also like to receive marketing emails. I can unsubscribe later." })] })) : null, error ? _jsx("p", { className: "text-sm text-red-700", role: "alert", children: error }) : null, _jsx("button", { className: "min-h-11 rounded-full bg-accent px-5 py-2.5 text-sm font-semibold text-accent-foreground disabled:opacity-60", disabled: !ready || pending, type: "submit", children: pending ? "Joining…" : "Join the waitlist" }), privacyHref ? (_jsxs("p", { className: "text-xs leading-5 text-muted", children: ["We use your details to manage your place on the waitlist, as described in our", " ", _jsx("a", { className: "underline underline-offset-2 hover:text-ink", href: privacyHref, children: "privacy notice" }), "."] })) : null] }));
42
+ return (_jsxs("form", { className: "space-y-4", onSubmit: onSubmit, children: [_jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-name`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Name (optional)" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-name`, maxLength: 255, name: "name", autoComplete: "name" })] }), _jsxs("label", { className: "block space-y-1.5", htmlFor: `${id}-email`, children: [_jsx("span", { className: "text-sm font-medium text-ink", children: "Email" }), _jsx("input", { className: "min-h-11 w-full rounded-xl border border-border bg-white px-3 py-2 text-ink", disabled: !ready || pending, id: `${id}-email`, maxLength: 254, name: "email", type: "email", autoComplete: "email", required: true })] }), collectMarketingConsent ? (_jsxs("label", { className: "flex items-start gap-2 text-sm leading-6 text-muted", children: [_jsx("input", { className: "mt-1", disabled: !ready || pending, name: "marketing_opt_in", type: "checkbox" }), _jsx("span", { children: "I would also like to receive marketing emails. I can unsubscribe later." })] })) : null, _jsx(DashHoneypotField, {}), error ? _jsx("p", { className: "text-sm text-red-700", role: "alert", children: error }) : null, _jsx("button", { className: "min-h-11 rounded-full bg-accent px-5 py-2.5 text-sm font-semibold text-accent-foreground disabled:opacity-60", disabled: !ready || pending, type: "submit", children: pending ? "Joining…" : "Join the waitlist" }), privacyHref ? (_jsxs("p", { className: "text-xs leading-5 text-muted", children: ["We use your details to manage your place on the waitlist, as described in our", " ", _jsx("a", { className: "underline underline-offset-2 hover:text-ink", href: privacyHref, children: "privacy notice" }), "."] })) : null] }));
41
43
  }
package/dist/ui.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  */
10
10
  export { ButtonLink, Container, Eyebrow, SectionHeading, StatusPanel, VerifiedBadge, } from "./ui/primitives.js";
11
11
  export { SiteImage } from "./ui/site-image.js";
12
+ export { DashHoneypotField, HONEYPOT_FIELD_NAME, readHoneypot } from "./ui/honeypot-field.js";
12
13
  export { DashWaitlistForm } from "./ui/waitlist-form.js";
13
14
  export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
14
15
  export { DashMaintenancePage } from "./ui/maintenance-page.js";
package/dist/ui.js CHANGED
@@ -9,6 +9,7 @@
9
9
  */
10
10
  export { ButtonLink, Container, Eyebrow, SectionHeading, StatusPanel, VerifiedBadge, } from "./ui/primitives.js";
11
11
  export { SiteImage } from "./ui/site-image.js";
12
+ export { DashHoneypotField, HONEYPOT_FIELD_NAME, readHoneypot } from "./ui/honeypot-field.js";
12
13
  export { DashWaitlistForm } from "./ui/waitlist-form.js";
13
14
  export { DashWaitlistEmailLink, DashWaitlistPage } from "./ui/waitlist-page.js";
14
15
  export { DashMaintenancePage } from "./ui/maintenance-page.js";
@@ -1,3 +1,10 @@
1
1
  export declare function safePublicHref(value: unknown): string | undefined;
2
2
  export declare function safeImageSource(value: unknown): string | undefined;
3
3
  export declare function isInternalHref(href: string): boolean;
4
+ /**
5
+ * Brand media (logo, icon, share image) must be an absolute https URL: the
6
+ * backend resolves them to that, and a relative or other value (a legacy
7
+ * `/tenant-media/...` path) would 404 on the site's own origin. Anything else
8
+ * is undefined so the caller uses its own fallback.
9
+ */
10
+ export declare function absoluteHttpsUrl(value: unknown): string | undefined;
@@ -44,3 +44,21 @@ export function safeImageSource(value) {
44
44
  export function isInternalHref(href) {
45
45
  return internal(href);
46
46
  }
47
+ /**
48
+ * Brand media (logo, icon, share image) must be an absolute https URL: the
49
+ * backend resolves them to that, and a relative or other value (a legacy
50
+ * `/tenant-media/...` path) would 404 on the site's own origin. Anything else
51
+ * is undefined so the caller uses its own fallback.
52
+ */
53
+ export function absoluteHttpsUrl(value) {
54
+ const source = candidate(value);
55
+ if (!source)
56
+ return undefined;
57
+ try {
58
+ const url = new URL(source);
59
+ return url.protocol === "https:" && url.hostname ? url.toString() : undefined;
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
@@ -18,6 +18,7 @@ export function validateLeadForm(formData) {
18
18
  const rawEmail = formData.get("email");
19
19
  const rawPhone = formData.get("phone");
20
20
  const rawMessage = formData.get("message");
21
+ const rawGotcha = formData.get("_gotcha");
21
22
  const name = optional(rawName, LEAD_LIMITS.name);
22
23
  const email = optional(rawEmail, LEAD_LIMITS.email)?.toLowerCase();
23
24
  const phone = optional(rawPhone, LEAD_LIMITS.phone);
@@ -53,6 +54,8 @@ export function validateLeadForm(formData) {
53
54
  ...(name ? { name } : {}),
54
55
  ...(phone ? { phone } : {}),
55
56
  ...(message ? { message } : {}),
57
+ // The honeypot is forwarded as typed: the API, not the kit, judges it.
58
+ ...(typeof rawGotcha === "string" ? { _gotcha: rawGotcha } : {}),
56
59
  },
57
60
  },
58
61
  };
@@ -34,6 +34,7 @@ export function validateMovingQuoteForm(form) {
34
34
  packing_required: form.get("packing_required") === "on", storage_required: form.get("storage_required") === "on",
35
35
  dismantling_required: form.get("dismantling_required") === "on", special_items: specialItems,
36
36
  additional_notes: string("additional_notes", 4000),
37
+ ...(typeof form.get("_gotcha") === "string" ? { _gotcha: form.get("_gotcha") } : {}),
37
38
  ...(Number.isFinite(distance) && distance > 0 ? { distance_miles: distance } : {}),
38
39
  ...(Number.isFinite(duration) && duration > 0 ? { duration_minutes: duration } : {}),
39
40
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
@@ -43,7 +43,7 @@
43
43
  "server-only": "0.0.1"
44
44
  },
45
45
  "peerDependencies": {
46
- "@c1m-public/channel-client": ">=0.35.0 <1",
46
+ "@c1m-public/channel-client": ">=0.36.0 <1",
47
47
  "@c1m-public/platform-auth": ">=0.22.0 <1",
48
48
  "next": "^16",
49
49
  "react": "^19"
@@ -57,7 +57,7 @@
57
57
  "react-dom": "19.2.8",
58
58
  "typescript": "5.9.3",
59
59
  "vitest": "^4.1.4",
60
- "@c1m-public/channel-client": "0.35.0",
60
+ "@c1m-public/channel-client": "0.36.0",
61
61
  "@c1m-public/platform-auth": "0.23.0"
62
62
  },
63
63
  "peerDependenciesMeta": {