@meterbox/react 0.1.12 → 0.1.14
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 +9 -4
- package/package.json +2 -2
- package/src/PricingTable.js +27 -7
- package/src/i18n.js +4 -0
package/README.md
CHANGED
|
@@ -63,16 +63,21 @@ whichever interval was selected, ready to hand straight to
|
|
|
63
63
|
`<CheckoutButton billingInterval>`. `PricingTable.annualPriceUsd(plan)` is
|
|
64
64
|
exposed as a static if you need the same total outside the grid.
|
|
65
65
|
|
|
66
|
+
`PricingTable.fetchPricingPage({ publishableKey, baseUrl? })` resolves to the public pricing
|
|
67
|
+
snapshot as `{ plans, branding }`, each plan in the shape `<PricingTable plans>` takes: for a page
|
|
68
|
+
that uses the same plans elsewhere (a sign-up form's plan picker), or shows its own until the live
|
|
69
|
+
ones arrive.
|
|
70
|
+
|
|
66
71
|
From the snapshot, the featured plan is highlighted with its badge ("Most
|
|
67
72
|
popular"), a plan's free trial shows as "14-day free trial", and, without
|
|
68
73
|
`onSelect`, each plan's button is its own call-to-action link (e.g. Enterprise
|
|
69
74
|
to a contact page); `customerEmail` fills `{CUSTOMER_EMAIL}` in it.
|
|
70
75
|
|
|
71
76
|
Plans from the snapshot (or the customer portal's plan list) also carry
|
|
72
|
-
`usage
|
|
73
|
-
pay for usage: the amounts included each month,
|
|
74
|
-
(billed, stopped until next month, or an upgrade), and
|
|
75
|
-
and output rates per 1M tokens, tier ladders included.
|
|
77
|
+
`usage`. With `showUsage` (off by default), each card then shows what an AI
|
|
78
|
+
product's customers actually pay for usage: the amounts included each month,
|
|
79
|
+
what happens past them (billed, stopped until next month, or an upgrade), and
|
|
80
|
+
every model's input and output rates per 1M tokens, tier ladders included.
|
|
76
81
|
|
|
77
82
|
A plan lists its included credits first ("1,500 Bits a month", in the tenant's credit unit), then
|
|
78
83
|
its `bullet_details`, which `GET /v1/plans`, the pricing snapshot and the customer portal's plans
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meterbox/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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.
|
|
20
|
+
"@meterbox/node": "0.1.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=17",
|
package/src/PricingTable.js
CHANGED
|
@@ -21,17 +21,18 @@
|
|
|
21
21
|
* total divided back into a misleading "$X/mo" figure — a shopper who
|
|
22
22
|
* commits annually is billed once for the year, not monthly.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
* list carry it) also shows its
|
|
26
|
-
* and its models' input and output
|
|
27
|
-
* included.
|
|
24
|
+
* With `showUsage` (off by default), a plan with `usage` (the pricing
|
|
25
|
+
* snapshot and the customer portal's plan list carry it) also shows its
|
|
26
|
+
* included amounts, what happens past them, and its models' input and output
|
|
27
|
+
* rates per 1M tokens, tier ladders included.
|
|
28
28
|
*
|
|
29
29
|
* Self-fetching, it takes the tenant's branding (Settings → Branding) from
|
|
30
30
|
* the snapshot; `branding` overrides it, and a <BrandingProvider> around it
|
|
31
31
|
* applies when neither is set.
|
|
32
32
|
*
|
|
33
33
|
* From the snapshot, the featured plan is highlighted with its `badge`, a
|
|
34
|
-
* plan's `trial_days` shows as "14-day free trial",
|
|
34
|
+
* plan's `trial_days` shows as "14-day free trial", its `ends_after_days` as
|
|
35
|
+
* "For 90 days, then choose a plan", and without `onSelect`
|
|
35
36
|
* each plan's button is its call-to-action link (`customerEmail` fills
|
|
36
37
|
* {CUSTOMER_EMAIL} in it).
|
|
37
38
|
*
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
|
|
59
60
|
const React = require("react");
|
|
60
61
|
const theme = require("./theme");
|
|
61
|
-
const { useBaseUrl } = require("./config");
|
|
62
|
+
const { useBaseUrl, DEFAULT_BASE_URL } = require("./config");
|
|
62
63
|
const { brandingVars } = require("./branding");
|
|
63
64
|
const { useI18n } = require("./i18n");
|
|
64
65
|
|
|
@@ -366,6 +367,7 @@ function fromSnapshot(p) {
|
|
|
366
367
|
highlight: !!p.highlight,
|
|
367
368
|
badge: p.badge || null,
|
|
368
369
|
trial_days: p.trial_days || null,
|
|
370
|
+
ends_after_days: p.ends_after_days || null,
|
|
369
371
|
cta: p.cta || null,
|
|
370
372
|
};
|
|
371
373
|
}
|
|
@@ -393,6 +395,7 @@ function PricingTable({
|
|
|
393
395
|
baseUrl: baseUrlProp,
|
|
394
396
|
publishableKey,
|
|
395
397
|
fetch: fetchImpl,
|
|
398
|
+
showUsage = false,
|
|
396
399
|
}) {
|
|
397
400
|
const baseUrl = useBaseUrl(baseUrlProp);
|
|
398
401
|
const selfFetch = !Array.isArray(plans) && !!publishableKey;
|
|
@@ -589,6 +592,12 @@ function PricingTable({
|
|
|
589
592
|
{ style: styles.trial },
|
|
590
593
|
t("pricing.trial", { days: plan.trial_days }),
|
|
591
594
|
),
|
|
595
|
+
plan.ends_after_days > 0 &&
|
|
596
|
+
React.createElement(
|
|
597
|
+
"div",
|
|
598
|
+
{ style: styles.trial },
|
|
599
|
+
t("pricing.endsAfter", { days: plan.ends_after_days }),
|
|
600
|
+
),
|
|
592
601
|
bullets.length > 0 &&
|
|
593
602
|
React.createElement(
|
|
594
603
|
"ul",
|
|
@@ -604,7 +613,7 @@ function PricingTable({
|
|
|
604
613
|
),
|
|
605
614
|
),
|
|
606
615
|
),
|
|
607
|
-
plan.usage && React.createElement(PlanUsage, { usage: plan.usage }),
|
|
616
|
+
showUsage && plan.usage && React.createElement(PlanUsage, { usage: plan.usage }),
|
|
608
617
|
action,
|
|
609
618
|
);
|
|
610
619
|
}),
|
|
@@ -613,4 +622,15 @@ function PricingTable({
|
|
|
613
622
|
}
|
|
614
623
|
|
|
615
624
|
PricingTable.annualPriceUsd = annualPriceUsd;
|
|
625
|
+
/**
|
|
626
|
+
* The public pricing snapshot, as `{ plans, branding }` with each plan in the
|
|
627
|
+
* shape this table takes: for a page that also uses the plans elsewhere (a
|
|
628
|
+
* sign-up form's plan picker), or shows its own plans until the live ones
|
|
629
|
+
* arrive. Rejects on an HTTP error.
|
|
630
|
+
*/
|
|
631
|
+
PricingTable.fetchPricingPage = ({
|
|
632
|
+
baseUrl = DEFAULT_BASE_URL,
|
|
633
|
+
publishableKey,
|
|
634
|
+
fetch: fetchImpl,
|
|
635
|
+
}) => fetchCatalog({ baseUrl, publishableKey, fetchImpl: fetchImpl || globalThis.fetch });
|
|
616
636
|
module.exports = PricingTable;
|
package/src/i18n.js
CHANGED
|
@@ -78,6 +78,7 @@ const en = {
|
|
|
78
78
|
"pricing.perMonth": "/ month",
|
|
79
79
|
"pricing.billedAnnually": "billed annually",
|
|
80
80
|
"pricing.trial": "{days}-day free trial",
|
|
81
|
+
"pricing.endsAfter": "For {days} days, then choose a plan",
|
|
81
82
|
"pricing.includes": "Includes {parts} a month",
|
|
82
83
|
"pricing.inputTokens": "{n} input tokens",
|
|
83
84
|
"pricing.outputTokens": "{n} output tokens",
|
|
@@ -230,6 +231,7 @@ const es = {
|
|
|
230
231
|
"pricing.perMonth": "/ mes",
|
|
231
232
|
"pricing.billedAnnually": "facturado anualmente",
|
|
232
233
|
"pricing.trial": "Prueba gratuita de {days} días",
|
|
234
|
+
"pricing.endsAfter": "Durante {days} días; luego elige un plan",
|
|
233
235
|
"pricing.includes": "Incluye {parts} al mes",
|
|
234
236
|
"pricing.inputTokens": "{n} tokens de entrada",
|
|
235
237
|
"pricing.outputTokens": "{n} tokens de salida",
|
|
@@ -382,6 +384,7 @@ const fr = {
|
|
|
382
384
|
"pricing.perMonth": "/ mois",
|
|
383
385
|
"pricing.billedAnnually": "facturé annuellement",
|
|
384
386
|
"pricing.trial": "Essai gratuit de {days} jours",
|
|
387
|
+
"pricing.endsAfter": "Pendant {days} jours, puis choisissez une offre",
|
|
385
388
|
"pricing.includes": "Inclut {parts} par mois",
|
|
386
389
|
"pricing.inputTokens": "{n} tokens en entrée",
|
|
387
390
|
"pricing.outputTokens": "{n} tokens en sortie",
|
|
@@ -535,6 +538,7 @@ const de = {
|
|
|
535
538
|
"pricing.perMonth": "/ Monat",
|
|
536
539
|
"pricing.billedAnnually": "jährlich abgerechnet",
|
|
537
540
|
"pricing.trial": "{days} Tage kostenlos testen",
|
|
541
|
+
"pricing.endsAfter": "{days} Tage lang, danach einen Tarif wählen",
|
|
538
542
|
"pricing.includes": "Enthält {parts} pro Monat",
|
|
539
543
|
"pricing.inputTokens": "{n} Input-Tokens",
|
|
540
544
|
"pricing.outputTokens": "{n} Output-Tokens",
|