@c1m-public/dash-site-kit 0.13.1 → 0.14.1

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 "@c1m-public/platform-auth";
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 "@c1m-public/platform-auth";
7
8
  export * from "./url-policy.js";
8
9
  export * from "./image-policy.js";
9
10
  export { canonicalUrl, createSiteConfig, safeLocale, } from "./site-config.js";
@@ -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 "@c1m-public/platform-auth";
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.1",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Shared transport, domain and UI layer for MML dash-scoped public sites",
@@ -44,6 +44,7 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@c1m-public/channel-client": ">=0.31.0 <1",
47
+ "@c1m-public/platform-auth": ">=0.22.0 <1",
47
48
  "next": "^16",
48
49
  "react": "^19"
49
50
  },
@@ -56,7 +57,8 @@
56
57
  "react-dom": "19.2.8",
57
58
  "typescript": "5.9.3",
58
59
  "vitest": "^4.1.4",
59
- "@c1m-public/channel-client": "0.31.0"
60
+ "@c1m-public/channel-client": "0.33.0",
61
+ "@c1m-public/platform-auth": "0.22.0"
60
62
  },
61
63
  "peerDependenciesMeta": {
62
64
  "next": {