@meterbox/react 0.1.19 → 0.1.20
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/package.json +1 -1
- package/src/CreditGrantsTable.js +6 -2
- package/src/OutcomeHistory.js +2 -2
- package/src/UsageChart.js +1 -1
- package/src/i18n.js +19 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meterbox/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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",
|
package/src/CreditGrantsTable.js
CHANGED
|
@@ -196,11 +196,15 @@ function CreditGrantsTable({
|
|
|
196
196
|
React.createElement(
|
|
197
197
|
"td",
|
|
198
198
|
{ style: styles.td },
|
|
199
|
-
g.reason || g.source || g.type || "
|
|
199
|
+
g.reason || g.source || g.type || t("credits.unnamed"),
|
|
200
200
|
),
|
|
201
201
|
React.createElement("td", { style: styles.td }, money(g.amount_usd)),
|
|
202
202
|
React.createElement("td", { style: styles.td }, money(remaining(g))),
|
|
203
|
-
React.createElement(
|
|
203
|
+
React.createElement(
|
|
204
|
+
"td",
|
|
205
|
+
{ style: styles.td },
|
|
206
|
+
g.expires_at ? date(g.expires_at) : t("credits.neverExpires"),
|
|
207
|
+
),
|
|
204
208
|
React.createElement(
|
|
205
209
|
"td",
|
|
206
210
|
{ style: styles.td },
|
package/src/OutcomeHistory.js
CHANGED
|
@@ -65,12 +65,12 @@ const STATUS_STYLE = {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
function dollars(n) {
|
|
68
|
-
if (n == null) return "
|
|
68
|
+
if (n == null) return "Not available";
|
|
69
69
|
return `$${Number(n).toLocaleString(undefined, { maximumFractionDigits: 2 })}`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function fmtDate(iso) {
|
|
73
|
-
if (!iso) return "
|
|
73
|
+
if (!iso) return "Unknown";
|
|
74
74
|
const d = new Date(iso);
|
|
75
75
|
if (Number.isNaN(d.getTime())) return iso;
|
|
76
76
|
return d.toISOString().slice(0, 10);
|
package/src/UsageChart.js
CHANGED
|
@@ -38,7 +38,7 @@ const VALUE_LABELS = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
function formatValue(valueKey, n) {
|
|
41
|
-
if (n == null) return "
|
|
41
|
+
if (n == null) return "No data";
|
|
42
42
|
if (valueKey === "amount_usd") {
|
|
43
43
|
return `$${Number(n).toLocaleString(undefined, { maximumFractionDigits: 2 })}`;
|
|
44
44
|
}
|
package/src/i18n.js
CHANGED
|
@@ -157,6 +157,10 @@ const en = {
|
|
|
157
157
|
"credits.amount": "Amount",
|
|
158
158
|
"credits.remaining": "Remaining",
|
|
159
159
|
"credits.expires": "Expires",
|
|
160
|
+
"credits.neverExpires": "Never",
|
|
161
|
+
"credits.unnamed": "Credit",
|
|
162
|
+
"value.none": "Not available",
|
|
163
|
+
"value.noDate": "No date",
|
|
160
164
|
"credits.status": "Status",
|
|
161
165
|
"credits.utilLoading": "Loading utilization…",
|
|
162
166
|
"credits.utilError": "Could not load utilization.",
|
|
@@ -329,6 +333,10 @@ const es = {
|
|
|
329
333
|
"credits.amount": "Importe",
|
|
330
334
|
"credits.remaining": "Restante",
|
|
331
335
|
"credits.expires": "Vence",
|
|
336
|
+
"credits.neverExpires": "Nunca",
|
|
337
|
+
"credits.unnamed": "Crédito",
|
|
338
|
+
"value.none": "No disponible",
|
|
339
|
+
"value.noDate": "Sin fecha",
|
|
332
340
|
"credits.status": "Estado",
|
|
333
341
|
"credits.utilLoading": "Cargando el uso…",
|
|
334
342
|
"credits.utilError": "No se pudo cargar el uso.",
|
|
@@ -502,6 +510,10 @@ const fr = {
|
|
|
502
510
|
"credits.amount": "Montant",
|
|
503
511
|
"credits.remaining": "Restant",
|
|
504
512
|
"credits.expires": "Expire",
|
|
513
|
+
"credits.neverExpires": "Jamais",
|
|
514
|
+
"credits.unnamed": "Crédit",
|
|
515
|
+
"value.none": "Non disponible",
|
|
516
|
+
"value.noDate": "Aucune date",
|
|
505
517
|
"credits.status": "Statut",
|
|
506
518
|
"credits.utilLoading": "Chargement de l'utilisation…",
|
|
507
519
|
"credits.utilError": "Impossible de charger l'utilisation.",
|
|
@@ -674,6 +686,10 @@ const de = {
|
|
|
674
686
|
"credits.amount": "Betrag",
|
|
675
687
|
"credits.remaining": "Verbleibend",
|
|
676
688
|
"credits.expires": "Läuft ab",
|
|
689
|
+
"credits.neverExpires": "Nie",
|
|
690
|
+
"credits.unnamed": "Guthaben",
|
|
691
|
+
"value.none": "Nicht verfügbar",
|
|
692
|
+
"value.noDate": "Kein Datum",
|
|
677
693
|
"credits.status": "Status",
|
|
678
694
|
"credits.utilLoading": "Nutzung wird geladen…",
|
|
679
695
|
"credits.utilError": "Die Nutzung konnte nicht geladen werden.",
|
|
@@ -742,9 +758,9 @@ function createI18n(locale, messages) {
|
|
|
742
758
|
}
|
|
743
759
|
|
|
744
760
|
// `amount` in the currency's major unit, whole amounts without decimals;
|
|
745
|
-
// "
|
|
761
|
+
// "Not available" (translated) when there's none.
|
|
746
762
|
function money(amount, currency = "USD", options = {}) {
|
|
747
|
-
if (amount == null) return "
|
|
763
|
+
if (amount == null) return t("value.none");
|
|
748
764
|
const n = Number(amount);
|
|
749
765
|
const whole = n % 1 === 0 ? { minimumFractionDigits: 0, maximumFractionDigits: 0 } : {};
|
|
750
766
|
try {
|
|
@@ -757,7 +773,7 @@ function createI18n(locale, messages) {
|
|
|
757
773
|
// The calendar date of an ISO timestamp, as written in `locale` (UTC, so a
|
|
758
774
|
// date never shifts a day with the viewer's time zone).
|
|
759
775
|
function date(iso) {
|
|
760
|
-
if (!iso) return "
|
|
776
|
+
if (!iso) return t("value.noDate");
|
|
761
777
|
const d = new Date(iso);
|
|
762
778
|
if (Number.isNaN(d.getTime())) return String(iso);
|
|
763
779
|
return new Intl.DateTimeFormat(tag, { dateStyle: "medium", timeZone: "UTC" }).format(d);
|