@c1m-public/dash-site-kit 0.6.0 → 0.7.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/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@
9
9
  * reaching the transport, as a package boundary rather than a folder rule.
10
10
  */
11
11
  export type * from "./models/bootstrap.js";
12
+ export type * from "./models/waitlist.js";
13
+ export { shouldShowWaitlistPage } from "./models/bootstrap.js";
12
14
  export type * from "./models/directory.js";
13
15
  export type * from "./models/leads.js";
14
16
  export type * from "./models/lead-portal.js";
@@ -20,6 +22,7 @@ export type { LeadsProvider } from "./ports/leads.js";
20
22
  export type { LeadPortalProvider } from "./ports/lead-portal.js";
21
23
  export type { PlansProvider } from "./ports/plans.js";
22
24
  export type { ProfileProvider } from "./ports/profile.js";
25
+ export type { WaitlistProvider } from "./ports/waitlist.js";
23
26
  export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
24
27
  export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
25
28
  export type { LeadField, LeadValidationResult, ValidatedLead } from "./validation/leads.js";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { shouldShowWaitlistPage } from "./models/bootstrap.js";
1
2
  export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
2
3
  export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
3
4
  export { formatMoney } from "./format.js";
@@ -30,4 +30,11 @@ export interface DashBootstrap {
30
30
  title: string;
31
31
  description?: string;
32
32
  };
33
+ waitlist?: {
34
+ enabled: boolean;
35
+ acceptingEntries: boolean;
36
+ display: "page" | "block";
37
+ };
33
38
  }
39
+ /** Page mode owns the public brochure experience; block mode remains composable. */
40
+ export declare function shouldShowWaitlistPage(bootstrap: DashBootstrap): boolean;
@@ -1 +1,4 @@
1
- export {};
1
+ /** Page mode owns the public brochure experience; block mode remains composable. */
2
+ export function shouldShowWaitlistPage(bootstrap) {
3
+ return bootstrap.waitlist?.enabled === true && bootstrap.waitlist.display === "page";
4
+ }
@@ -0,0 +1,12 @@
1
+ export interface DashWaitlistForm {
2
+ acceptingEntries: boolean;
3
+ collectMarketingConsent: boolean;
4
+ }
5
+ export interface DashWaitlistSubmission {
6
+ email: string;
7
+ name?: string;
8
+ marketingOptIn?: boolean;
9
+ }
10
+ export interface DashWaitlistReceipt {
11
+ accepted: true;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,6 +5,7 @@ import type { LeadInput, LeadOutcome } from "../models/leads.js";
5
5
  import type { RequestLinkOutcome, ViewOutcome } from "../models/lead-portal.js";
6
6
  import type { PlanCatalog } from "../models/plans.js";
7
7
  import type { DashProfile } from "../models/profile.js";
8
+ import type { DashWaitlistForm, DashWaitlistReceipt, DashWaitlistSubmission } from "../models/waitlist.js";
8
9
  /**
9
10
  * A credential-free local preview. When `enabled()` is true the layer answers
10
11
  * from these fixtures and never touches the channel, so `npm run dev` works
@@ -32,6 +33,8 @@ export interface DashDataLayer {
32
33
  submitLead(input: LeadInput, attemptId: string): Promise<LeadOutcome>;
33
34
  requestPortalLink(email: string): Promise<RequestLinkOutcome>;
34
35
  viewPortal(token: string): Promise<ViewOutcome>;
36
+ loadDashWaitlistForm(): Promise<DashWaitlistForm>;
37
+ submitDashWaitlist(input: DashWaitlistSubmission, attemptId: string): Promise<DashWaitlistReceipt>;
35
38
  }
36
39
  /**
37
40
  * Builds the whole logic layer for a dash site in one call.
@@ -7,6 +7,7 @@ import { createC1MLeadPortalProvider } from "./providers/lead-portal.js";
7
7
  import { createC1MLeadsProvider } from "./providers/leads.js";
8
8
  import { createC1MPlansProvider } from "./providers/plans.js";
9
9
  import { createC1MProfileProvider } from "./providers/profile.js";
10
+ import { createC1MWaitlistProvider } from "./providers/waitlist.js";
10
11
  /**
11
12
  * Builds the whole logic layer for a dash site in one call.
12
13
  *
@@ -24,6 +25,7 @@ export function createDashDataLayer(options) {
24
25
  const plansProvider = createC1MPlansProvider();
25
26
  const leadsProvider = createC1MLeadsProvider(options.leadSource);
26
27
  const leadPortalProvider = createC1MLeadPortalProvider();
28
+ const waitlistProvider = createC1MWaitlistProvider();
27
29
  const loadDashProfile = cache(() => inPreview() ? Promise.resolve(preview.profile) : profileProvider.loadProfile());
28
30
  const listDirectoryRegions = cache(() => inPreview() ? Promise.resolve([]) : directoryProvider.listRegions());
29
31
  const listDirectory = cache((filter) => inPreview() ? Promise.resolve([]) : directoryProvider.list(filter));
@@ -49,5 +51,7 @@ export function createDashDataLayer(options) {
49
51
  submitLead: (input, attemptId) => leadsProvider.create(input, attemptId),
50
52
  requestPortalLink: (email) => leadPortalProvider.requestLink(email),
51
53
  viewPortal: (token) => leadPortalProvider.view(token),
54
+ loadDashWaitlistForm: cache(() => waitlistProvider.loadForm()),
55
+ submitDashWaitlist: (input, attemptId) => waitlistProvider.submit(input, attemptId),
52
56
  };
53
57
  }
@@ -29,6 +29,11 @@ export function normalizeDashBootstrap(init) {
29
29
  title: text(init.seo?.title) ?? name,
30
30
  description: text(init.seo?.description) ?? text(init.public_profile.headline) ?? text(init.public_profile.short_description),
31
31
  },
32
+ waitlist: {
33
+ enabled: init.waitlist?.enabled === true,
34
+ acceptingEntries: init.waitlist?.accepting_entries === true,
35
+ display: init.waitlist?.display === "page" ? "page" : "block",
36
+ },
32
37
  };
33
38
  }
34
39
  // --- profile --------------------------------------------------------------
@@ -0,0 +1,7 @@
1
+ import "server-only";
2
+ import type { WaitlistProvider } from "../../ports/waitlist.js";
3
+ import { getDashChannelClient } from "../client.js";
4
+ type ChannelClient = Awaited<ReturnType<typeof getDashChannelClient>>;
5
+ type ChannelClientResolver = () => ChannelClient | Promise<ChannelClient>;
6
+ export declare function createC1MWaitlistProvider(resolveClient?: ChannelClientResolver): WaitlistProvider;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ import "server-only";
2
+ import { getDashChannelClient } from "../client.js";
3
+ export function createC1MWaitlistProvider(resolveClient = getDashChannelClient) {
4
+ return {
5
+ async loadForm() {
6
+ const response = await (await resolveClient()).dash.waitlist.form();
7
+ return {
8
+ acceptingEntries: response.status.accepting_entries === true && response.status.display === "page",
9
+ collectMarketingConsent: response.collect_marketing_consent === true,
10
+ };
11
+ },
12
+ async submit(input, attemptId) {
13
+ const response = await (await resolveClient()).dash.waitlist.submit({
14
+ email: input.email,
15
+ name: input.name,
16
+ marketing_opt_in: input.marketingOptIn === true,
17
+ source: "waitlist_page",
18
+ }, { idempotencyKey: attemptId });
19
+ if (response.accepted !== true)
20
+ throw new Error("waitlist submission was not accepted");
21
+ return { accepted: true };
22
+ },
23
+ };
24
+ }
package/dist/next.d.ts CHANGED
@@ -22,6 +22,7 @@ export { ChannelSiteSentryConfigurationError, createChannelSiteRequestErrorHandl
22
22
  export type { ChannelSiteSentryEnvironment, ChannelSiteSentryOptions, } from "./next/sentry.js";
23
23
  export { resolveC1MAsset } from "./next/assets.js";
24
24
  export { createC1MBootstrapProvider } from "./next/providers/bootstrap.js";
25
+ export { createC1MWaitlistProvider } from "./next/providers/waitlist.js";
25
26
  export { createC1MDirectoryProvider } from "./next/providers/directory.js";
26
27
  export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
27
28
  export { createC1MLeadsProvider } from "./next/providers/leads.js";
package/dist/next.js CHANGED
@@ -17,6 +17,7 @@ export { observeChannelRequest } from "./next/observability.js";
17
17
  export { ChannelSiteSentryConfigurationError, createChannelSiteRequestErrorHandler, initializeChannelSiteSentry, resolveChannelSiteSentryOptions, } from "./next/sentry.js";
18
18
  export { resolveC1MAsset } from "./next/assets.js";
19
19
  export { createC1MBootstrapProvider } from "./next/providers/bootstrap.js";
20
+ export { createC1MWaitlistProvider } from "./next/providers/waitlist.js";
20
21
  export { createC1MDirectoryProvider } from "./next/providers/directory.js";
21
22
  export { createC1MLeadPortalProvider } from "./next/providers/lead-portal.js";
22
23
  export { createC1MLeadsProvider } from "./next/providers/leads.js";
@@ -0,0 +1,5 @@
1
+ import type { DashWaitlistForm, DashWaitlistReceipt, DashWaitlistSubmission } from "../models/waitlist.js";
2
+ export interface WaitlistProvider {
3
+ loadForm(): Promise<DashWaitlistForm>;
4
+ submit(input: DashWaitlistSubmission, attemptId: string): Promise<DashWaitlistReceipt>;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { DashWaitlistReceipt, DashWaitlistSubmission } from "../models/waitlist.js";
2
+ export declare function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, submit, }: {
3
+ acceptingEntries: boolean;
4
+ collectMarketingConsent: boolean;
5
+ submit: (input: DashWaitlistSubmission) => Promise<DashWaitlistReceipt>;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useState } from "react";
4
+ export function DashWaitlistForm({ acceptingEntries, collectMarketingConsent, submit, }) {
5
+ const id = useId();
6
+ const [ready, setReady] = useState(false);
7
+ const [pending, setPending] = useState(false);
8
+ const [accepted, setAccepted] = useState(false);
9
+ const [error, setError] = useState(null);
10
+ useEffect(() => setReady(true), []);
11
+ async function onSubmit(event) {
12
+ event.preventDefault();
13
+ if (!ready || pending || !acceptingEntries)
14
+ return;
15
+ const values = new FormData(event.currentTarget);
16
+ setPending(true);
17
+ setError(null);
18
+ try {
19
+ const receipt = await submit({
20
+ email: String(values.get("email") ?? "").trim(),
21
+ name: String(values.get("name") ?? "").trim(),
22
+ marketingOptIn: collectMarketingConsent && values.get("marketing_opt_in") === "on",
23
+ });
24
+ if (receipt.accepted !== true)
25
+ throw new Error("waitlist submission was not accepted");
26
+ setAccepted(true);
27
+ }
28
+ catch {
29
+ setError("We could not add you right now. Please try again.");
30
+ }
31
+ finally {
32
+ setPending(false);
33
+ }
34
+ }
35
+ if (accepted)
36
+ return _jsx("p", { role: "status", children: "Thanks. You are on the waitlist." });
37
+ if (!acceptingEntries)
38
+ return _jsx("p", { role: "status", children: "The waitlist is currently closed." });
39
+ 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" })] }));
40
+ }
package/dist/ui.d.ts CHANGED
@@ -9,4 +9,5 @@
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 { DashWaitlistForm } from "./ui/waitlist-form.js";
12
13
  export { SiteErrorFallback } from "./ui/error-fallback.js";
package/dist/ui.js CHANGED
@@ -9,4 +9,5 @@
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 { DashWaitlistForm } from "./ui/waitlist-form.js";
12
13
  export { SiteErrorFallback } from "./ui/error-fallback.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.6.0",
3
+ "version": "0.7.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.23.0 <1",
46
+ "@c1m-public/channel-client": ">=0.27.0 <1",
47
47
  "next": "^16",
48
48
  "react": "^19"
49
49
  },
@@ -54,7 +54,7 @@
54
54
  "typescript": "5.9.3",
55
55
  "vitest": "^4.1.4",
56
56
  "@types/node": "^22",
57
- "@c1m-public/channel-client": "0.25.0"
57
+ "@c1m-public/channel-client": "0.27.0"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "next": {