@meterbox/react 0.1.16 → 0.1.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meterbox/react",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
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",
@@ -10,6 +10,10 @@
10
10
  "README.md",
11
11
  "LICENSE"
12
12
  ],
13
+ "scripts": {
14
+ "format": "prettier --write .",
15
+ "format:check": "prettier --check ."
16
+ },
13
17
  "engines": {
14
18
  "node": ">=18"
15
19
  },
@@ -17,12 +21,15 @@
17
21
  "access": "public"
18
22
  },
19
23
  "dependencies": {
20
- "@meterbox/node": "0.1.3"
24
+ "@meterbox/node": "0.1.4"
21
25
  },
22
26
  "peerDependencies": {
23
27
  "react": ">=17",
24
28
  "react-dom": ">=17"
25
29
  },
30
+ "devDependencies": {
31
+ "prettier": "^3.9.10"
32
+ },
26
33
  "keywords": [
27
34
  "meterbox",
28
35
  "react",
@@ -40,7 +40,13 @@ const styles = {
40
40
  title: { fontSize: 14, fontWeight: 700 },
41
41
  balance: { fontSize: 13, opacity: 0.7 },
42
42
  table: { width: "100%", borderCollapse: "collapse", fontSize: 13 },
43
- th: { textAlign: "left", padding: "6px 8px", borderBottom: "1px solid #e5e7eb", opacity: 0.6, fontWeight: 600 },
43
+ th: {
44
+ textAlign: "left",
45
+ padding: "6px 8px",
46
+ borderBottom: "1px solid #e5e7eb",
47
+ opacity: 0.6,
48
+ fontWeight: 600,
49
+ },
44
50
  td: { padding: "6px 8px", borderBottom: "1px solid #f3f4f6" },
45
51
  pill: {
46
52
  display: "inline-block",
@@ -187,7 +193,11 @@ function CreditGrantsTable({
187
193
  React.createElement(
188
194
  "tr",
189
195
  { key: g.id },
190
- React.createElement("td", { style: styles.td }, g.reason || g.source || g.type || "—"),
196
+ React.createElement(
197
+ "td",
198
+ { style: styles.td },
199
+ g.reason || g.source || g.type || "—",
200
+ ),
191
201
  React.createElement("td", { style: styles.td }, money(g.amount_usd)),
192
202
  React.createElement("td", { style: styles.td }, money(remaining(g))),
193
203
  React.createElement("td", { style: styles.td }, date(g.expires_at)),
@@ -151,7 +151,9 @@ function CreditUtilization({
151
151
  const y = 100 - (v / max) * 100;
152
152
  return [x, y];
153
153
  });
154
- const linePath = coords.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
154
+ const linePath = coords
155
+ .map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`)
156
+ .join(" ");
155
157
  const areaPath = `${linePath} L100,100 L0,100 Z`;
156
158
  return React.createElement(
157
159
  "div",
@@ -69,7 +69,13 @@ async function fetchInvoices({ baseUrl, customerId, customerToken, fetchImpl })
69
69
  return json.invoices || [];
70
70
  }
71
71
 
72
- function InvoiceHistory({ invoices, baseUrl: baseUrlProp, customerId, customerToken, fetch: fetchImpl }) {
72
+ function InvoiceHistory({
73
+ invoices,
74
+ baseUrl: baseUrlProp,
75
+ customerId,
76
+ customerToken,
77
+ fetch: fetchImpl,
78
+ }) {
73
79
  const baseUrl = useBaseUrl(baseUrlProp);
74
80
  const selfFetch = !invoices && customerId && customerToken;
75
81
  const [fetched, setFetched] = React.useState(null);
@@ -192,7 +192,14 @@ function PlanChangeCard({
192
192
  const result = onConfirm
193
193
  ? await onConfirm(effective)
194
194
  : canSelfFetch
195
- ? await postChange({ baseUrl, customerId, customerToken, planId, effective, fetchImpl: fetcher })
195
+ ? await postChange({
196
+ baseUrl,
197
+ customerId,
198
+ customerToken,
199
+ planId,
200
+ effective,
201
+ fetchImpl: fetcher,
202
+ })
196
203
  : null;
197
204
  if (result?.scheduled) {
198
205
  setScheduled(result.scheduled_change);
@@ -50,7 +50,14 @@ const styles = {
50
50
  delta: { fontSize: 13, fontWeight: 600 },
51
51
  };
52
52
 
53
- async function fetchPreview({ baseUrl, customerId, customerToken, planId, planVersion, fetchImpl }) {
53
+ async function fetchPreview({
54
+ baseUrl,
55
+ customerId,
56
+ customerToken,
57
+ planId,
58
+ planVersion,
59
+ fetchImpl,
60
+ }) {
54
61
  const url = `${String(baseUrl).replace(/\/+$/, "")}/v1/customer-portal/${encodeURIComponent(
55
62
  customerId,
56
63
  )}/subscription/preview`;
package/src/UsageChart.js CHANGED
@@ -72,7 +72,11 @@ function UsageChart({ series, valueKey = "amount_usd", height = 120, label }) {
72
72
  return React.createElement(
73
73
  "div",
74
74
  { className: "meterbox-usage-chart", style: styles.wrap },
75
- React.createElement("div", { style: styles.label }, label || VALUE_LABELS[valueKey] || valueKey),
75
+ React.createElement(
76
+ "div",
77
+ { style: styles.label },
78
+ label || VALUE_LABELS[valueKey] || valueKey,
79
+ ),
76
80
  React.createElement("div", { style: styles.total }, formatValue(valueKey, total)),
77
81
  React.createElement(
78
82
  "svg",