@usethrottle/auth 0.12.0 → 0.13.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.
Files changed (39) hide show
  1. package/README.md +10 -0
  2. package/dist/{AccountModal-B5Y6DXYQ.js → AccountModal-4GF7X5X4.js} +2 -2
  3. package/dist/{chunk-MC7TAQYZ.js → chunk-37RG635A.js} +4 -17
  4. package/dist/{chunk-MC7TAQYZ.js.map → chunk-37RG635A.js.map} +1 -1
  5. package/dist/chunk-PTREZIKS.js +31 -0
  6. package/dist/chunk-PTREZIKS.js.map +1 -0
  7. package/dist/{chunk-4HUBLJQC.js → chunk-X4IZ7RC6.js} +2 -2
  8. package/dist/{chunk-IQXKFRVX.js → chunk-YRJFGH6J.js} +9 -6
  9. package/dist/{chunk-IQXKFRVX.js.map → chunk-YRJFGH6J.js.map} +1 -1
  10. package/dist/{client-7LVKfuXO.d.ts → client-BripyQad.d.ts} +5 -3
  11. package/dist/{hooks-DkpLrEiC.d.ts → hooks-q2sYQa7f.d.ts} +1 -1
  12. package/dist/index.cjs +38 -2
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +8 -3
  15. package/dist/index.d.ts +8 -3
  16. package/dist/index.js +27 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/react/components/account/index.d.ts +3 -2
  19. package/dist/react/components/account/index.js +1 -1
  20. package/dist/react/components/auth/index.js +2 -2
  21. package/dist/react/components/index.cjs +71 -39
  22. package/dist/react/components/index.cjs.map +1 -1
  23. package/dist/react/components/index.d.cts +13 -5
  24. package/dist/react/components/index.d.ts +15 -7
  25. package/dist/react/components/index.js +25 -4
  26. package/dist/react/components/index.js.map +1 -1
  27. package/dist/react/components/provider.d.ts +2 -1
  28. package/dist/react/components/provider.js +1 -1
  29. package/dist/react/index.cjs +36 -0
  30. package/dist/react/index.cjs.map +1 -1
  31. package/dist/react/index.d.cts +7 -3
  32. package/dist/react/index.d.ts +7 -4
  33. package/dist/react/index.js +24 -1
  34. package/dist/styles.css +7 -4
  35. package/package.json +4 -1
  36. package/dist/chunk-ETYOOYYV.js +0 -2
  37. package/dist/chunk-ETYOOYYV.js.map +0 -1
  38. /package/dist/{AccountModal-B5Y6DXYQ.js.map → AccountModal-4GF7X5X4.js.map} +0 -0
  39. /package/dist/{chunk-4HUBLJQC.js.map → chunk-X4IZ7RC6.js.map} +0 -0
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  "use strict";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __esm = (fn, res) => function __init() {
8
10
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -19,6 +21,14 @@ var __copyProps = (to, from, except, desc) => {
19
21
  }
20
22
  return to;
21
23
  };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
22
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
33
 
24
34
  // src/errors.ts
@@ -3608,22 +3618,8 @@ var init_PaymentMethodsPanel = __esm({
3608
3618
 
3609
3619
  // src/react/components/format.ts
3610
3620
  function formatMoney(minorUnits, currency, locale) {
3611
- const code = (currency || "USD").toUpperCase();
3612
- let digits = 2;
3613
- try {
3614
- digits = new Intl.NumberFormat("en-US", { style: "currency", currency: code }).resolvedOptions().maximumFractionDigits ?? 2;
3615
- } catch {
3616
- }
3617
- const major = minorUnits / 10 ** digits;
3618
- try {
3619
- return new Intl.NumberFormat(locale, { style: "currency", currency: code }).format(major);
3620
- } catch {
3621
- try {
3622
- return new Intl.NumberFormat("en-US", { style: "currency", currency: code }).format(major);
3623
- } catch {
3624
- return `${code} ${major.toFixed(digits)}`;
3625
- }
3626
- }
3621
+ void locale;
3622
+ return (0, import_money.formatMoney)(minorUnits, currency);
3627
3623
  }
3628
3624
  function formatDate(value, locale) {
3629
3625
  const date = value instanceof Date ? value : new Date(value);
@@ -3649,9 +3645,11 @@ function scheduleDueLabel(row, locale) {
3649
3645
  return `${new Intl.DateTimeFormat("en-US", opts).format(date)} UTC`;
3650
3646
  }
3651
3647
  }
3648
+ var import_money;
3652
3649
  var init_format = __esm({
3653
3650
  "src/react/components/format.ts"() {
3654
3651
  "use strict";
3652
+ import_money = require("@usethrottle/money");
3655
3653
  }
3656
3654
  });
3657
3655
 
@@ -3667,10 +3665,10 @@ function OrderStatus(props) {
3667
3665
  const labels = props.t.orders.statusLabels;
3668
3666
  const payLabels = props.t.orders.paymentLabels;
3669
3667
  const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
3670
- const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
3668
+ const money2 = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
3671
3669
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3672
3670
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
3673
- money ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
3671
+ money2 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money2 }) : null
3674
3672
  ] });
3675
3673
  }
3676
3674
  var import_jsx_runtime36, ATTENTION_PAYMENT_STATES, TERMINAL_STATUSES;
@@ -3811,7 +3809,7 @@ function OrderDetail(props) {
3811
3809
  subscriptionId: li.subscriptionId ?? null
3812
3810
  }))
3813
3811
  };
3814
- const money = (v) => formatMoney(v, order.currency, locale);
3812
+ const money2 = (v) => formatMoney(v, order.currency, locale);
3815
3813
  const paid = SETTLED_PAYMENT.has(order.paymentStatus);
3816
3814
  const showCancel = allowCancel && CAN_CANCEL.has(order.status) && !paid;
3817
3815
  const showReorder = !!props.onReorder && (CAN_REORDER.has(order.status) || !!props.reorderOnPaid && REORDER_PAID_PAYMENT.has(order.paymentStatus));
@@ -3837,10 +3835,10 @@ function OrderDetail(props) {
3837
3835
  " ",
3838
3836
  item.quantity,
3839
3837
  " \xD7 ",
3840
- money(item.unitPrice)
3838
+ money2(item.unitPrice)
3841
3839
  ] })
3842
3840
  ] }),
3843
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: money(item.total) })
3841
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: money2(item.total) })
3844
3842
  ] }, item.id)) })
3845
3843
  ] }),
3846
3844
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
@@ -3878,13 +3876,13 @@ function OrderDetail(props) {
3878
3876
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("aside", { ...a.el("orderDetail.rail", "throttle-detail__rail"), children: [
3879
3877
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3880
3878
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.total }),
3881
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__headline", children: money(order.total) })
3879
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__headline", children: money2(order.total) })
3882
3880
  ] }),
3883
3881
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
3884
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: money(order.subtotal) }),
3885
- order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: money(-order.discountTotal) }) : null,
3886
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: money(order.shippingTotal) }),
3887
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: money(order.taxTotal) })
3882
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: money2(order.subtotal) }),
3883
+ order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: money2(-order.discountTotal) }) : null,
3884
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: money2(order.shippingTotal) }),
3885
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: money2(order.taxTotal) })
3888
3886
  ] }),
3889
3887
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.actions", "throttle-detail__actions"), children: [
3890
3888
  props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { elementKey: "orderDetail.payButton", onClick: () => props.onPayNow(target), children: t.orders.payNow }) : null,
@@ -4140,7 +4138,7 @@ function InvoiceDetail(props) {
4140
4138
  ) : null,
4141
4139
  error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
4142
4140
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => {
4143
- const money = (v) => formatMoney(v, invoice.currency, locale);
4141
+ const money2 = (v) => formatMoney(v, invoice.currency, locale);
4144
4142
  const lines = invoice.lineItems ?? [];
4145
4143
  const partOfOrder = invoice.orderTotal != null;
4146
4144
  const isDepositReceipt = partOfOrder && invoice.balanceDue != null;
@@ -4169,23 +4167,23 @@ function InvoiceDetail(props) {
4169
4167
  " ",
4170
4168
  item.quantity,
4171
4169
  " \xD7 ",
4172
- money(item.unitPrice)
4170
+ money2(item.unitPrice)
4173
4171
  ] })
4174
4172
  ] }),
4175
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: money(item.total) })
4173
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: money2(item.total) })
4176
4174
  ] }, i)) })
4177
4175
  ] }) : null
4178
4176
  ] }),
4179
4177
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("aside", { ...a.el("invoiceDetail.rail", "throttle-detail__rail"), children: [
4180
4178
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4181
4179
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: headlineLabel }),
4182
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money(invoice.total) })
4180
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money2(invoice.total) })
4183
4181
  ] }),
4184
4182
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
4185
- partOfOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.orderTotal, value: money(invoice.orderTotal) }) : null,
4186
- partOfOrder && invoice.amountPaid ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.amountPaid, value: `-${money(invoice.amountPaid)}` }) : null,
4187
- partOfOrder && invoice.compWaived ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.waived, value: `-${money(invoice.compWaived)}` }) : null,
4188
- isDepositReceipt && invoice.balanceDue ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.balanceDue, value: money(invoice.balanceDue) }) : null,
4183
+ partOfOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.orderTotal, value: money2(invoice.orderTotal) }) : null,
4184
+ partOfOrder && invoice.amountPaid ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.amountPaid, value: `-${money2(invoice.amountPaid)}` }) : null,
4185
+ partOfOrder && invoice.compWaived ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.waived, value: `-${money2(invoice.compWaived)}` }) : null,
4186
+ isDepositReceipt && invoice.balanceDue ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.balanceDue, value: money2(invoice.balanceDue) }) : null,
4189
4187
  invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
4190
4188
  invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4191
4189
  Line2,
@@ -4194,7 +4192,7 @@ function InvoiceDetail(props) {
4194
4192
  value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
4195
4193
  }
4196
4194
  ) : null,
4197
- invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.refunded, value: money(invoice.amountRefunded) }) : null
4195
+ invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.refunded, value: money2(invoice.amountRefunded) }) : null
4198
4196
  ] }),
4199
4197
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.actions", "throttle-detail__actions"), children: [
4200
4198
  props.onPay && PAYABLE.has(invoice.status) ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
@@ -4454,6 +4452,14 @@ var init_subscription_line = __esm({
4454
4452
  }
4455
4453
  });
4456
4454
 
4455
+ // ../core-cadence/src/plan-id.ts
4456
+ var init_plan_id = __esm({
4457
+ "../core-cadence/src/plan-id.ts"() {
4458
+ "use strict";
4459
+ init_cadence();
4460
+ }
4461
+ });
4462
+
4457
4463
  // ../core-cadence/src/index.ts
4458
4464
  var init_src = __esm({
4459
4465
  "../core-cadence/src/index.ts"() {
@@ -4464,6 +4470,7 @@ var init_src = __esm({
4464
4470
  init_recurring_terms();
4465
4471
  init_subscription_line();
4466
4472
  init_schedule();
4473
+ init_plan_id();
4467
4474
  }
4468
4475
  });
4469
4476
 
@@ -5100,6 +5107,7 @@ __export(components_exports, {
5100
5107
  AddressesPanel: () => AddressesPanel,
5101
5108
  AuthFlow: () => AuthFlow,
5102
5109
  AuthModal: () => AuthModal,
5110
+ CURRENCIES: () => import_money2.CURRENCIES,
5103
5111
  ForgotPassword: () => ForgotPassword,
5104
5112
  InvoiceDetail: () => InvoiceDetail,
5105
5113
  InvoicesPanel: () => InvoicesPanel,
@@ -5126,16 +5134,25 @@ __export(components_exports, {
5126
5134
  ThrottleAuthError: () => ThrottleAuthError,
5127
5135
  ThrottleAuthProvider: () => ThrottleAuthProvider,
5128
5136
  ThrottleProvider: () => ThrottleProvider,
5137
+ UnknownCurrencyError: () => import_money2.UnknownCurrencyError,
5129
5138
  UserButton: () => UserButton,
5130
5139
  VerifyEmail: () => VerifyEmail,
5131
5140
  VerifyEmailBanner: () => VerifyEmailBanner,
5132
5141
  createAccount: () => createAccount,
5133
5142
  createThrottleAuth: () => createThrottleAuth,
5143
+ currencySymbol: () => import_money2.currencySymbol,
5134
5144
  enUS: () => enUS,
5135
5145
  formatDate: () => formatDate,
5136
5146
  formatMoney: () => formatMoney,
5147
+ isKnownCurrency: () => import_money2.isKnownCurrency,
5137
5148
  localStorageAdapter: () => localStorageAdapter,
5138
5149
  memoryStorage: () => memoryStorage,
5150
+ minorUnitsOf: () => import_money2.minorUnitsOf,
5151
+ money: () => money,
5152
+ moneyValue: () => import_money2.moneyValue,
5153
+ parseMoney: () => import_money2.parseMoney,
5154
+ toDecimalString: () => import_money2.toDecimalString,
5155
+ toMinor: () => import_money2.toMinor,
5139
5156
  useAddresses: () => useAddresses,
5140
5157
  useAuth: () => useAuth,
5141
5158
  useAuthContext: () => useAuthContext,
@@ -5537,10 +5554,6 @@ var THROTTLE_STYLES = `
5537
5554
  .throttle-addresses { grid-template-columns: 1fr; }
5538
5555
  .throttle-fieldrow { grid-template-columns: 1fr; }
5539
5556
  .throttle-tabs__rail { width: 100%; }
5540
- /* One column, and the rail stops sticking \u2014 on a phone a sticky summary
5541
- covers the very line items it is summarising. */
5542
- .throttle-detail { grid-template-columns: 1fr; }
5543
- .throttle-detail__rail { position: static; }
5544
5557
  }
5545
5558
 
5546
5559
  .throttle-table { width: 100%; border-collapse: collapse; text-align: left; }
@@ -5654,6 +5667,13 @@ var THROTTLE_STYLES = `
5654
5667
  border-radius: var(--throttle-radius-md);
5655
5668
  background: var(--throttle-color-surface);
5656
5669
  }
5670
+ /* One column, and the rail stops sticking \u2014 on a phone a sticky summary covers
5671
+ the very line items it is summarising. Placed AFTER the base rules above: a
5672
+ container query adds no specificity, so the later rule wins. */
5673
+ @container (max-width: 560px) {
5674
+ .throttle-detail { grid-template-columns: 1fr; }
5675
+ .throttle-detail__rail { position: static; }
5676
+ }
5657
5677
  /* The one number the buyer came for. */
5658
5678
  .throttle-detail__headline { font-size: var(--throttle-font-size-xl); font-weight: 600; line-height: 1.2; }
5659
5679
  .throttle-detail__section { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
@@ -6203,6 +6223,8 @@ init_client();
6203
6223
  init_errors();
6204
6224
  init_storage();
6205
6225
  init_account();
6226
+ var money = __toESM(require("@usethrottle/money"), 1);
6227
+ var import_money2 = require("@usethrottle/money");
6206
6228
  // Annotate the CommonJS export names for ESM import in node:
6207
6229
  0 && (module.exports = {
6208
6230
  ACCOUNT_TABS,
@@ -6212,6 +6234,7 @@ init_account();
6212
6234
  AddressesPanel,
6213
6235
  AuthFlow,
6214
6236
  AuthModal,
6237
+ CURRENCIES,
6215
6238
  ForgotPassword,
6216
6239
  InvoiceDetail,
6217
6240
  InvoicesPanel,
@@ -6238,16 +6261,25 @@ init_account();
6238
6261
  ThrottleAuthError,
6239
6262
  ThrottleAuthProvider,
6240
6263
  ThrottleProvider,
6264
+ UnknownCurrencyError,
6241
6265
  UserButton,
6242
6266
  VerifyEmail,
6243
6267
  VerifyEmailBanner,
6244
6268
  createAccount,
6245
6269
  createThrottleAuth,
6270
+ currencySymbol,
6246
6271
  enUS,
6247
6272
  formatDate,
6248
6273
  formatMoney,
6274
+ isKnownCurrency,
6249
6275
  localStorageAdapter,
6250
6276
  memoryStorage,
6277
+ minorUnitsOf,
6278
+ money,
6279
+ moneyValue,
6280
+ parseMoney,
6281
+ toDecimalString,
6282
+ toMinor,
6251
6283
  useAddresses,
6252
6284
  useAuth,
6253
6285
  useAuthContext,