@c1m-public/dash-site-kit 1.0.0 → 4.0.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 +4 -4
- package/dist/models/attribution.d.ts +7 -1
- package/dist/models/attribution.js +8 -2
- package/dist/models/plans.d.ts +2 -8
- package/dist/next/normalize.d.ts +3 -3
- package/dist/next/normalize.js +11 -17
- package/dist/next/providers/plans.js +1 -7
- package/dist/ui/plan-cards.js +3 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -187,10 +187,10 @@ global initialization tag.
|
|
|
187
187
|
Two clients, deliberately:
|
|
188
188
|
|
|
189
189
|
- A **shared, revalidating** client for reads that are identical for every
|
|
190
|
-
visitor — profile, directory
|
|
190
|
+
visitor — profile, directory and the Dash-selected plan catalogue.
|
|
191
191
|
- A **`no-store`** client for anything whose answer depends on who is asking —
|
|
192
|
-
geo detection
|
|
193
|
-
|
|
192
|
+
geo detection and lead capture. Geo never changes plan pricing: the backend
|
|
193
|
+
returns the Dash's authoritative default region and exact price.
|
|
194
194
|
|
|
195
195
|
The npm channel client forces `no-store` only for mutations and
|
|
196
196
|
customer-session reads, so a signed-visitor GET on the shared client would be
|
|
@@ -281,7 +281,7 @@ before relying on it.
|
|
|
281
281
|
|
|
282
282
|
## Peer dependencies
|
|
283
283
|
|
|
284
|
-
`@c1m-public/channel-client` ^
|
|
284
|
+
`@c1m-public/channel-client` ^4.0.0, `@c1m-public/platform-auth` ^1.0.0, `next` 16, `react` 19.
|
|
285
285
|
|
|
286
286
|
The moving quote form, validation, server data layer and customer lead portal
|
|
287
287
|
are shared across Dash sites. A site supplies its own channel client and
|
|
@@ -15,7 +15,13 @@ export interface FirstTouch {
|
|
|
15
15
|
country?: string;
|
|
16
16
|
locale?: string;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The first touch for a landing request. The referrer counts only when
|
|
20
|
+
* external. The landing path keeps no query string: campaign tags are read
|
|
21
|
+
* into their own fields, and a first visit can arrive on an emailed link whose
|
|
22
|
+
* query carries a secret (a waitlist verify token or unsubscribe key), which
|
|
23
|
+
* must not sit in a 30-day cookie or travel on as attribution.
|
|
24
|
+
*/
|
|
19
25
|
export declare function firstTouchFrom(url: URL, referrer: string | null | undefined): FirstTouch;
|
|
20
26
|
export declare function encodeFirstTouch(touch: FirstTouch): string;
|
|
21
27
|
/** Parses a cookie value, keeping only known, bounded string fields. */
|
|
@@ -9,9 +9,15 @@ function bounded(value, max) {
|
|
|
9
9
|
const trimmed = value?.trim();
|
|
10
10
|
return trimmed && trimmed.length <= max && !/[\u0000-\u001f\u007f]/.test(trimmed) ? trimmed : undefined;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The first touch for a landing request. The referrer counts only when
|
|
14
|
+
* external. The landing path keeps no query string: campaign tags are read
|
|
15
|
+
* into their own fields, and a first visit can arrive on an emailed link whose
|
|
16
|
+
* query carries a secret (a waitlist verify token or unsubscribe key), which
|
|
17
|
+
* must not sit in a 30-day cookie or travel on as attribution.
|
|
18
|
+
*/
|
|
13
19
|
export function firstTouchFrom(url, referrer) {
|
|
14
|
-
const touch = { landing_path: bounded(url.pathname
|
|
20
|
+
const touch = { landing_path: bounded(url.pathname, 512) };
|
|
15
21
|
for (const key of UTM_KEYS) {
|
|
16
22
|
const value = bounded(url.searchParams.get(key), 128);
|
|
17
23
|
if (value)
|
package/dist/models/plans.d.ts
CHANGED
|
@@ -15,17 +15,11 @@ export interface Plan {
|
|
|
15
15
|
isFree: boolean;
|
|
16
16
|
trialDays?: number;
|
|
17
17
|
highlights: string[];
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
export interface PlanRegion {
|
|
22
|
-
code: string;
|
|
23
|
-
name: string;
|
|
24
|
-
currency: string;
|
|
18
|
+
/** The exact backend-selected price for the catalogue's default region. */
|
|
19
|
+
price?: PlanPrice;
|
|
25
20
|
}
|
|
26
21
|
export interface PlanCatalog {
|
|
27
22
|
/** Sorted by level, ascending — free first. */
|
|
28
23
|
plans: Plan[];
|
|
29
|
-
regions: PlanRegion[];
|
|
30
24
|
defaultRegion: string;
|
|
31
25
|
}
|
package/dist/next/normalize.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export declare function normalizeDirectoryRegion(region: DashDirectoryRegion): D
|
|
|
16
16
|
export declare function normalizeDirectoryEntry(entry: DashDirectoryEntry): DirectoryEntry;
|
|
17
17
|
export declare function normalizeDirectoryProfile(profile: DashDirectoryProfile): DirectoryProfile;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* stay in minor units end to end — `lib/format.ts` is the only
|
|
21
|
-
* become display strings.
|
|
19
|
+
* The backend selects one authoritative region and returns only its exact
|
|
20
|
+
* price. Prices stay in minor units end to end — `lib/format.ts` is the only
|
|
21
|
+
* place they become display strings.
|
|
22
22
|
*/
|
|
23
23
|
export declare function normalizePlanCatalog(response: DashPlansResponse): PlanCatalog;
|
package/dist/next/normalize.js
CHANGED
|
@@ -112,21 +112,20 @@ export function normalizeDirectoryProfile(profile) {
|
|
|
112
112
|
}
|
|
113
113
|
// --- plans ------------------------------------------------------------------
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
116
|
-
* stay in minor units end to end — `lib/format.ts` is the only
|
|
117
|
-
* become display strings.
|
|
115
|
+
* The backend selects one authoritative region and returns only its exact
|
|
116
|
+
* price. Prices stay in minor units end to end — `lib/format.ts` is the only
|
|
117
|
+
* place they become display strings.
|
|
118
118
|
*/
|
|
119
119
|
export function normalizePlanCatalog(response) {
|
|
120
120
|
const plans = (response.plans ?? [])
|
|
121
121
|
.map((plan) => {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
122
|
+
const price = plan.price
|
|
123
|
+
? {
|
|
124
|
+
currency: plan.price.currency,
|
|
125
|
+
monthlyCents: plan.price.monthly_price,
|
|
126
|
+
yearlyCents: plan.price.yearly_price,
|
|
127
|
+
}
|
|
128
|
+
: undefined;
|
|
130
129
|
return {
|
|
131
130
|
id: plan.id,
|
|
132
131
|
name: plan.name,
|
|
@@ -135,17 +134,12 @@ export function normalizePlanCatalog(response) {
|
|
|
135
134
|
isFree: plan.is_free === true,
|
|
136
135
|
trialDays: plan.trial_days,
|
|
137
136
|
highlights: plan.highlights ?? [],
|
|
138
|
-
|
|
137
|
+
price,
|
|
139
138
|
};
|
|
140
139
|
})
|
|
141
140
|
.sort((a, b) => a.level - b.level);
|
|
142
141
|
return {
|
|
143
142
|
plans,
|
|
144
|
-
regions: (response.regions ?? []).map((region) => ({
|
|
145
|
-
code: region.code,
|
|
146
|
-
name: text(region.name) ?? region.code,
|
|
147
|
-
currency: region.currency,
|
|
148
|
-
})),
|
|
149
143
|
defaultRegion: response.default_region,
|
|
150
144
|
};
|
|
151
145
|
}
|
|
@@ -5,13 +5,7 @@ export function createC1MPlansProvider(resolveClient = getVisitorDashChannelClie
|
|
|
5
5
|
return {
|
|
6
6
|
async loadCatalog() {
|
|
7
7
|
const client = await resolveClient();
|
|
8
|
-
|
|
9
|
-
client.dash.plans(),
|
|
10
|
-
client.geo.detect().catch(() => undefined),
|
|
11
|
-
]);
|
|
12
|
-
const catalog = normalizePlanCatalog(response);
|
|
13
|
-
const detectedRegion = geo ? catalog.regions.find((region) => region.code.toUpperCase() === geo.region.code.toUpperCase()) : undefined;
|
|
14
|
-
return detectedRegion ? { ...catalog, defaultRegion: detectedRegion.code } : catalog;
|
|
8
|
+
return normalizePlanCatalog(await client.dash.plans());
|
|
15
9
|
},
|
|
16
10
|
};
|
|
17
11
|
}
|
package/dist/ui/plan-cards.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ButtonLink } from "./primitives.js";
|
|
3
|
-
function priceLabel(plan,
|
|
3
|
+
function priceLabel(plan, formatMoney) {
|
|
4
4
|
if (plan.isFree)
|
|
5
5
|
return "Free";
|
|
6
|
-
const price = plan.
|
|
6
|
+
const price = plan.price;
|
|
7
7
|
if (!price)
|
|
8
8
|
return "Contact us";
|
|
9
9
|
return `${formatMoney(price.monthlyCents, price.currency)} / month`;
|
|
@@ -13,5 +13,5 @@ function priceLabel(plan, catalog, formatMoney) {
|
|
|
13
13
|
* site says (normally sign-up on the Dash's admin host, with the plan id).
|
|
14
14
|
*/
|
|
15
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,
|
|
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, 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
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/dash-site-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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": "^
|
|
46
|
+
"@c1m-public/channel-client": "^4.0.0",
|
|
47
47
|
"@c1m-public/platform-auth": "^1.0.0",
|
|
48
48
|
"next": "^16",
|
|
49
49
|
"react": "^19"
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"react-dom": "19.2.8",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
59
|
"vitest": "^4.1.4",
|
|
60
|
-
"@c1m-public/
|
|
61
|
-
"@c1m-public/
|
|
60
|
+
"@c1m-public/channel-client": "4.0.0",
|
|
61
|
+
"@c1m-public/platform-auth": "1.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"next": {
|