@c1m-public/dash-site-kit 0.13.0 → 0.14.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
@@ -268,3 +268,12 @@ before relying on it.
268
268
  ## Peer dependencies
269
269
 
270
270
  `@c1m-public/channel-client` (>=0.31.0), `next` 16, `react` 19.
271
+
272
+ ## Admin host links
273
+
274
+ A Dash's providers sign up, sign in and manage their workspace on the Dash's
275
+ admin host (`https://admin.<dash domain>`, or `https://<slug>.saasdash.app`
276
+ before it has a domain), never on `saasdash.app`. Set `adminUrl` in
277
+ `site.defaults.json` and build links with `createSiteConfig().adminUrl(path)`.
278
+ `DashAdminLink` swaps its label while the admin host's `c1m_signed_in` hint is
279
+ set; the session itself never leaves the admin host.
package/dist/index.d.ts CHANGED
@@ -32,6 +32,7 @@ export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } fr
32
32
  export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
33
33
  export type { LeadField, LeadValidationResult, ValidatedLead } from "./validation/leads.js";
34
34
  export { formatMoney } from "./format.js";
35
+ export { SIGN_IN_HINT_COOKIE, hasSignInHint } from "./sign-in-hint.js";
35
36
  export * from "./url-policy.js";
36
37
  export * from "./image-policy.js";
37
38
  export { canonicalUrl, createSiteConfig, safeLocale, } from "./site-config.js";
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ export { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS, decodeFirstTouch, enco
4
4
  export { selectDirectoryRegion, validateDirectoryKey, validateRegionFilter, } from "./validation/directory.js";
5
5
  export { LEAD_LIMITS, validateLeadForm } from "./validation/leads.js";
6
6
  export { formatMoney } from "./format.js";
7
+ export { SIGN_IN_HINT_COOKIE, hasSignInHint } from "./sign-in-hint.js";
7
8
  export * from "./url-policy.js";
8
9
  export * from "./image-policy.js";
9
10
  export { canonicalUrl, createSiteConfig, safeLocale, } from "./site-config.js";
@@ -2,6 +2,11 @@ import { FIRST_TOUCH_COOKIE, FIRST_TOUCH_MAX_AGE_SECONDS } from "./attribution.j
2
2
  function operatorOf(facts) {
3
3
  return facts.operator?.trim() || facts.siteName;
4
4
  }
5
+ /** "SimpleVan" or "SimpleVan, run by SimpleVan Ltd," when the operator differs. */
6
+ function runBy(facts) {
7
+ const operator = operatorOf(facts);
8
+ return operator === facts.siteName ? facts.siteName : `${facts.siteName}, run by ${operator},`;
9
+ }
5
10
  function contactLine(facts) {
6
11
  return facts.contactHref ? `through our contact page (${facts.contactHref})` : "using the contact details on this site";
7
12
  }
@@ -12,7 +17,6 @@ const firstTouchDays = Math.round(FIRST_TOUCH_MAX_AGE_SECONDS / 86_400);
12
17
  * details before relying on it.
13
18
  */
14
19
  export function privacyNotice(facts) {
15
- const operator = operatorOf(facts);
16
20
  const collected = [
17
21
  "Requests you send us: your name, email address, phone number and the details you enter about the job.",
18
22
  "An email address when you ask for a link to your existing requests.",
@@ -23,9 +27,9 @@ export function privacyNotice(facts) {
23
27
  return {
24
28
  title: "Privacy notice",
25
29
  updated: facts.updated,
26
- summary: `How ${operator} collects and uses personal information on ${facts.siteName}.`,
30
+ summary: `How ${facts.siteName} collects and uses your personal information.`,
27
31
  sections: [
28
- { heading: "Who we are", paragraphs: [`${facts.siteName} is run by ${operator}, the controller of the personal information described here. The site runs on the SaaSDash platform, which stores and processes that information on our behalf.`] },
32
+ { heading: "Who we are", paragraphs: [`${runBy(facts)} is responsible for the personal information described here. The site runs on the SaaSDash platform, which stores and processes that information on our behalf.`] },
29
33
  { heading: "What we collect", bullets: collected },
30
34
  {
31
35
  heading: "How we use it",
@@ -63,13 +67,12 @@ export function cookieNotice(facts) {
63
67
  }
64
68
  /** Terms of use for a Dash site. */
65
69
  export function termsOfUse(facts) {
66
- const operator = operatorOf(facts);
67
70
  return {
68
71
  title: "Terms of use",
69
72
  updated: facts.updated,
70
73
  summary: `The terms for using ${facts.siteName}.`,
71
74
  sections: [
72
- { heading: "About these terms", paragraphs: [`These terms apply when you use ${facts.siteName}, run by ${operator}. By using the site you accept them.`] },
75
+ { heading: "About these terms", paragraphs: [`These terms apply when you use ${runBy(facts).replace(/,$/, "")}. By using the site you accept them.`] },
73
76
  ...(facts.sharesWithProviders ? [{ heading: "Providers", paragraphs: ["Providers listed on the site are independent businesses. Any job you agree with a provider is a contract between you and that provider, who is responsible for the service, its price and its insurance. We help you find and contact providers but do not carry out the work."] }] : []),
74
77
  { heading: "Using the site", bullets: ["Give accurate information when you send a request.", "Do not misuse the site, interfere with it or try to access it without permission.", "Do not submit other people's details without their agreement."] },
75
78
  { heading: "Information on the site", paragraphs: ["We keep the site accurate but cannot guarantee every listing, price or guide is complete or current."] },
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Set by the Dash's admin host on the Dash's own domain while someone is
3
+ * signed in there. A display hint only ("Open your workspace" instead of
4
+ * "Sign in"): it carries no identity and must never gate access.
5
+ */
6
+ export declare const SIGN_IN_HINT_COOKIE = "c1m_signed_in";
7
+ /** Reads the hint from a `Cookie` header or `document.cookie` string. */
8
+ export declare function hasSignInHint(cookieHeader: string | null | undefined): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Set by the Dash's admin host on the Dash's own domain while someone is
3
+ * signed in there. A display hint only ("Open your workspace" instead of
4
+ * "Sign in"): it carries no identity and must never gate access.
5
+ */
6
+ export const SIGN_IN_HINT_COOKIE = "c1m_signed_in";
7
+ /** Reads the hint from a `Cookie` header or `document.cookie` string. */
8
+ export function hasSignInHint(cookieHeader) {
9
+ if (!cookieHeader)
10
+ return false;
11
+ return cookieHeader
12
+ .split(";")
13
+ .some((pair) => pair.trim() === `${SIGN_IN_HINT_COOKIE}=1`);
14
+ }
@@ -11,6 +11,11 @@ export interface SiteDefaults {
11
11
  leadSource?: string;
12
12
  /** Display fallback only; the plan catalog's per-region currency always wins. */
13
13
  defaultCurrency?: string;
14
+ /**
15
+ * The Dash's admin host (`https://admin.<dash domain>`), where providers sign
16
+ * up, sign in and manage their workspace. Never `saasdash.app`.
17
+ */
18
+ adminUrl?: string;
14
19
  }
15
20
  export interface SiteMeta {
16
21
  name: string;
@@ -50,6 +55,8 @@ export interface SiteConfig {
50
55
  canonicalUrl(baseUrl: string | null, pathname: string): string | undefined;
51
56
  formatMoney(cents: number, currency: string): string;
52
57
  resolveSiteMeta(): Promise<SiteMeta>;
58
+ /** A URL on the Dash's admin host, or null when the site has none configured. */
59
+ adminUrl(path?: string): string | null;
53
60
  }
54
61
  export declare function canonicalUrl(baseUrl: string | null, pathname: string): string | undefined;
55
62
  export declare function safeLocale(value: string | null | undefined): string;
@@ -74,6 +74,18 @@ export function createSiteConfig(defaults, options = {}) {
74
74
  return fallback;
75
75
  }
76
76
  }
77
+ function adminUrl(path = "/") {
78
+ const configured = defaults.adminUrl?.trim();
79
+ if (!configured)
80
+ return null;
81
+ try {
82
+ const url = new URL(path, configured);
83
+ return url.protocol === "https:" || url.protocol === "http:" ? url.toString() : null;
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
77
89
  return {
78
90
  siteName,
79
91
  siteDescription,
@@ -83,5 +95,6 @@ export function createSiteConfig(defaults, options = {}) {
83
95
  canonicalUrl,
84
96
  formatMoney: (cents, currency) => formatMoney(cents, currency, defaultCurrency),
85
97
  resolveSiteMeta,
98
+ adminUrl,
86
99
  };
87
100
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A link to the Dash's admin host whose label follows the sign-in hint. It
3
+ * renders the signed-out label on the server and swaps after hydration, so
4
+ * pages stay cacheable.
5
+ */
6
+ export declare function DashAdminLink({ href, signedOutLabel, signedInLabel, className, }: {
7
+ href: string;
8
+ signedOutLabel?: string;
9
+ signedInLabel?: string;
10
+ className?: string;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import Link from "next/link";
4
+ import { useEffect, useState } from "react";
5
+ import { hasSignInHint } from "../sign-in-hint.js";
6
+ /**
7
+ * A link to the Dash's admin host whose label follows the sign-in hint. It
8
+ * renders the signed-out label on the server and swaps after hydration, so
9
+ * pages stay cacheable.
10
+ */
11
+ export function DashAdminLink({ href, signedOutLabel = "Provider login", signedInLabel = "Open your workspace", className, }) {
12
+ const [signedIn, setSignedIn] = useState(false);
13
+ useEffect(() => {
14
+ setSignedIn(hasSignInHint(document.cookie));
15
+ }, []);
16
+ return (_jsx(Link, { className: className, href: href, prefetch: false, children: signedIn ? signedInLabel : signedOutLabel }));
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { Plan, PlanCatalog } from "../models/plans.js";
2
+ /**
3
+ * The Dash's live plan catalogue as cards. Each card's button goes where the
4
+ * site says (normally sign-up on the Dash's admin host, with the plan id).
5
+ */
6
+ export declare function DashPlanCards({ catalog, formatMoney, ctaHref, ctaLabel, }: {
7
+ catalog: PlanCatalog;
8
+ formatMoney: (cents: number, currency: string) => string;
9
+ ctaHref: (plan: Plan) => string;
10
+ ctaLabel?: string;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ButtonLink } from "./primitives.js";
3
+ function priceLabel(plan, catalog, formatMoney) {
4
+ if (plan.isFree)
5
+ return "Free";
6
+ const price = plan.pricing[catalog.defaultRegion] ?? Object.values(plan.pricing)[0];
7
+ if (!price)
8
+ return "Contact us";
9
+ return `${formatMoney(price.monthlyCents, price.currency)} / month`;
10
+ }
11
+ /**
12
+ * The Dash's live plan catalogue as cards. Each card's button goes where the
13
+ * site says (normally sign-up on the Dash's admin host, with the plan id).
14
+ */
15
+ export function DashPlanCards({ catalog, formatMoney, ctaHref, ctaLabel = "Get started", }) {
16
+ return (_jsx("ul", { className: "grid gap-5 md:grid-cols-2 lg:grid-cols-3", children: catalog.plans.map((plan) => (_jsxs("li", { className: "flex flex-col rounded-3xl border border-border bg-white p-7", children: [_jsx("h2", { className: "text-xl font-semibold tracking-tight text-ink", children: plan.name }), plan.description ? _jsx("p", { className: "mt-2 text-sm leading-6 text-muted", children: plan.description }) : null, _jsx("p", { className: "mt-5 text-3xl font-semibold tracking-tight text-ink", children: priceLabel(plan, catalog, formatMoney) }), plan.trialDays ? _jsxs("p", { className: "mt-1 text-sm text-muted", children: [plan.trialDays, "-day free trial"] }) : null, plan.highlights.length ? (_jsx("ul", { className: "mt-6 grid gap-2 text-sm leading-6 text-ink", children: plan.highlights.map((highlight) => (_jsxs("li", { className: "flex gap-2", children: [_jsx("span", { "aria-hidden": "true", className: "text-accent-text", children: "\u2713" }), highlight] }, highlight))) })) : null, _jsx("div", { className: "mt-auto pt-8", children: _jsx(ButtonLink, { href: ctaHref(plan), children: ctaLabel }) })] }, plan.id))) }));
17
+ }
package/dist/ui.d.ts CHANGED
@@ -15,3 +15,5 @@ export { DashMaintenancePage } from "./ui/maintenance-page.js";
15
15
  export { DashLandingPage, DashWaitlistLanding } from "./ui/landing-page.js";
16
16
  export { SiteErrorFallback } from "./ui/error-fallback.js";
17
17
  export { DashLegalPage } from "./ui/legal-page.js";
18
+ export { DashAdminLink } from "./ui/admin-link.js";
19
+ export { DashPlanCards } from "./ui/plan-cards.js";
package/dist/ui.js CHANGED
@@ -15,3 +15,5 @@ export { DashMaintenancePage } from "./ui/maintenance-page.js";
15
15
  export { DashLandingPage, DashWaitlistLanding } from "./ui/landing-page.js";
16
16
  export { SiteErrorFallback } from "./ui/error-fallback.js";
17
17
  export { DashLegalPage } from "./ui/legal-page.js";
18
+ export { DashAdminLink } from "./ui/admin-link.js";
19
+ export { DashPlanCards } from "./ui/plan-cards.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/dash-site-kit",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
@@ -56,7 +56,7 @@
56
56
  "react-dom": "19.2.8",
57
57
  "typescript": "5.9.3",
58
58
  "vitest": "^4.1.4",
59
- "@c1m-public/channel-client": "0.31.0"
59
+ "@c1m-public/channel-client": "0.32.0"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "next": {