@meterbox/react 0.1.8 → 0.1.10

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
@@ -14,8 +14,8 @@ Each component supports two modes:
14
14
  `<CreditBalance>`, `<CreditGrantsTable>`, and `<CreditUtilization>` can
15
15
  fetch their own data from the `/v1/customer-portal/*` endpoints using a
16
16
  short-lived customer-scoped JWT minted server-side
17
- (`POST /v1/tokens/:id`). Pass `baseUrl` + `customerId` +
18
- `customerToken` instead of the data prop.
17
+ (`POST /v1/tokens/:id`). Pass `customerId` + `customerToken` instead of
18
+ the data prop.
19
19
 
20
20
  For a complete hosted-feel portal in one component, see
21
21
  [`@meterbox/customer-portal`](https://www.npmjs.com/package/@meterbox/customer-portal).
@@ -45,9 +45,9 @@ import {
45
45
  } from "@meterbox/react";
46
46
  ```
47
47
 
48
- ### `<PricingTable plans currentPlanId? currency? onSelect? customerEmail? branding? />` or `<PricingTable baseUrl publishableKey … />`
48
+ ### `<PricingTable plans currentPlanId? currency? onSelect? customerEmail? branding? selectedPlanId? onPlanClick? renderFooter? />` or `<PricingTable publishableKey … />`
49
49
 
50
- On a public page with no backend of its own, pass `baseUrl` and a
50
+ On a public page with no backend of its own, pass a
51
51
  publishable key (`mb_pub_...`, from Settings > API keys) instead of `plans`.
52
52
  The table then reads the public pricing snapshot,
53
53
  `GET /v1/catalog/pricing-page`: published plans with display fields only. A
@@ -75,18 +75,37 @@ pay for usage: the amounts included each month, what happens past them
75
75
  and output rates per 1M tokens, tier ladders included.
76
76
 
77
77
  A plan lists its included credits first ("1,500 Bits a month", in the tenant's credit unit), then
78
- its `bullets`: the tenant's own pricing-page bullets, else its features' names. A pricing-page
79
- plan with a public promotion shows its promotional price, the regular one struck through, and the
80
- code to use ("Save 50% with code LAUNCH50 for 3 months").
78
+ its `bullet_details`, which `GET /v1/plans`, the pricing snapshot and the customer portal's plans
79
+ all carry: the tenant's own pricing-page bullets, else each feature by its name with its
80
+ description under it, by its description when it has no name, and by its id only when it has
81
+ neither. Without them, it lists its `bullets`, its `display_features` or its feature ids. A
82
+ pricing-page plan with a public promotion shows its promotional price, the regular one struck
83
+ through, and the code to use ("Save 50% with code LAUNCH50 for 3 months").
84
+
85
+ A plan whose `stripe_price_monthly_usd` is `null` has no fixed price and shows "Custom". A plan's
86
+ own `cta.label` names its button, and its `cta.url` may also be a path on your site
87
+ (`/signup?plan=pro`). A plan's `badges` (an array of text) show next to its `badge`.
88
+
89
+ For a catalog you manage rather than sell from, such as an admin page: `selectedPlanId` and
90
+ `onPlanClick(plan)` make each card selectable, and `renderFooter(plan)` puts your own content
91
+ (counts, edit buttons) where each card's button would be. A click inside it doesn't select the
92
+ card.
93
+
94
+ ### Base URL: `<MeterboxProvider baseUrl>`
95
+
96
+ The components call `https://meterbox.ai`, so there's nothing to set. To
97
+ point them elsewhere, wrap them once in `<MeterboxProvider baseUrl="…">`; a
98
+ component's own `baseUrl` prop wins over both. `useBaseUrl()` reads the
99
+ resolved URL for your own calls.
81
100
 
82
101
  ### Branding: `<BrandingProvider branding>`
83
102
 
84
103
  Every component styles itself from `--mbx-*` CSS variables (`--mbx-accent`,
85
- `--mbx-text`, `--mbx-card`, `--mbx-font`, `--mbx-radius` and the button
86
- variables), with Meterbox's defaults as fallbacks. Wrap them in
104
+ `--mbx-text`, `--mbx-card`, `--mbx-border`, `--mbx-font`, `--mbx-radius` and the
105
+ button variables), with Meterbox's defaults as fallbacks. Wrap them in
87
106
  `<BrandingProvider branding={branding}>` to apply your branding from
88
107
  Settings → Branding (`GET /v1/settings/branding`): logo, colors, font and
89
- button style. `<PricingTable baseUrl publishableKey>` applies it from the
108
+ button style. `<PricingTable publishableKey>` applies it from the
90
109
  pricing snapshot by itself, and any component's surroundings can set the
91
110
  variables in CSS. `useBranding()` reads the values (e.g. the logo), and
92
111
  `theme` exports the variable references for styling your own elements to
@@ -105,7 +124,7 @@ keys and English text are in [`src/i18n.js`](./src/i18n.js). Plan names,
105
124
  features and offers are shown as you entered them. `useI18n()` gives your own
106
125
  elements the same `t(key, vars)`, `date(iso)` and `money(amount, currency)`.
107
126
 
108
- ### `<BillingDetailsButton baseUrl customerId customerToken returnUrl? label? onSession? onError? />`
127
+ ### `<BillingDetailsButton customerId customerToken returnUrl? label? onSession? onError? />`
109
128
 
110
129
  Sends the customer to Stripe's own Billing Portal to update their payment
111
130
  method and billing details (address, tax IDs, email, name, phone) and see
@@ -122,7 +141,7 @@ works once the customer has a Stripe account and the tenant has enabled
122
141
  Side-by-side comparison of two plan records with added / removed feature
123
142
  deltas. Pair with `<SubscriptionPreview>` for the prorated math.
124
143
 
125
- ### `<CheckoutButton planId successUrl cancelUrl baseUrl customerId customerToken billingInterval? label? onSession? onError? />`
144
+ ### `<CheckoutButton planId successUrl cancelUrl customerId customerToken billingInterval? label? onSession? onError? />`
126
145
 
127
146
  One-tap Stripe Checkout for a plan change. POSTs to
128
147
  `/v1/customer-portal/:id/checkout` (customer JWT, no API key in the
@@ -131,13 +150,13 @@ browser) and redirects to the returned Stripe URL. `billingInterval`
131
150
  `annual_free_months` configured; requesting "annual" on a plan that
132
151
  doesn't offer it surfaces a 400 via `onError` rather than redirecting.
133
152
 
134
- ### `<SubscriptionPreview preview? | baseUrl customerId customerToken planId planVersion? />`
153
+ ### `<SubscriptionPreview preview? | customerId customerToken planId planVersion? />`
135
154
 
136
155
  Renders the response of `POST /v1/customers/:id/subscription/preview` (admin)
137
156
  or `POST /v1/customer-portal/:id/subscription/preview` (customer JWT):
138
157
  prorated charge, MRR delta, effective date.
139
158
 
140
- ### `<PlanChangeCard preview? scheduledChange? allowSchedule? | baseUrl customerId customerToken planId planVersion? fetch? onConfirm? onCancelScheduled? onChanged? />`
159
+ ### `<PlanChangeCard preview? scheduledChange? allowSchedule? | customerId customerToken planId planVersion? fetch? onConfirm? onCancelScheduled? onChanged? />`
141
160
 
142
161
  Composes `<SubscriptionPreview>` with the actions it doesn't have: actually
143
162
  applying or scheduling the change, and cancelling a pending scheduled one.
@@ -147,7 +166,7 @@ Two modes:
147
166
  `onConfirm(effective)` / `onCancelScheduled()` callbacks that return
148
167
  promises; you own how the request is actually made (e.g. proxied through
149
168
  your own backend, session-authenticated, holding no customer JWT).
150
- - **Self-fetching**: `baseUrl` + `customerId` + `customerToken` + `planId`,
169
+ - **Self-fetching**: `customerId` + `customerToken` + `planId`,
151
170
  no `onConfirm`/`onCancelScheduled` supplied: fetches its own preview AND
152
171
  posts confirm/cancel directly to `POST /v1/customer-portal/:id/subscription/change`
153
172
  and `DELETE /v1/customer-portal/:id/subscription/scheduled`.
@@ -163,23 +182,23 @@ mounted; keep whatever render condition shows the card independent of the
163
182
  plan id it just changed to, or the card (and the confirmation message it's
164
183
  showing) unmounts the instant your own state catches up.
165
184
 
166
- ### `<CreditBalance balance? | baseUrl customerId customerToken; threshold? onTopUp? />`
185
+ ### `<CreditBalance balance? | customerId customerToken; threshold? onTopUp? />`
167
186
 
168
187
  Compact balance widget. If `balance_usd < threshold`, shows a top-up CTA
169
188
  wired to `onTopUp`. Self-fetches `GET /v1/customer-portal/:id/credits` in
170
189
  self-fetch mode.
171
190
 
172
- ### `<CreditGrantsTable grants? balance_usd? | baseUrl customerId customerToken; filter? />`
191
+ ### `<CreditGrantsTable grants? balance_usd? | customerId customerToken; filter? />`
173
192
 
174
193
  Table of active grants: source, amount, remaining, expiry, status. Pass
175
194
  `filter={(g) => ...}` to slice the rows.
176
195
 
177
- ### `<CreditUtilization series? | baseUrl customerId customerToken from? to? granularity?; height? />`
196
+ ### `<CreditUtilization series? | customerId customerToken from? to? granularity?; height? />`
178
197
 
179
198
  Inline SVG line + area chart of credit balance over time, fed by
180
199
  `GET /v1/customer-portal/:id/credits/timeseries`.
181
200
 
182
- ### `<InvoiceHistory invoices? | baseUrl customerId customerToken />`
201
+ ### `<InvoiceHistory invoices? | customerId customerToken />`
183
202
 
184
203
  The invoices the customer received, newest first: date, number, status and
185
204
  amount, with a link to download each Stripe invoice's PDF and to its hosted
@@ -200,10 +219,7 @@ from `GET /v1/ledger/:id?grain=day`. `valueKey` picks the dimension
200
219
  // app/server.tsx (Next.js Server Component, or any backend handler)
201
220
  import { getV1Plans, MeterboxClient } from "@meterbox/node";
202
221
 
203
- new MeterboxClient({
204
- baseUrl: process.env.METERBOX_BASE_URL, // e.g. https://meterbox.ai
205
- apiKey: process.env.METERBOX_API_KEY,
206
- });
222
+ new MeterboxClient({ apiKey: process.env.METERBOX_API_KEY });
207
223
 
208
224
  export default async function PricingPage() {
209
225
  const { data } = await getV1Plans();
@@ -237,13 +253,11 @@ export function PortalBits({ customerJwt }) {
237
253
  return (
238
254
  <>
239
255
  <SubscriptionPreview
240
- baseUrl="https://meterbox.ai"
241
256
  customerId="cus_42"
242
257
  customerToken={customerJwt}
243
258
  planId="pro"
244
259
  />
245
260
  <CreditBalance
246
- baseUrl="https://meterbox.ai"
247
261
  customerId="cus_42"
248
262
  customerToken={customerJwt}
249
263
  threshold={10}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meterbox/react",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Embeddable React components for Meterbox: pricing tables, subscription preview, credit balance and usage charts. Presentational by default, with data fetched by your backend via @meterbox/node.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meterbox.ai",
@@ -17,7 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@meterbox/node": "0.1.0"
20
+ "@meterbox/node": "0.1.1"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": ">=17",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * <BillingDetailsButton baseUrl customerId customerToken returnUrl? label? />
2
+ * <BillingDetailsButton customerId customerToken returnUrl? label? />
3
3
  *
4
4
  * Sends the customer to Stripe's own Billing Portal to update their payment
5
5
  * method and billing details (address, tax IDs, email, name, phone) and see
@@ -17,6 +17,7 @@
17
17
 
18
18
  const React = require("react");
19
19
  const theme = require("./theme");
20
+ const { useBaseUrl } = require("./config");
20
21
  const { useI18n } = require("./i18n");
21
22
 
22
23
  const styles = {
@@ -50,7 +51,7 @@ async function openBillingDetails({ baseUrl, customerId, customerToken, returnUr
50
51
  }
51
52
 
52
53
  function BillingDetailsButton({
53
- baseUrl,
54
+ baseUrl: baseUrlProp,
54
55
  customerId,
55
56
  customerToken,
56
57
  returnUrl,
@@ -59,9 +60,10 @@ function BillingDetailsButton({
59
60
  onSession,
60
61
  onError,
61
62
  }) {
63
+ const baseUrl = useBaseUrl(baseUrlProp);
62
64
  const [busy, setBusy] = React.useState(false);
63
65
  const { t } = useI18n();
64
- const ready = baseUrl && customerId && customerToken;
66
+ const ready = customerId && customerToken;
65
67
 
66
68
  async function onClick() {
67
69
  setBusy(true);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * <CheckoutButton planId="pro" successUrl="..." cancelUrl="..."
3
- * customerId customerToken baseUrl billingInterval? />
3
+ * customerId customerToken billingInterval? />
4
4
  *
5
5
  * One-tap Stripe Checkout for a plan change. POSTs to
6
6
  * `/v1/customer-portal/:id/checkout` and redirects the browser to the
@@ -20,6 +20,7 @@
20
20
 
21
21
  const React = require("react");
22
22
  const theme = require("./theme");
23
+ const { useBaseUrl } = require("./config");
23
24
 
24
25
  const styles = {
25
26
  btn: {
@@ -74,13 +75,14 @@ function CheckoutButton({
74
75
  cancelUrl,
75
76
  billingInterval,
76
77
  label,
77
- baseUrl,
78
+ baseUrl: baseUrlProp,
78
79
  customerId,
79
80
  customerToken,
80
81
  fetch: fetchImpl,
81
82
  onSession,
82
83
  onError,
83
84
  }) {
85
+ const baseUrl = useBaseUrl(baseUrlProp);
84
86
  const [busy, setBusy] = React.useState(false);
85
87
 
86
88
  const onClick = React.useCallback(async () => {
@@ -118,7 +120,7 @@ function CheckoutButton({
118
120
  onError,
119
121
  ]);
120
122
 
121
- const ready = baseUrl && customerId && customerToken && planId && successUrl && cancelUrl;
123
+ const ready = customerId && customerToken && planId && successUrl && cancelUrl;
122
124
  return React.createElement(
123
125
  "button",
124
126
  {
@@ -9,8 +9,7 @@
9
9
  * — `{balance_usd, grants}`.
10
10
  *
11
11
  * 2. **Self-fetching** (browser-safe):
12
- * <CreditBalance baseUrl="https://meterbox.ai"
13
- * customerId="cus_42"
12
+ * <CreditBalance customerId="cus_42"
14
13
  * customerToken={jwt}
15
14
  * threshold={10} onTopUp={...} />
16
15
  * Fetches `GET /v1/customer-portal/:id/credits` with the customer JWT.
@@ -21,6 +20,7 @@
21
20
 
22
21
  const React = require("react");
23
22
  const theme = require("./theme");
23
+ const { useBaseUrl } = require("./config");
24
24
  const { useI18n } = require("./i18n");
25
25
 
26
26
  async function fetchBalance({ baseUrl, customerId, customerToken, fetchImpl }) {
@@ -72,12 +72,13 @@ function CreditBalance({
72
72
  balance,
73
73
  threshold,
74
74
  onTopUp,
75
- baseUrl,
75
+ baseUrl: baseUrlProp,
76
76
  customerId,
77
77
  customerToken,
78
78
  fetch: fetchImpl,
79
79
  }) {
80
- const selfFetch = !balance && baseUrl && customerId && customerToken;
80
+ const baseUrl = useBaseUrl(baseUrlProp);
81
+ const selfFetch = !balance && customerId && customerToken;
81
82
  const [fetched, setFetched] = React.useState(null);
82
83
  const [error, setError] = React.useState(null);
83
84
  const [loading, setLoading] = React.useState(false);
@@ -10,8 +10,7 @@
10
10
  * in as props.
11
11
  *
12
12
  * 2. **Self-fetching** (browser-safe):
13
- * <CreditGrantsTable baseUrl="https://meterbox.ai"
14
- * customerId="cus_42"
13
+ * <CreditGrantsTable customerId="cus_42"
15
14
  * customerToken={jwt} />
16
15
  * Fetches `GET /v1/customer-portal/:id/credits` directly with the
17
16
  * customer-scoped JWT. Re-fetches when `customerId` changes.
@@ -22,6 +21,7 @@
22
21
 
23
22
  const React = require("react");
24
23
  const theme = require("./theme");
24
+ const { useBaseUrl } = require("./config");
25
25
  const { useI18n } = require("./i18n");
26
26
 
27
27
  const styles = {
@@ -80,12 +80,13 @@ function CreditGrantsTable({
80
80
  grants,
81
81
  balance_usd,
82
82
  filter,
83
- baseUrl,
83
+ baseUrl: baseUrlProp,
84
84
  customerId,
85
85
  customerToken,
86
86
  fetch: fetchImpl,
87
87
  }) {
88
- const selfFetch = !grants && baseUrl && customerId && customerToken;
88
+ const baseUrl = useBaseUrl(baseUrlProp);
89
+ const selfFetch = !grants && customerId && customerToken;
89
90
  const [fetched, setFetched] = React.useState(null);
90
91
  const [error, setError] = React.useState(null);
91
92
  const [loading, setLoading] = React.useState(false);
@@ -11,7 +11,7 @@
11
11
  * <CreditUtilization series={timeseries} />
12
12
  *
13
13
  * 2. **Self-fetching**:
14
- * <CreditUtilization baseUrl="..." customerId="cus_42"
14
+ * <CreditUtilization customerId="cus_42"
15
15
  * customerToken={jwt}
16
16
  * from="2026-05-01" to="2026-06-01"
17
17
  * granularity="day" />
@@ -19,6 +19,7 @@
19
19
 
20
20
  const React = require("react");
21
21
  const theme = require("./theme");
22
+ const { useBaseUrl } = require("./config");
22
23
  const { useI18n } = require("./i18n");
23
24
 
24
25
  const styles = {
@@ -71,7 +72,7 @@ async function fetchTimeseries({
71
72
 
72
73
  function CreditUtilization({
73
74
  series,
74
- baseUrl,
75
+ baseUrl: baseUrlProp,
75
76
  customerId,
76
77
  customerToken,
77
78
  from,
@@ -80,7 +81,8 @@ function CreditUtilization({
80
81
  height = 120,
81
82
  fetch: fetchImpl,
82
83
  }) {
83
- const selfFetch = !series && baseUrl && customerId && customerToken;
84
+ const baseUrl = useBaseUrl(baseUrlProp);
85
+ const selfFetch = !series && customerId && customerToken;
84
86
  const [fetched, setFetched] = React.useState(null);
85
87
  const [error, setError] = React.useState(null);
86
88
  const [loading, setLoading] = React.useState(false);
@@ -7,14 +7,14 @@
7
7
  * 1. **Presentational**: <InvoiceHistory invoices={...} />, with the
8
8
  * `invoices` array from `GET /v1/customer-portal/:id/invoices`.
9
9
  * 2. **Self-fetching** (browser-safe):
10
- * <InvoiceHistory baseUrl="https://meterbox.ai"
11
- * customerId="cus_42"
10
+ * <InvoiceHistory customerId="cus_42"
12
11
  * customerToken={jwt} />
13
12
  * Fetches that endpoint with the customer-scoped JWT.
14
13
  */
15
14
 
16
15
  const React = require("react");
17
16
  const theme = require("./theme");
17
+ const { useBaseUrl } = require("./config");
18
18
  const { useI18n } = require("./i18n");
19
19
 
20
20
  const styles = {
@@ -69,8 +69,9 @@ async function fetchInvoices({ baseUrl, customerId, customerToken, fetchImpl })
69
69
  return json.invoices || [];
70
70
  }
71
71
 
72
- function InvoiceHistory({ invoices, baseUrl, customerId, customerToken, fetch: fetchImpl }) {
73
- const selfFetch = !invoices && baseUrl && customerId && customerToken;
72
+ function InvoiceHistory({ invoices, baseUrl: baseUrlProp, customerId, customerToken, fetch: fetchImpl }) {
73
+ const baseUrl = useBaseUrl(baseUrlProp);
74
+ const selfFetch = !invoices && customerId && customerToken;
74
75
  const [fetched, setFetched] = React.useState(null);
75
76
  const [error, setError] = React.useState(null);
76
77
  const { t, locale, date } = useI18n();
@@ -9,8 +9,7 @@
9
9
  * `@meterbox/node` and passes `outcomes` in as a prop.
10
10
  *
11
11
  * 2. **Self-fetching** (browser-safe):
12
- * <OutcomeHistory baseUrl="https://meterbox.ai"
13
- * customerId="cus_42"
12
+ * <OutcomeHistory customerId="cus_42"
14
13
  * customerToken={jwt} />
15
14
  * Fetches `GET /v1/customer-portal/:id/outcomes` directly with the
16
15
  * customer-scoped JWT. Re-fetches when `customerId` changes.
@@ -26,6 +25,7 @@
26
25
 
27
26
  const React = require("react");
28
27
  const theme = require("./theme");
28
+ const { useBaseUrl } = require("./config");
29
29
 
30
30
  const styles = {
31
31
  card: {
@@ -96,12 +96,13 @@ async function fetchOutcomes({ baseUrl, customerId, customerToken, fetchImpl })
96
96
  function OutcomeHistory({
97
97
  outcomes,
98
98
  filter,
99
- baseUrl,
99
+ baseUrl: baseUrlProp,
100
100
  customerId,
101
101
  customerToken,
102
102
  fetch: fetchImpl,
103
103
  }) {
104
- const selfFetch = !outcomes && baseUrl && customerId && customerToken;
104
+ const baseUrl = useBaseUrl(baseUrlProp);
105
+ const selfFetch = !outcomes && customerId && customerToken;
105
106
  const [fetched, setFetched] = React.useState(null);
106
107
  const [error, setError] = React.useState(null);
107
108
  const [loading, setLoading] = React.useState(false);
package/src/Paywall.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * <Paywall feature="vision" customerId="..." customerToken="..." baseUrl="...">
2
+ * <Paywall feature="vision" customerId="..." customerToken="...">
3
3
  * <YourFeature />
4
4
  * </Paywall>
5
5
  *
@@ -8,7 +8,7 @@
8
8
  * prompt). Self-fetches from `GET /v1/customer-portal/:id/entitlements`.
9
9
  *
10
10
  * Modes:
11
- * • **Self-fetching** (default) — provide `baseUrl`, `customerId`,
11
+ * • **Self-fetching** (default) — provide `customerId` and
12
12
  * `customerToken`. Fetches the entitlements once on mount and again
13
13
  * whenever the customer or token changes.
14
14
  * • **Presentational** — pass `features` (array of feature ids the customer
@@ -23,6 +23,7 @@
23
23
 
24
24
  const React = require("react");
25
25
  const theme = require("./theme");
26
+ const { useBaseUrl } = require("./config");
26
27
 
27
28
  const defaultStyles = {
28
29
  fallback: {
@@ -67,13 +68,14 @@ function Paywall({
67
68
  children,
68
69
  fallback,
69
70
  onUpgradeClick,
70
- baseUrl,
71
+ baseUrl: baseUrlProp,
71
72
  customerId,
72
73
  customerToken,
73
74
  fetch: fetchImpl,
74
75
  failOpen = true,
75
76
  }) {
76
- const selfFetch = !features && baseUrl && customerId && customerToken;
77
+ const baseUrl = useBaseUrl(baseUrlProp);
78
+ const selfFetch = !features && customerId && customerToken;
77
79
  const [fetched, setFetched] = React.useState(null);
78
80
  const [error, setError] = React.useState(null);
79
81
 
@@ -17,7 +17,7 @@
17
17
  * (e.g. Meterbox's own Settings page proxies through its control
18
18
  * plane, session-authenticated, holding no customer JWT at all).
19
19
  *
20
- * 2. **Self-fetching** — `baseUrl` + `customerId` + `customerToken` +
20
+ * 2. **Self-fetching** — `customerId` + `customerToken` +
21
21
  * `planId`, no `onConfirm`/`onCancelScheduled` supplied. The panel
22
22
  * fetches its own preview AND posts the confirm/cancel actions
23
23
  * directly to `/v1/customer-portal/:id/subscription/change` and
@@ -38,6 +38,7 @@
38
38
 
39
39
  const React = require("react");
40
40
  const theme = require("./theme");
41
+ const { useBaseUrl } = require("./config");
41
42
  const SubscriptionPreview = require("./SubscriptionPreview");
42
43
  const { useI18n } = require("./i18n");
43
44
 
@@ -125,7 +126,7 @@ function PlanChangeCard({
125
126
  preview,
126
127
  scheduledChange,
127
128
  allowSchedule = true,
128
- baseUrl,
129
+ baseUrl: baseUrlProp,
129
130
  customerId,
130
131
  customerToken,
131
132
  planId,
@@ -135,8 +136,9 @@ function PlanChangeCard({
135
136
  onCancelScheduled,
136
137
  onChanged,
137
138
  }) {
139
+ const baseUrl = useBaseUrl(baseUrlProp);
138
140
  const fetcher = fetchImpl || globalThis.fetch;
139
- const canSelfFetch = Boolean(baseUrl && customerId && customerToken);
141
+ const canSelfFetch = Boolean(customerId && customerToken);
140
142
  const [busy, setBusy] = React.useState(false);
141
143
  const [err, setErr] = React.useState(null);
142
144
  const [message, setMessage] = React.useState(null);
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * <PricingTable plans={...} currentPlanId? onSelect? />
3
- * <PricingTable baseUrl publishableKey />
3
+ * <PricingTable publishableKey />
4
4
  *
5
5
  * Renders the tenant's plan catalog as a comparison grid. `plans` is the
6
6
  * array your backend fetched from `GET /v1/plans` (via
7
7
  * `@meterbox/node`'s `getV1Plans`). Or, on a public page with no backend of
8
- * its own, pass `baseUrl` + `publishableKey` (`mb_pub_...`, Settings > API
8
+ * its own, pass `publishableKey` (`mb_pub_...`, Settings > API
9
9
  * keys) and it reads the public pricing snapshot instead
10
10
  * (`GET /v1/catalog/pricing-page`: published plans, display fields only).
11
11
  * Highlights `currentPlanId` if
@@ -35,12 +35,22 @@
35
35
  * each plan's button is its call-to-action link (`customerEmail` fills
36
36
  * {CUSTOMER_EMAIL} in it).
37
37
  *
38
- * A plan's list is its `bullets` (the snapshot and the customer portal's plan
39
- * list: the tenant's own bullets, else its features' labels), else its
40
- * `display_features`, else its feature ids made readable; its included
41
- * credits come first ("1,500 Bits a month"). A snapshot plan's `promotion`
42
- * shows its monthly price with the regular one struck through, and how to
43
- * get it ("Save 50% with code LAUNCH50 for 3 months").
38
+ * A plan's list is its `bullet_details` (the API's plans, the snapshot and the
39
+ * customer portal's plan list all carry it: the tenant's own bullets, else
40
+ * each feature by its label with its description under it, by its
41
+ * description when it has no label, by its id when it has neither), else
42
+ * its `bullets`, else its `display_features`, else its feature ids; its
43
+ * included credits come first ("1,500 Bits a month"). A snapshot plan's
44
+ * `promotion` shows its monthly price with the regular one struck through,
45
+ * and how to get it ("Save 50% with code LAUNCH50 for 3 months").
46
+ *
47
+ * A plan whose `stripe_price_monthly_usd` is null has no fixed price and
48
+ * shows "Custom". A plan's `cta.label` names its button, and its `cta.url`
49
+ * may also be a path on your own site ("/signup?plan=pro"). A plan's
50
+ * `badges` add to its `badge`. For a catalog you manage rather than sell
51
+ * from: `selectedPlanId` + `onPlanClick(plan)` make each card selectable,
52
+ * and `renderFooter(plan)` replaces each card's button with your own
53
+ * content (a click inside it doesn't select the card).
44
54
  *
45
55
  * Pure presentational + inline styles — no CSS pipeline required from the
46
56
  * tenant.
@@ -48,6 +58,7 @@
48
58
 
49
59
  const React = require("react");
50
60
  const theme = require("./theme");
61
+ const { useBaseUrl } = require("./config");
51
62
  const { brandingVars } = require("./branding");
52
63
  const { useI18n } = require("./i18n");
53
64
 
@@ -70,8 +81,8 @@ const styles = {
70
81
  padding: 4,
71
82
  width: "fit-content",
72
83
  margin: "0 auto",
73
- background: "#f3f4f6",
74
- border: "1px solid #e5e7eb",
84
+ background: theme.accentTint(6),
85
+ border: `1px solid ${theme.border}`,
75
86
  borderRadius: 999,
76
87
  },
77
88
  toggleBtn: {
@@ -79,7 +90,7 @@ const styles = {
79
90
  borderRadius: 999,
80
91
  border: "none",
81
92
  background: "transparent",
82
- color: "#4b5563",
93
+ color: theme.text,
83
94
  fontSize: 13,
84
95
  fontWeight: 600,
85
96
  fontFamily: theme.font,
@@ -94,7 +105,7 @@ const styles = {
94
105
  color: theme.text,
95
106
  },
96
107
  card: {
97
- border: "1px solid #e5e7eb",
108
+ border: `1px solid ${theme.border}`,
98
109
  borderRadius: 12,
99
110
  padding: 20,
100
111
  background: theme.card,
@@ -116,7 +127,7 @@ const styles = {
116
127
  cursor: "pointer",
117
128
  },
118
129
  ctaCurrent: {
119
- background: "#e5e7eb",
130
+ background: theme.accentTint(12),
120
131
  color: theme.text,
121
132
  border: "1px solid transparent",
122
133
  cursor: "default",
@@ -128,9 +139,10 @@ const styles = {
128
139
  display: "grid",
129
140
  gap: 4,
130
141
  fontSize: 12,
131
- borderTop: "1px solid #e5e7eb",
142
+ borderTop: `1px solid ${theme.border}`,
132
143
  paddingTop: 10,
133
144
  },
145
+ bulletDescription: { fontSize: 12, opacity: 0.65, marginLeft: 12 },
134
146
  badge: {
135
147
  fontSize: 11,
136
148
  fontWeight: 600,
@@ -138,15 +150,20 @@ const styles = {
138
150
  color: "#fff",
139
151
  padding: "2px 8px",
140
152
  borderRadius: 999,
141
- alignSelf: "flex-start",
142
153
  },
154
+ badges: { display: "flex", flexWrap: "wrap", gap: 6 },
143
155
  };
144
156
 
145
- /** What a plan lists: its bullets, else its own display text, else its feature ids. */
157
+ /**
158
+ * What a plan lists, as `{ text, description }`: its `bullet_details`, else
159
+ * its bullets, else its own display text, else its feature ids.
160
+ */
146
161
  function planBullets(plan) {
147
- if (Array.isArray(plan.bullets)) return plan.bullets;
148
- if (plan.display_features?.length) return plan.display_features;
149
- return (plan.features || []).map((f) => f.replace(/_/g, " "));
162
+ if (Array.isArray(plan.bullet_details)) return plan.bullet_details;
163
+ let texts = plan.features || [];
164
+ if (Array.isArray(plan.bullets)) texts = plan.bullets;
165
+ else if (plan.display_features?.length) texts = plan.display_features;
166
+ return texts.map((text) => ({ text, description: null }));
150
167
  }
151
168
 
152
169
  /** "1,500 Bits a month", or "$15 of credit a month" without a credit unit. */
@@ -242,8 +259,8 @@ function PlanUsage({ usage }) {
242
259
  );
243
260
  }
244
261
 
245
- // A plan's call-to-action link from the snapshot, {CUSTOMER_EMAIL} filled in;
246
- // null unless it's an http(s), mailto: or tel: link.
262
+ // A plan's call-to-action link, {CUSTOMER_EMAIL} filled in; null unless it's
263
+ // an http(s), mailto: or tel: link, or a path on this site.
247
264
  function ctaLink(plan, customerEmail) {
248
265
  if (!plan.cta?.url) return null;
249
266
  const email = encodeURIComponent(customerEmail || "");
@@ -252,7 +269,7 @@ function ctaLink(plan, customerEmail) {
252
269
  .join(email)
253
270
  .split("%7BCUSTOMER_EMAIL%7D")
254
271
  .join(email);
255
- return /^(https?:|mailto:|tel:)/i.test(url) ? { url, label: plan.cta.label } : null;
272
+ return /^(https?:|mailto:|tel:|\/(?!\/))/i.test(url) ? { url, label: plan.cta.label } : null;
256
273
  }
257
274
 
258
275
  /** A plan from the public snapshot, in the shape the table renders. */
@@ -263,6 +280,7 @@ function fromSnapshot(p) {
263
280
  description: p.description || null,
264
281
  features: p.features || [],
265
282
  bullets: p.bullets || null,
283
+ bullet_details: p.bullet_details || null,
266
284
  included_credits: p.included_credits || null,
267
285
  promotion: p.promotion || null,
268
286
  stripe_price_monthly_usd: p.price ? p.price.monthly_usd : 0,
@@ -291,13 +309,17 @@ function PricingTable({
291
309
  currentPlanId,
292
310
  currency = "USD",
293
311
  onSelect,
312
+ selectedPlanId,
313
+ onPlanClick,
314
+ renderFooter,
294
315
  customerEmail,
295
316
  branding,
296
- baseUrl,
317
+ baseUrl: baseUrlProp,
297
318
  publishableKey,
298
319
  fetch: fetchImpl,
299
320
  }) {
300
- const selfFetch = !Array.isArray(plans) && !!baseUrl && !!publishableKey;
321
+ const baseUrl = useBaseUrl(baseUrlProp);
322
+ const selfFetch = !Array.isArray(plans) && !!publishableKey;
301
323
  const [fetched, setFetched] = React.useState(null);
302
324
  const [billingInterval, setBillingInterval] = React.useState("monthly");
303
325
  const i18n = useI18n();
@@ -361,33 +383,121 @@ function PricingTable({
361
383
  { style: styles.grid },
362
384
  list.map((plan) => {
363
385
  const isCurrent = plan.id === currentPlanId;
386
+ const isSelected = plan.id === selectedPlanId;
364
387
  const localized = (plan.localized_prices || []).find(
365
388
  (p) => (p.currency || "").toUpperCase() === currency.toUpperCase(),
366
389
  );
367
390
  const monthlyAmount = localized ? localized.monthly_amount : plan.stripe_price_monthly_usd;
368
391
  const displayCurrency = localized ? localized.currency : "USD";
392
+ // No fixed price: "Custom", with no period, annual total or promotion.
393
+ const custom = monthlyAmount == null;
369
394
  // Annual only applies when THIS plan offers it — a plan without
370
395
  // annual_free_months always shows its monthly price, even while the
371
396
  // toggle above is set to "Annual" for its siblings.
372
397
  const annual = billingInterval === "annual" ? annualPriceUsd(plan) : null;
373
398
  const link = !onSelect && !isCurrent ? ctaLink(plan, customerEmail) : null;
374
399
  // A promotion is on the monthly USD price.
375
- const promo = annual == null && displayCurrency === "USD" ? plan.promotion : null;
400
+ const promo =
401
+ !custom && annual == null && displayCurrency === "USD" ? plan.promotion : null;
376
402
  const bullets = [
377
- ...(plan.included_credits ? [creditsText(i18n, plan.included_credits)] : []),
403
+ ...(plan.included_credits
404
+ ? [{ text: creditsText(i18n, plan.included_credits), description: null }]
405
+ : []),
378
406
  ...planBullets(plan),
379
407
  ];
408
+ const badges = [isCurrent ? t("pricing.current") : plan.badge, ...(plan.badges || [])];
409
+ const select = onPlanClick ? () => onPlanClick(plan) : null;
410
+ const outlined = isCurrent || isSelected || plan.highlight;
411
+ let price;
412
+ if (custom) {
413
+ price = React.createElement("span", { style: styles.price }, t("pricing.custom"));
414
+ } else {
415
+ price = [
416
+ promo &&
417
+ React.createElement(
418
+ "s",
419
+ { key: "was", style: styles.wasPrice },
420
+ money(monthlyAmount),
421
+ ),
422
+ React.createElement(
423
+ "span",
424
+ { key: "price", style: styles.price },
425
+ money(
426
+ promo ? promo.monthly_usd : annual != null ? annual : monthlyAmount,
427
+ displayCurrency,
428
+ ),
429
+ ),
430
+ React.createElement(
431
+ "span",
432
+ { key: "period", style: styles.perMonth },
433
+ annual != null ? t("pricing.billedAnnually") : t("pricing.perMonth"),
434
+ ),
435
+ ];
436
+ }
437
+ let action;
438
+ if (renderFooter) {
439
+ // Its own controls: a click inside it doesn't select the card.
440
+ action = React.createElement(
441
+ "div",
442
+ { style: { marginTop: "auto" }, onClick: select ? (e) => e.stopPropagation() : null },
443
+ renderFooter(plan),
444
+ );
445
+ } else if (link) {
446
+ action = React.createElement(
447
+ "a",
448
+ {
449
+ href: link.url,
450
+ style: { ...styles.cta, textAlign: "center", textDecoration: "none" },
451
+ },
452
+ link.label,
453
+ );
454
+ } else {
455
+ action = React.createElement(
456
+ "button",
457
+ {
458
+ type: "button",
459
+ style: isCurrent ? { ...styles.cta, ...styles.ctaCurrent } : styles.cta,
460
+ disabled: isCurrent,
461
+ onClick: () => (onSelect ? onSelect(plan, billingInterval) : undefined),
462
+ "aria-label": t(isCurrent ? "pricing.currentlyOn" : "pricing.choose", {
463
+ plan: plan.name || plan.id,
464
+ }),
465
+ },
466
+ isCurrent ? t("pricing.currentPlan") : plan.cta?.label || t("pricing.choosePlan"),
467
+ );
468
+ }
380
469
  return React.createElement(
381
470
  "div",
382
471
  {
383
472
  key: plan.id,
384
- style:
385
- isCurrent || plan.highlight ? { ...styles.card, ...styles.cardCurrent } : styles.card,
473
+ style: {
474
+ ...styles.card,
475
+ ...(outlined ? styles.cardCurrent : null),
476
+ ...(select ? { cursor: "pointer" } : null),
477
+ },
478
+ ...(select && {
479
+ role: "button",
480
+ tabIndex: 0,
481
+ "aria-pressed": isSelected,
482
+ onClick: select,
483
+ onKeyDown: (e) => {
484
+ if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
485
+ e.preventDefault();
486
+ select();
487
+ }
488
+ },
489
+ }),
386
490
  },
387
- isCurrent && React.createElement("span", { style: styles.badge }, t("pricing.current")),
388
- !isCurrent &&
389
- plan.badge &&
390
- React.createElement("span", { style: styles.badge }, plan.badge),
491
+ badges.some(Boolean) &&
492
+ React.createElement(
493
+ "div",
494
+ { style: styles.badges },
495
+ badges
496
+ .filter(Boolean)
497
+ .map((b, i) =>
498
+ React.createElement("span", { key: `${i}:${b}`, style: styles.badge }, b),
499
+ ),
500
+ ),
391
501
  React.createElement("h3", { style: styles.name }, plan.name || plan.id),
392
502
  plan.description &&
393
503
  React.createElement(
@@ -395,24 +505,7 @@ function PricingTable({
395
505
  { style: { fontSize: 13, opacity: 0.75, margin: 0 } },
396
506
  plan.description,
397
507
  ),
398
- React.createElement(
399
- "div",
400
- null,
401
- promo && React.createElement("s", { style: styles.wasPrice }, money(monthlyAmount)),
402
- React.createElement(
403
- "span",
404
- { style: styles.price },
405
- money(
406
- promo ? promo.monthly_usd : annual != null ? annual : monthlyAmount,
407
- displayCurrency,
408
- ),
409
- ),
410
- React.createElement(
411
- "span",
412
- { style: styles.perMonth },
413
- annual != null ? t("pricing.billedAnnually") : t("pricing.perMonth"),
414
- ),
415
- ),
508
+ React.createElement("div", null, price),
416
509
  promo && React.createElement("div", { style: styles.promo }, promoText(i18n, promo)),
417
510
  plan.trial_days > 0 &&
418
511
  React.createElement(
@@ -424,31 +517,19 @@ function PricingTable({
424
517
  React.createElement(
425
518
  "ul",
426
519
  { style: styles.features },
427
- bullets.map((b, i) => React.createElement("li", { key: `${i}:${b}` }, `• ${b}`)),
520
+ bullets.map((b, i) =>
521
+ React.createElement(
522
+ "li",
523
+ { key: `${i}:${b.text}` },
524
+ React.createElement("span", { "aria-hidden": true }, "• "),
525
+ React.createElement("span", null, b.text),
526
+ b.description &&
527
+ React.createElement("div", { style: styles.bulletDescription }, b.description),
528
+ ),
529
+ ),
428
530
  ),
429
531
  plan.usage && React.createElement(PlanUsage, { usage: plan.usage }),
430
- link
431
- ? React.createElement(
432
- "a",
433
- {
434
- href: link.url,
435
- style: { ...styles.cta, textAlign: "center", textDecoration: "none" },
436
- },
437
- link.label,
438
- )
439
- : React.createElement(
440
- "button",
441
- {
442
- type: "button",
443
- style: isCurrent ? { ...styles.cta, ...styles.ctaCurrent } : styles.cta,
444
- disabled: isCurrent,
445
- onClick: () => (onSelect ? onSelect(plan, billingInterval) : undefined),
446
- "aria-label": t(isCurrent ? "pricing.currentlyOn" : "pricing.choose", {
447
- plan: plan.name || plan.id,
448
- }),
449
- },
450
- isCurrent ? t("pricing.currentPlan") : t("pricing.choosePlan"),
451
- ),
532
+ action,
452
533
  );
453
534
  }),
454
535
  ),
@@ -10,8 +10,7 @@
10
10
  * key) and passes the body in as `preview`.
11
11
  *
12
12
  * 2. **Self-fetching** (browser-safe):
13
- * <SubscriptionPreview baseUrl="https://meterbox.ai"
14
- * customerId="cus_42"
13
+ * <SubscriptionPreview customerId="cus_42"
15
14
  * customerToken={jwt}
16
15
  * planId="pro" />
17
16
  * The component calls `POST /v1/customer-portal/:id/subscription/preview`
@@ -22,6 +21,7 @@
22
21
 
23
22
  const React = require("react");
24
23
  const theme = require("./theme");
24
+ const { useBaseUrl } = require("./config");
25
25
  const { useI18n } = require("./i18n");
26
26
 
27
27
  const styles = {
@@ -76,14 +76,15 @@ async function fetchPreview({ baseUrl, customerId, customerToken, planId, planVe
76
76
 
77
77
  function SubscriptionPreview({
78
78
  preview,
79
- baseUrl,
79
+ baseUrl: baseUrlProp,
80
80
  customerId,
81
81
  customerToken,
82
82
  planId,
83
83
  planVersion,
84
84
  fetch: fetchImpl,
85
85
  }) {
86
- const selfFetch = !preview && baseUrl && customerId && customerToken && planId;
86
+ const baseUrl = useBaseUrl(baseUrlProp);
87
+ const selfFetch = !preview && customerId && customerToken && planId;
87
88
  const [fetched, setFetched] = React.useState(null);
88
89
  const [error, setError] = React.useState(null);
89
90
  const [loading, setLoading] = React.useState(false);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * <TrialBanner customerId customerToken baseUrl onConvert={(planId) => …} />
2
+ * <TrialBanner customerId customerToken onConvert={(planId) => …} />
3
3
  *
4
4
  * Renders a thin banner showing time remaining on the customer's trial, with
5
5
  * a "Convert now" CTA that the host can wire to its checkout flow. Hides
@@ -11,6 +11,7 @@
11
11
 
12
12
  const React = require("react");
13
13
  const theme = require("./theme");
14
+ const { useBaseUrl } = require("./config");
14
15
 
15
16
  const styles = {
16
17
  banner: {
@@ -55,13 +56,14 @@ function daysRemaining(ends) {
55
56
  function TrialBanner({
56
57
  trialEndsAt,
57
58
  status,
58
- baseUrl,
59
+ baseUrl: baseUrlProp,
59
60
  customerId,
60
61
  customerToken,
61
62
  fetch: fetchImpl,
62
63
  onConvert,
63
64
  }) {
64
- const selfFetch = (!trialEndsAt || !status) && baseUrl && customerId && customerToken;
65
+ const baseUrl = useBaseUrl(baseUrlProp);
66
+ const selfFetch = (!trialEndsAt || !status) && customerId && customerToken;
65
67
  const [me, setMe] = React.useState(null);
66
68
 
67
69
  React.useEffect(() => {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * <UsageProgress metric="input_tokens_per_month" customerId customerToken baseUrl />
2
+ * <UsageProgress metric="input_tokens_per_month" customerId customerToken />
3
3
  *
4
4
  * Real-time bar chart of consumption against the customer's current plan
5
5
  * limit. Self-fetches from `GET /v1/customer-portal/:id/usage`, or accept
@@ -17,6 +17,7 @@
17
17
 
18
18
  const React = require("react");
19
19
  const theme = require("./theme");
20
+ const { useBaseUrl } = require("./config");
20
21
 
21
22
  const styles = {
22
23
  wrap: {
@@ -58,12 +59,13 @@ function UsageProgress({
58
59
  limits,
59
60
  warnAt = 0.8,
60
61
  dangerAt = 1.0,
61
- baseUrl,
62
+ baseUrl: baseUrlProp,
62
63
  customerId,
63
64
  customerToken,
64
65
  fetch: fetchImpl,
65
66
  }) {
66
- const selfFetch = (!usage || !limits) && baseUrl && customerId && customerToken;
67
+ const baseUrl = useBaseUrl(baseUrlProp);
68
+ const selfFetch = (!usage || !limits) && customerId && customerToken;
67
69
  const [fetched, setFetched] = React.useState(null);
68
70
  const [stale, setStale] = React.useState(false);
69
71
 
package/src/config.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * config.js — where the components reach Meterbox.
3
+ *
4
+ * <MeterboxProvider baseUrl="https://billing.example.com">…</MeterboxProvider>
5
+ *
6
+ * sets the API's base URL once for every component inside it. Without one,
7
+ * they call https://meterbox.ai; a component's own `baseUrl` prop still wins.
8
+ */
9
+
10
+ const React = require("react");
11
+
12
+ const DEFAULT_BASE_URL = "https://meterbox.ai";
13
+
14
+ const BaseUrlContext = React.createContext(null);
15
+
16
+ function MeterboxProvider({ baseUrl, children }) {
17
+ return React.createElement(BaseUrlContext.Provider, { value: baseUrl || null }, children);
18
+ }
19
+
20
+ /** The base URL to call, without a trailing slash: `override`, else the provider's, else meterbox.ai. */
21
+ function useBaseUrl(override) {
22
+ const provided = React.useContext(BaseUrlContext);
23
+ return String(override || provided || DEFAULT_BASE_URL).replace(/\/+$/, "");
24
+ }
25
+
26
+ module.exports = { MeterboxProvider, useBaseUrl, DEFAULT_BASE_URL };
package/src/i18n.js CHANGED
@@ -73,6 +73,7 @@ const en = {
73
73
  "pricing.choose": "Choose {plan}",
74
74
  "pricing.currentPlan": "Current plan",
75
75
  "pricing.choosePlan": "Choose plan",
76
+ "pricing.custom": "Custom",
76
77
  "pricing.perMonth": "/ month",
77
78
  "pricing.billedAnnually": "billed annually",
78
79
  "pricing.trial": "{days}-day free trial",
@@ -223,6 +224,7 @@ const es = {
223
224
  "pricing.choose": "Elegir {plan}",
224
225
  "pricing.currentPlan": "Plan actual",
225
226
  "pricing.choosePlan": "Elegir plan",
227
+ "pricing.custom": "Personalizado",
226
228
  "pricing.perMonth": "/ mes",
227
229
  "pricing.billedAnnually": "facturado anualmente",
228
230
  "pricing.trial": "Prueba gratuita de {days} días",
@@ -373,6 +375,7 @@ const fr = {
373
375
  "pricing.choose": "Choisir {plan}",
374
376
  "pricing.currentPlan": "Forfait actuel",
375
377
  "pricing.choosePlan": "Choisir ce forfait",
378
+ "pricing.custom": "Sur mesure",
376
379
  "pricing.perMonth": "/ mois",
377
380
  "pricing.billedAnnually": "facturé annuellement",
378
381
  "pricing.trial": "Essai gratuit de {days} jours",
@@ -523,6 +526,7 @@ const de = {
523
526
  "pricing.choose": "{plan} wählen",
524
527
  "pricing.currentPlan": "Aktueller Tarif",
525
528
  "pricing.choosePlan": "Tarif wählen",
529
+ "pricing.custom": "Individuell",
526
530
  "pricing.perMonth": "/ Monat",
527
531
  "pricing.billedAnnually": "jährlich abgerechnet",
528
532
  "pricing.trial": "{days} Tage kostenlos testen",
package/src/index.js CHANGED
@@ -11,6 +11,10 @@
11
11
  * `/v1/customer-portal/*` endpoints using a short-lived customer-scoped
12
12
  * JWT minted server-side (`POST /v1/tokens/:id`).
13
13
  *
14
+ * Base URL: the components call https://meterbox.ai; `<MeterboxProvider
15
+ * baseUrl>` points every component inside it elsewhere, and a component's own
16
+ * `baseUrl` prop wins over both.
17
+ *
14
18
  * Branding: `<BrandingProvider branding>` themes every component inside it
15
19
  * with the tenant's branding (GET /v1/settings/branding); `theme` is the
16
20
  * --mbx-* CSS variables they read, for matching your own elements.
@@ -43,6 +47,7 @@ const CheckoutButton = require("./CheckoutButton");
43
47
  const BillingDetailsButton = require("./BillingDetailsButton");
44
48
  const { BrandingProvider, useBranding, brandingVars, logoUrl } = require("./branding");
45
49
  const { LocaleProvider, useI18n } = require("./i18n");
50
+ const { MeterboxProvider, useBaseUrl } = require("./config");
46
51
  const theme = require("./theme");
47
52
 
48
53
  module.exports = {
@@ -67,6 +72,8 @@ module.exports = {
67
72
  logoUrl,
68
73
  LocaleProvider,
69
74
  useI18n,
75
+ MeterboxProvider,
76
+ useBaseUrl,
70
77
  theme,
71
78
  sdk,
72
79
  MeterboxClient: sdk.MeterboxClient,
package/src/theme.js CHANGED
@@ -13,6 +13,7 @@ module.exports = {
13
13
  accentTint: (pct = 12) => `color-mix(in srgb, ${accent} ${pct}%, transparent)`,
14
14
  text: "var(--mbx-text, #111)",
15
15
  card: "var(--mbx-card, #fff)",
16
+ border: "var(--mbx-border, #e5e7eb)",
16
17
  font: "var(--mbx-font, system-ui, -apple-system, sans-serif)",
17
18
  // Primary buttons: filled with the accent, or outlined (branding's button_style).
18
19
  button: {