@usethrottle/auth 0.2.2 → 0.2.3
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/dist/{chunk-HGBAIM6B.js → chunk-2DREGJUF.js} +2 -2
- package/dist/{chunk-SZ427BQ3.js → chunk-NCSTIPJF.js} +8 -1
- package/dist/{chunk-SZ427BQ3.js.map → chunk-NCSTIPJF.js.map} +1 -1
- package/dist/{chunk-AIXBUDOT.js → chunk-ST77QX7X.js} +12 -1
- package/dist/chunk-ST77QX7X.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/react/components/index.cjs +439 -297
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +24 -8
- package/dist/react/components/index.d.ts +24 -8
- package/dist/react/components/index.js +409 -286
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/forms/index.cjs +11 -0
- package/dist/react/forms/index.cjs.map +1 -1
- package/dist/react/forms/index.js +2 -2
- package/dist/react/index.cjs +7 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +24 -0
- package/dist/react/index.d.ts +24 -0
- package/dist/react/index.js +2 -2
- package/dist/styles.css +21 -2
- package/package.json +1 -1
- package/dist/chunk-AIXBUDOT.js.map +0 -1
- /package/dist/{chunk-HGBAIM6B.js.map → chunk-2DREGJUF.js.map} +0 -0
|
@@ -24,6 +24,7 @@ __export(components_exports, {
|
|
|
24
24
|
ACCOUNT_TABS: () => ACCOUNT_TABS,
|
|
25
25
|
AccountDashboard: () => AccountDashboard,
|
|
26
26
|
AccountModal: () => AccountModal,
|
|
27
|
+
AddCardDialog: () => AddCardDialog,
|
|
27
28
|
AddressesPanel: () => AddressesPanel,
|
|
28
29
|
AuthFlow: () => AuthFlow,
|
|
29
30
|
AuthModal: () => AuthModal,
|
|
@@ -78,7 +79,7 @@ __export(components_exports, {
|
|
|
78
79
|
module.exports = __toCommonJS(components_exports);
|
|
79
80
|
|
|
80
81
|
// src/react/components/provider.tsx
|
|
81
|
-
var
|
|
82
|
+
var import_react31 = require("react");
|
|
82
83
|
|
|
83
84
|
// src/errors.ts
|
|
84
85
|
var ThrottleAuthError = class extends Error {
|
|
@@ -444,6 +445,13 @@ function createAccount(auth) {
|
|
|
444
445
|
// this is how a buyer changes what they are billed on: move the default.
|
|
445
446
|
setDefaultPaymentMethod: (id) => call("PATCH", `/me/payment-methods/${seg(id)}`, { isDefault: true }),
|
|
446
447
|
deletePaymentMethod: (id) => call("DELETE", `/me/payment-methods/${seg(id)}`),
|
|
448
|
+
// Saving a card is two calls because the card number never reaches us: the
|
|
449
|
+
// first mints a processor-hosted embed session, the buyer types their card
|
|
450
|
+
// into that, and the second records what the processor vaulted. Everything
|
|
451
|
+
// about the saved card is read back from the processor, so nothing here
|
|
452
|
+
// trusts what the browser claims the card was.
|
|
453
|
+
startCardSetup: () => call("POST", "/me/payment-methods/embed-token"),
|
|
454
|
+
confirmCardSetup: (transactionId) => call("POST", "/me/payment-methods/confirm", { transactionId }),
|
|
447
455
|
listOrders: (page) => call("GET", `/me/orders${query(page)}`),
|
|
448
456
|
getOrder: (id) => call("GET", `/me/orders/${seg(id)}`),
|
|
449
457
|
listInvoices: (page) => call("GET", `/me/invoices${query(page)}`),
|
|
@@ -610,6 +618,12 @@ var VARIABLE_PROPERTY = {
|
|
|
610
618
|
borderRadius: "--throttle-radius",
|
|
611
619
|
borderWidth: "--throttle-border-width",
|
|
612
620
|
spacing: "--throttle-spacing",
|
|
621
|
+
// The account dashboard's own surface and outer padding. Separate from
|
|
622
|
+
// colorBackground/colorSurface because a merchant embedding the dashboard
|
|
623
|
+
// in their page usually wants it to paint nothing at all, while still
|
|
624
|
+
// theming the cards inside it.
|
|
625
|
+
accountSurface: "--throttle-color-account-surface",
|
|
626
|
+
accountPadding: "--throttle-account-padding",
|
|
613
627
|
shadowCard: "--throttle-shadow-card",
|
|
614
628
|
shadowPopover: "--throttle-shadow-popover",
|
|
615
629
|
transition: "--throttle-transition",
|
|
@@ -744,6 +758,8 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
744
758
|
"paymentMethodsPanel.item",
|
|
745
759
|
"paymentMethodsPanel.defaultButton",
|
|
746
760
|
"paymentMethodsPanel.deleteButton",
|
|
761
|
+
"paymentMethodsPanel.addButton",
|
|
762
|
+
"paymentMethodsPanel.addDialog",
|
|
747
763
|
"paymentMethodsPanel.table",
|
|
748
764
|
"paymentMethodsPanel.row",
|
|
749
765
|
"ordersPanel.root",
|
|
@@ -852,6 +868,10 @@ function waitCopy(seconds) {
|
|
|
852
868
|
const minutes = Math.ceil(seconds / 60);
|
|
853
869
|
return `Please wait ${minutes} ${minutes === 1 ? "minute" : "minutes"} and try again.`;
|
|
854
870
|
}
|
|
871
|
+
function fieldLabel(path) {
|
|
872
|
+
const words = path.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([a-zA-Z])([0-9])/g, "$1 $2").toLowerCase().trim();
|
|
873
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
874
|
+
}
|
|
855
875
|
function messageForError(err) {
|
|
856
876
|
const e = err;
|
|
857
877
|
switch (e?.code) {
|
|
@@ -884,6 +904,13 @@ function messageForError(err) {
|
|
|
884
904
|
return "We could not find that.";
|
|
885
905
|
case "payment_method_in_use":
|
|
886
906
|
return e.message || "That payment method is in use and cannot be removed.";
|
|
907
|
+
case "validation_error": {
|
|
908
|
+
const first2 = e.details?.[0];
|
|
909
|
+
if (first2?.path && first2?.message) {
|
|
910
|
+
return `${fieldLabel(first2.path)} ${first2.message.replace(/\bNOT\b/g, "not")}.`;
|
|
911
|
+
}
|
|
912
|
+
return "Please check the highlighted fields and try again.";
|
|
913
|
+
}
|
|
887
914
|
default:
|
|
888
915
|
return "Something went wrong. Please try again.";
|
|
889
916
|
}
|
|
@@ -1018,8 +1045,9 @@ var enUS = {
|
|
|
1018
1045
|
},
|
|
1019
1046
|
paymentMethods: {
|
|
1020
1047
|
empty: "No saved cards",
|
|
1021
|
-
|
|
1022
|
-
|
|
1048
|
+
emptyDescription: "Add a card here, or one will be saved when you check out.",
|
|
1049
|
+
addButton: "Add card",
|
|
1050
|
+
addTitle: "Add a card",
|
|
1023
1051
|
// Shown whenever the panel is empty with no error and the buyer is not
|
|
1024
1052
|
// verified — including simply being signed out — matching the copy
|
|
1025
1053
|
// orders/invoices/subscriptions already show in that state.
|
|
@@ -1216,6 +1244,12 @@ var THROTTLE_STYLES = `
|
|
|
1216
1244
|
edges, table rules, dividers) keep --throttle-color-border: they do not
|
|
1217
1245
|
identify a control, so the requirement does not apply and darkening
|
|
1218
1246
|
them would only add noise. */
|
|
1247
|
+
/* The account dashboard paints nothing by default so it can drop into a
|
|
1248
|
+
merchant's page without fighting their background. The accountSurface and
|
|
1249
|
+
accountPadding appearance variables opt back into a card.
|
|
1250
|
+
No backticks in this comment: the sheet is a TS template literal. */
|
|
1251
|
+
--throttle-color-account-surface: transparent;
|
|
1252
|
+
--throttle-account-padding: 0;
|
|
1219
1253
|
--throttle-color-border-control: #8b93a1;
|
|
1220
1254
|
--throttle-color-danger: #c2321f;
|
|
1221
1255
|
--throttle-color-danger-surface: #fef2f2;
|
|
@@ -1364,7 +1398,13 @@ var THROTTLE_STYLES = `
|
|
|
1364
1398
|
/* Always mounted, so it reserves its line whether or not there is an error:
|
|
1365
1399
|
an error appearing on submit must not push the submit button out from
|
|
1366
1400
|
under the buyer's pointer. */
|
|
1367
|
-
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs);
|
|
1401
|
+
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs); line-height: 1rem; }
|
|
1402
|
+
/* Reserved a full line under EVERY input even with nothing to say, which
|
|
1403
|
+
with the stack gap put 28px of dead space beneath each field, on every
|
|
1404
|
+
form and all seven account panels. The element stays mounted when empty
|
|
1405
|
+
because role=alert only announces changes to a live region that was
|
|
1406
|
+
already there; it just stops occupying a line. */
|
|
1407
|
+
.throttle-field__error:empty { display: none; }
|
|
1368
1408
|
|
|
1369
1409
|
.throttle-field-group {
|
|
1370
1410
|
display: flex;
|
|
@@ -1423,6 +1463,11 @@ var THROTTLE_STYLES = `
|
|
|
1423
1463
|
animation: throttle-spin 700ms linear infinite;
|
|
1424
1464
|
}
|
|
1425
1465
|
@keyframes throttle-spin { to { transform: rotate(360deg); } }
|
|
1466
|
+
.throttle-button--loading { position: relative; }
|
|
1467
|
+
.throttle-button__label { display: inline-flex; align-items: center; justify-content: center; gap: var(--throttle-space-2); }
|
|
1468
|
+
.throttle-button__label--hidden { visibility: hidden; }
|
|
1469
|
+
.throttle-spinner--centred { position: absolute; top: 50%; left: 50%; margin: -0.5em 0 0 -0.5em; }
|
|
1470
|
+
|
|
1426
1471
|
@media (prefers-reduced-motion: reduce) { .throttle-spinner { animation-duration: 2.4s; } }
|
|
1427
1472
|
|
|
1428
1473
|
.throttle-skeleton {
|
|
@@ -1505,7 +1550,9 @@ var THROTTLE_STYLES = `
|
|
|
1505
1550
|
/* Paints its own ground. A UserButton in a navbar should stay transparent, but
|
|
1506
1551
|
the dashboard is a large surface of themed text: in dark theme its foreground
|
|
1507
1552
|
is near-white, so on a light host page it was rendering white-on-white. */
|
|
1508
|
-
.throttle-
|
|
1553
|
+
.throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
|
|
1554
|
+
.throttle-centre { display: flex; align-items: center; justify-content: center; min-height: 160px; }
|
|
1555
|
+
.throttle-account-root { container-type: inline-size; background: var(--throttle-color-account-surface); color: var(--throttle-color-foreground); padding: var(--throttle-account-padding); }
|
|
1509
1556
|
.throttle-account { display: flex; gap: var(--throttle-space-5); align-items: flex-start; }
|
|
1510
1557
|
.throttle-account__content { flex: 1; min-width: 0; }
|
|
1511
1558
|
.throttle-tabs__rail { flex: none; width: 220px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -1685,11 +1732,12 @@ function CardFooter(props) {
|
|
|
1685
1732
|
|
|
1686
1733
|
// src/react/components/primitives/Spinner.tsx
|
|
1687
1734
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1688
|
-
function Spinner() {
|
|
1735
|
+
function Spinner({ centred } = {}) {
|
|
1689
1736
|
const a = useAppearance();
|
|
1690
1737
|
const Slot = a.slots.Spinner;
|
|
1691
1738
|
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, {});
|
|
1692
|
-
|
|
1739
|
+
const cls = `throttle-spinner${centred ? " throttle-spinner--centred" : ""}`;
|
|
1740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { ...a.el("spinner", cls), "aria-hidden": "true" });
|
|
1693
1741
|
}
|
|
1694
1742
|
|
|
1695
1743
|
// src/react/components/primitives/Button.tsx
|
|
@@ -1698,7 +1746,7 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1698
1746
|
const a = useAppearance();
|
|
1699
1747
|
const Slot = a.slots.Button;
|
|
1700
1748
|
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { variant, loading, ...rest, children });
|
|
1701
|
-
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}`;
|
|
1749
|
+
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}${loading ? " throttle-button--loading" : ""}`;
|
|
1702
1750
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1703
1751
|
"button",
|
|
1704
1752
|
{
|
|
@@ -1706,9 +1754,10 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1706
1754
|
...rest,
|
|
1707
1755
|
...a.el(elementKey ?? "button", base),
|
|
1708
1756
|
disabled: rest.disabled || loading,
|
|
1757
|
+
"aria-busy": loading ? true : void 0,
|
|
1709
1758
|
children: [
|
|
1710
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, {}) : null,
|
|
1711
|
-
children
|
|
1759
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { centred: true }) : null,
|
|
1760
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `throttle-button__label${loading ? " throttle-button__label--hidden" : ""}`, children })
|
|
1712
1761
|
]
|
|
1713
1762
|
}
|
|
1714
1763
|
);
|
|
@@ -2631,10 +2680,10 @@ function AuthModal(props) {
|
|
|
2631
2680
|
}
|
|
2632
2681
|
|
|
2633
2682
|
// src/react/components/account/AccountModal.tsx
|
|
2634
|
-
var
|
|
2683
|
+
var import_react30 = require("react");
|
|
2635
2684
|
|
|
2636
2685
|
// src/react/components/account/AccountDashboard.tsx
|
|
2637
|
-
var
|
|
2686
|
+
var import_react29 = require("react");
|
|
2638
2687
|
|
|
2639
2688
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2640
2689
|
var import_react19 = require("react");
|
|
@@ -2909,7 +2958,7 @@ function ProfilePanel(props) {
|
|
|
2909
2958
|
const { status } = useAuth();
|
|
2910
2959
|
const resource = useCustomer();
|
|
2911
2960
|
const { submitting, error, notice, run } = useAction();
|
|
2912
|
-
const [form, setForm] = (0, import_react21.useState)({ firstName: "", lastName: "", phone: "", company: ""
|
|
2961
|
+
const [form, setForm] = (0, import_react21.useState)({ firstName: "", lastName: "", phone: "", company: "" });
|
|
2913
2962
|
const edited = (0, import_react21.useRef)(false);
|
|
2914
2963
|
(0, import_react21.useEffect)(() => {
|
|
2915
2964
|
const c = resource.data;
|
|
@@ -2918,8 +2967,7 @@ function ProfilePanel(props) {
|
|
|
2918
2967
|
firstName: c.firstName ?? "",
|
|
2919
2968
|
lastName: c.lastName ?? "",
|
|
2920
2969
|
phone: c.phone ?? "",
|
|
2921
|
-
company: c.company ?? ""
|
|
2922
|
-
acceptsMarketing: Boolean(c.acceptsMarketing)
|
|
2970
|
+
company: c.company ?? ""
|
|
2923
2971
|
});
|
|
2924
2972
|
}, [resource.data]);
|
|
2925
2973
|
if (status === "unauthenticated") return null;
|
|
@@ -2942,8 +2990,7 @@ function ProfilePanel(props) {
|
|
|
2942
2990
|
firstName: form.firstName,
|
|
2943
2991
|
lastName: form.lastName,
|
|
2944
2992
|
phone: form.phone,
|
|
2945
|
-
company: form.company || null
|
|
2946
|
-
acceptsMarketing: form.acceptsMarketing
|
|
2993
|
+
company: form.company || null
|
|
2947
2994
|
});
|
|
2948
2995
|
return t.profile.savedNotice;
|
|
2949
2996
|
});
|
|
@@ -3010,20 +3057,6 @@ function ProfilePanel(props) {
|
|
|
3010
3057
|
}
|
|
3011
3058
|
}
|
|
3012
3059
|
),
|
|
3013
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("label", { className: "throttle-row", children: [
|
|
3014
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3015
|
-
"input",
|
|
3016
|
-
{
|
|
3017
|
-
type: "checkbox",
|
|
3018
|
-
checked: form.acceptsMarketing,
|
|
3019
|
-
onChange: (e) => {
|
|
3020
|
-
edited.current = true;
|
|
3021
|
-
setForm((f) => ({ ...f, acceptsMarketing: e.target.checked }));
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
),
|
|
3025
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: t.profile.acceptsMarketing })
|
|
3026
|
-
] }),
|
|
3027
3060
|
error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3028
3061
|
notice ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
3029
3062
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
@@ -3176,7 +3209,7 @@ function AddressesPanel(props) {
|
|
|
3176
3209
|
})
|
|
3177
3210
|
}
|
|
3178
3211
|
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
3179
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }),
|
|
3212
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
|
|
3180
3213
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3181
3214
|
PanelState,
|
|
3182
3215
|
{
|
|
@@ -3283,7 +3316,102 @@ function AddressesPanel(props) {
|
|
|
3283
3316
|
}
|
|
3284
3317
|
|
|
3285
3318
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3319
|
+
var import_react25 = require("react");
|
|
3320
|
+
|
|
3321
|
+
// src/react/components/account/AddCardDialog.tsx
|
|
3322
|
+
var import_react24 = require("react");
|
|
3286
3323
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3324
|
+
function AddCardDialog(props) {
|
|
3325
|
+
const { account } = useAuth();
|
|
3326
|
+
const titleId = (0, import_react24.useId)();
|
|
3327
|
+
const { t } = useCopy(props.localization);
|
|
3328
|
+
const [src, setSrc] = (0, import_react24.useState)(null);
|
|
3329
|
+
const [error, setError] = (0, import_react24.useState)(null);
|
|
3330
|
+
const [busy, setBusy] = (0, import_react24.useState)(false);
|
|
3331
|
+
const onAdded = (0, import_react24.useRef)(props.onAdded);
|
|
3332
|
+
const onClose = (0, import_react24.useRef)(props.onClose);
|
|
3333
|
+
onAdded.current = props.onAdded;
|
|
3334
|
+
onClose.current = props.onClose;
|
|
3335
|
+
(0, import_react24.useEffect)(() => {
|
|
3336
|
+
if (!props.open) {
|
|
3337
|
+
setSrc(null);
|
|
3338
|
+
setError(null);
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
let live = true;
|
|
3342
|
+
setError(null);
|
|
3343
|
+
account.startCardSetup().then(
|
|
3344
|
+
(session) => {
|
|
3345
|
+
if (!live) return;
|
|
3346
|
+
let url = session.embedUrl;
|
|
3347
|
+
try {
|
|
3348
|
+
const u = new URL(session.embedUrl, window.location.origin);
|
|
3349
|
+
u.searchParams.set("parentOrigin", window.location.origin);
|
|
3350
|
+
url = u.toString();
|
|
3351
|
+
} catch {
|
|
3352
|
+
}
|
|
3353
|
+
setSrc(url);
|
|
3354
|
+
},
|
|
3355
|
+
(err) => {
|
|
3356
|
+
if (live) setError(messageForError(err));
|
|
3357
|
+
}
|
|
3358
|
+
);
|
|
3359
|
+
return () => {
|
|
3360
|
+
live = false;
|
|
3361
|
+
};
|
|
3362
|
+
}, [props.open, account]);
|
|
3363
|
+
(0, import_react24.useEffect)(() => {
|
|
3364
|
+
if (!src) return;
|
|
3365
|
+
const frameOrigin = (() => {
|
|
3366
|
+
try {
|
|
3367
|
+
return new URL(src).origin;
|
|
3368
|
+
} catch {
|
|
3369
|
+
return null;
|
|
3370
|
+
}
|
|
3371
|
+
})();
|
|
3372
|
+
if (!frameOrigin) return;
|
|
3373
|
+
async function onMessage(event) {
|
|
3374
|
+
if (event.origin !== frameOrigin) return;
|
|
3375
|
+
const data = event.data;
|
|
3376
|
+
if (!data || typeof data.type !== "string") return;
|
|
3377
|
+
if (data.type === "throttle.completed" && data.paymentId) {
|
|
3378
|
+
setBusy(true);
|
|
3379
|
+
try {
|
|
3380
|
+
await account.confirmCardSetup(data.paymentId);
|
|
3381
|
+
onAdded.current();
|
|
3382
|
+
onClose.current();
|
|
3383
|
+
} catch (err) {
|
|
3384
|
+
setError(messageForError(err));
|
|
3385
|
+
} finally {
|
|
3386
|
+
setBusy(false);
|
|
3387
|
+
}
|
|
3388
|
+
} else if (data.type === "throttle.error") {
|
|
3389
|
+
setError(data.message || t.common.somethingWentWrong);
|
|
3390
|
+
} else if (data.type === "throttle.cancelled") {
|
|
3391
|
+
onClose.current();
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
window.addEventListener("message", onMessage);
|
|
3395
|
+
return () => window.removeEventListener("message", onMessage);
|
|
3396
|
+
}, [src, account, t]);
|
|
3397
|
+
if (!props.open) return null;
|
|
3398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h2", { id: titleId, children: t.paymentMethods.addTitle }),
|
|
3400
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3401
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Spinner, {}) }) : src ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3402
|
+
"iframe",
|
|
3403
|
+
{
|
|
3404
|
+
className: "throttle-cardframe",
|
|
3405
|
+
src,
|
|
3406
|
+
title: t.paymentMethods.addTitle,
|
|
3407
|
+
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
3408
|
+
}
|
|
3409
|
+
) : !error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Spinner, {}) }) : null
|
|
3410
|
+
] });
|
|
3411
|
+
}
|
|
3412
|
+
|
|
3413
|
+
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3414
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3287
3415
|
function PaymentMethodsPanel(props) {
|
|
3288
3416
|
const a = useAppearance(props.appearance);
|
|
3289
3417
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3291,6 +3419,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3291
3419
|
const { emailVerified } = useAuth();
|
|
3292
3420
|
const resource = useSavedCards();
|
|
3293
3421
|
const { submitting, error, run } = useAction();
|
|
3422
|
+
const [adding, setAdding] = (0, import_react25.useState)(false);
|
|
3294
3423
|
const variant = props.variant ?? "rows";
|
|
3295
3424
|
const rowsVariant = variant === "rows";
|
|
3296
3425
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -3298,9 +3427,21 @@ function PaymentMethodsPanel(props) {
|
|
|
3298
3427
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3299
3428
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
3300
3429
|
const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
|
|
3301
|
-
return /* @__PURE__ */ (0,
|
|
3302
|
-
error ? /* @__PURE__ */ (0,
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
3430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
|
|
3431
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3432
|
+
emailVerified ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3434
|
+
AddCardDialog,
|
|
3435
|
+
{
|
|
3436
|
+
open: adding,
|
|
3437
|
+
onClose: () => setAdding(false),
|
|
3438
|
+
onAdded: () => {
|
|
3439
|
+
void resource.refetch();
|
|
3440
|
+
},
|
|
3441
|
+
localization: props.localization
|
|
3442
|
+
}
|
|
3443
|
+
),
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3304
3445
|
PanelState,
|
|
3305
3446
|
{
|
|
3306
3447
|
resource,
|
|
@@ -3309,7 +3450,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3309
3450
|
isEmpty: (rows) => rows.length === 0,
|
|
3310
3451
|
emptyTitle: t.paymentMethods.empty,
|
|
3311
3452
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
3312
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3453
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3313
3454
|
DataTable,
|
|
3314
3455
|
{
|
|
3315
3456
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -3319,9 +3460,9 @@ function PaymentMethodsPanel(props) {
|
|
|
3319
3460
|
columns: [
|
|
3320
3461
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
3321
3462
|
{ key: "expires", label: t.paymentMethods.expires, render: (card) => expiryLabel(card) },
|
|
3322
|
-
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0,
|
|
3323
|
-
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0,
|
|
3324
|
-
!card.isDefault ? /* @__PURE__ */ (0,
|
|
3463
|
+
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
|
|
3464
|
+
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-actions", children: [
|
|
3465
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3325
3466
|
Button,
|
|
3326
3467
|
{
|
|
3327
3468
|
variant: "secondary",
|
|
@@ -3331,7 +3472,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3331
3472
|
children: t.paymentMethods.makeDefault
|
|
3332
3473
|
}
|
|
3333
3474
|
) : null,
|
|
3334
|
-
/* @__PURE__ */ (0,
|
|
3475
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3335
3476
|
Button,
|
|
3336
3477
|
{
|
|
3337
3478
|
variant: "danger",
|
|
@@ -3347,13 +3488,13 @@ function PaymentMethodsPanel(props) {
|
|
|
3347
3488
|
] }) }
|
|
3348
3489
|
]
|
|
3349
3490
|
}
|
|
3350
|
-
) : /* @__PURE__ */ (0,
|
|
3351
|
-
/* @__PURE__ */ (0,
|
|
3352
|
-
/* @__PURE__ */ (0,
|
|
3353
|
-
/* @__PURE__ */ (0,
|
|
3354
|
-
card.isDefault ? /* @__PURE__ */ (0,
|
|
3491
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
|
|
3492
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { children: [
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-row", children: [
|
|
3494
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("strong", { children: cardLabel(card) }),
|
|
3495
|
+
card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
|
|
3355
3496
|
] }),
|
|
3356
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0,
|
|
3497
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("p", { className: "throttle-muted", children: [
|
|
3357
3498
|
t.paymentMethods.expires,
|
|
3358
3499
|
" ",
|
|
3359
3500
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -3361,8 +3502,8 @@ function PaymentMethodsPanel(props) {
|
|
|
3361
3502
|
card.cardExpYear
|
|
3362
3503
|
] }) : null
|
|
3363
3504
|
] }),
|
|
3364
|
-
/* @__PURE__ */ (0,
|
|
3365
|
-
!card.isDefault ? /* @__PURE__ */ (0,
|
|
3505
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-actions", children: [
|
|
3506
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3366
3507
|
Button,
|
|
3367
3508
|
{
|
|
3368
3509
|
variant: actionVariant("secondary"),
|
|
@@ -3372,7 +3513,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3372
3513
|
children: t.paymentMethods.makeDefault
|
|
3373
3514
|
}
|
|
3374
3515
|
) : null,
|
|
3375
|
-
/* @__PURE__ */ (0,
|
|
3516
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3376
3517
|
Button,
|
|
3377
3518
|
{
|
|
3378
3519
|
variant: actionVariant("danger"),
|
|
@@ -3393,7 +3534,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3393
3534
|
}
|
|
3394
3535
|
|
|
3395
3536
|
// src/react/components/account/OrdersPanel.tsx
|
|
3396
|
-
var
|
|
3537
|
+
var import_react26 = require("react");
|
|
3397
3538
|
|
|
3398
3539
|
// src/react/components/format.ts
|
|
3399
3540
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -3425,7 +3566,7 @@ function formatDate(value, locale) {
|
|
|
3425
3566
|
}
|
|
3426
3567
|
|
|
3427
3568
|
// src/react/components/account/OrderStatus.tsx
|
|
3428
|
-
var
|
|
3569
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3429
3570
|
function copyKey(wire) {
|
|
3430
3571
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
3431
3572
|
}
|
|
@@ -3433,25 +3574,25 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
3433
3574
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
3434
3575
|
function StatusBadge(props) {
|
|
3435
3576
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3436
|
-
return /* @__PURE__ */ (0,
|
|
3577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
3437
3578
|
}
|
|
3438
3579
|
function OrderStatus(props) {
|
|
3439
3580
|
const labels = props.t.orders.statusLabels;
|
|
3440
3581
|
const payLabels = props.t.orders.paymentLabels;
|
|
3441
3582
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3442
3583
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
3443
|
-
return /* @__PURE__ */ (0,
|
|
3444
|
-
/* @__PURE__ */ (0,
|
|
3445
|
-
money ? /* @__PURE__ */ (0,
|
|
3584
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
3585
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
|
|
3586
|
+
money ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
|
|
3446
3587
|
] });
|
|
3447
3588
|
}
|
|
3448
3589
|
|
|
3449
3590
|
// src/react/components/account/OrderDetail.tsx
|
|
3450
|
-
var
|
|
3591
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3451
3592
|
function Line(props) {
|
|
3452
|
-
return /* @__PURE__ */ (0,
|
|
3453
|
-
/* @__PURE__ */ (0,
|
|
3454
|
-
/* @__PURE__ */ (0,
|
|
3593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "throttle-row", children: [
|
|
3594
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
3595
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: props.value })
|
|
3455
3596
|
] });
|
|
3456
3597
|
}
|
|
3457
3598
|
function OrderDetail(props) {
|
|
@@ -3459,7 +3600,7 @@ function OrderDetail(props) {
|
|
|
3459
3600
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3460
3601
|
const { t, locale } = useCopy(props.localization);
|
|
3461
3602
|
const resource = useOrder(props.orderId);
|
|
3462
|
-
return /* @__PURE__ */ (0,
|
|
3603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
|
|
3463
3604
|
props.onBack ? (
|
|
3464
3605
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3465
3606
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3467,27 +3608,27 @@ function OrderDetail(props) {
|
|
|
3467
3608
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3468
3609
|
// its own width. A CSS fix would need a compound selector, and
|
|
3469
3610
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3470
|
-
/* @__PURE__ */ (0,
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3471
3612
|
) : null,
|
|
3472
|
-
/* @__PURE__ */ (0,
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3473
3614
|
PanelState,
|
|
3474
3615
|
{
|
|
3475
3616
|
resource,
|
|
3476
3617
|
isEmpty: (o) => o === null,
|
|
3477
3618
|
emptyTitle: t.orders.empty,
|
|
3478
3619
|
skeletonRows: 5,
|
|
3479
|
-
children: (order) => /* @__PURE__ */ (0,
|
|
3480
|
-
/* @__PURE__ */ (0,
|
|
3481
|
-
/* @__PURE__ */ (0,
|
|
3482
|
-
/* @__PURE__ */ (0,
|
|
3620
|
+
children: (order) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3621
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "throttle-row", children: [
|
|
3622
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h3", { children: order.orderNumber }),
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
|
|
3483
3624
|
] }),
|
|
3484
|
-
/* @__PURE__ */ (0,
|
|
3485
|
-
/* @__PURE__ */ (0,
|
|
3486
|
-
item.imageUrl ? /* @__PURE__ */ (0,
|
|
3487
|
-
/* @__PURE__ */ (0,
|
|
3488
|
-
/* @__PURE__ */ (0,
|
|
3489
|
-
item.description ? /* @__PURE__ */ (0,
|
|
3490
|
-
/* @__PURE__ */ (0,
|
|
3625
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
|
|
3627
|
+
item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
|
|
3628
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { style: { flex: 1 }, children: [
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("strong", { children: item.name }),
|
|
3630
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "throttle-muted", children: item.description }) : null,
|
|
3631
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "throttle-muted", children: [
|
|
3491
3632
|
t.orders.quantity,
|
|
3492
3633
|
" ",
|
|
3493
3634
|
item.quantity,
|
|
@@ -3495,16 +3636,16 @@ function OrderDetail(props) {
|
|
|
3495
3636
|
formatMoney(item.unitPrice, order.currency, locale)
|
|
3496
3637
|
] })
|
|
3497
3638
|
] }),
|
|
3498
|
-
/* @__PURE__ */ (0,
|
|
3639
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: formatMoney(item.total, order.currency, locale) })
|
|
3499
3640
|
] }, item.id)) }),
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
3501
|
-
/* @__PURE__ */ (0,
|
|
3502
|
-
order.discountTotal ? /* @__PURE__ */ (0,
|
|
3503
|
-
/* @__PURE__ */ (0,
|
|
3504
|
-
/* @__PURE__ */ (0,
|
|
3505
|
-
/* @__PURE__ */ (0,
|
|
3641
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
|
|
3642
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
|
|
3643
|
+
order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
|
|
3646
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
|
|
3506
3647
|
] }),
|
|
3507
|
-
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0,
|
|
3648
|
+
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
|
|
3508
3649
|
] })
|
|
3509
3650
|
}
|
|
3510
3651
|
)
|
|
@@ -3512,20 +3653,20 @@ function OrderDetail(props) {
|
|
|
3512
3653
|
}
|
|
3513
3654
|
|
|
3514
3655
|
// src/react/components/account/OrdersPanel.tsx
|
|
3515
|
-
var
|
|
3656
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3516
3657
|
function OrdersPanel(props) {
|
|
3517
3658
|
const a = useAppearance(props.appearance);
|
|
3518
3659
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3519
3660
|
const { t, locale } = useCopy(props.localization);
|
|
3520
3661
|
const { emailVerified } = useAuth();
|
|
3521
3662
|
const resource = useOrders();
|
|
3522
|
-
const [openId, setOpenId] = (0,
|
|
3663
|
+
const [openId, setOpenId] = (0, import_react26.useState)(null);
|
|
3523
3664
|
const variant = props.variant ?? "table";
|
|
3524
3665
|
const rowsVariant = variant === "rows";
|
|
3525
3666
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3526
3667
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3527
3668
|
if (openId) {
|
|
3528
|
-
return /* @__PURE__ */ (0,
|
|
3669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3529
3670
|
OrderDetail,
|
|
3530
3671
|
{
|
|
3531
3672
|
orderId: openId,
|
|
@@ -3536,7 +3677,7 @@ function OrdersPanel(props) {
|
|
|
3536
3677
|
}
|
|
3537
3678
|
);
|
|
3538
3679
|
}
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
3680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3540
3681
|
PanelState,
|
|
3541
3682
|
{
|
|
3542
3683
|
resource,
|
|
@@ -3545,7 +3686,7 @@ function OrdersPanel(props) {
|
|
|
3545
3686
|
isEmpty: (rows) => rows.length === 0,
|
|
3546
3687
|
emptyTitle: t.orders.empty,
|
|
3547
3688
|
emptyDescription: t.orders.emptyDescription,
|
|
3548
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3689
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3549
3690
|
DataTable,
|
|
3550
3691
|
{
|
|
3551
3692
|
tableKey: "ordersPanel.table",
|
|
@@ -3559,25 +3700,25 @@ function OrdersPanel(props) {
|
|
|
3559
3700
|
{
|
|
3560
3701
|
key: "status",
|
|
3561
3702
|
label: t.orders.status,
|
|
3562
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
3703
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3563
3704
|
},
|
|
3564
3705
|
{
|
|
3565
3706
|
key: "total",
|
|
3566
3707
|
label: t.orders.total,
|
|
3567
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
3708
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
3568
3709
|
}
|
|
3569
3710
|
]
|
|
3570
3711
|
}
|
|
3571
|
-
) : /* @__PURE__ */ (0,
|
|
3572
|
-
/* @__PURE__ */ (0,
|
|
3573
|
-
/* @__PURE__ */ (0,
|
|
3574
|
-
/* @__PURE__ */ (0,
|
|
3575
|
-
/* @__PURE__ */ (0,
|
|
3712
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { ...a.el("ordersPanel.item", itemBase), children: [
|
|
3713
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { children: [
|
|
3714
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "throttle-row", children: [
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("strong", { children: o.orderNumber }),
|
|
3716
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3576
3717
|
] }),
|
|
3577
|
-
/* @__PURE__ */ (0,
|
|
3578
|
-
/* @__PURE__ */ (0,
|
|
3718
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
|
|
3719
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
|
|
3579
3720
|
] }),
|
|
3580
|
-
/* @__PURE__ */ (0,
|
|
3721
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3581
3722
|
Button,
|
|
3582
3723
|
{
|
|
3583
3724
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3592,14 +3733,14 @@ function OrdersPanel(props) {
|
|
|
3592
3733
|
}
|
|
3593
3734
|
|
|
3594
3735
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3595
|
-
var
|
|
3736
|
+
var import_react27 = require("react");
|
|
3596
3737
|
|
|
3597
3738
|
// src/react/components/account/InvoiceDetail.tsx
|
|
3598
|
-
var
|
|
3739
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3599
3740
|
function Line2(props) {
|
|
3600
|
-
return /* @__PURE__ */ (0,
|
|
3601
|
-
/* @__PURE__ */ (0,
|
|
3602
|
-
/* @__PURE__ */ (0,
|
|
3741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "throttle-row", children: [
|
|
3742
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
3743
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { children: props.value })
|
|
3603
3744
|
] });
|
|
3604
3745
|
}
|
|
3605
3746
|
function InvoiceDetail(props) {
|
|
@@ -3609,7 +3750,7 @@ function InvoiceDetail(props) {
|
|
|
3609
3750
|
const { account } = useAuth();
|
|
3610
3751
|
const resource = useInvoice(props.invoiceId);
|
|
3611
3752
|
const { submitting, error, run } = useAction();
|
|
3612
|
-
return /* @__PURE__ */ (0,
|
|
3753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
|
|
3613
3754
|
props.onBack ? (
|
|
3614
3755
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3615
3756
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3617,25 +3758,25 @@ function InvoiceDetail(props) {
|
|
|
3617
3758
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3618
3759
|
// its own width. A CSS fix would need a compound selector, and
|
|
3619
3760
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3620
|
-
/* @__PURE__ */ (0,
|
|
3761
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3621
3762
|
) : null,
|
|
3622
|
-
/* @__PURE__ */ (0,
|
|
3623
|
-
/* @__PURE__ */ (0,
|
|
3624
|
-
/* @__PURE__ */ (0,
|
|
3625
|
-
/* @__PURE__ */ (0,
|
|
3763
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
3764
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "throttle-row", children: [
|
|
3765
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { children: invoice.number }),
|
|
3766
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
|
|
3626
3767
|
] }),
|
|
3627
|
-
/* @__PURE__ */ (0,
|
|
3628
|
-
/* @__PURE__ */ (0,
|
|
3629
|
-
invoice.dueAt ? /* @__PURE__ */ (0,
|
|
3630
|
-
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0,
|
|
3768
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
|
|
3769
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
|
|
3770
|
+
invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
|
|
3771
|
+
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3631
3772
|
Line2,
|
|
3632
3773
|
{
|
|
3633
3774
|
label: t.invoices.period,
|
|
3634
3775
|
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
3635
3776
|
}
|
|
3636
3777
|
) : null,
|
|
3637
|
-
/* @__PURE__ */ (0,
|
|
3638
|
-
invoice.amountRefunded ? /* @__PURE__ */ (0,
|
|
3778
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
|
|
3779
|
+
invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3639
3780
|
Line2,
|
|
3640
3781
|
{
|
|
3641
3782
|
label: t.invoices.refunded,
|
|
@@ -3643,8 +3784,8 @@ function InvoiceDetail(props) {
|
|
|
3643
3784
|
}
|
|
3644
3785
|
) : null
|
|
3645
3786
|
] }),
|
|
3646
|
-
error ? /* @__PURE__ */ (0,
|
|
3647
|
-
/* @__PURE__ */ (0,
|
|
3787
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3788
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3648
3789
|
Button,
|
|
3649
3790
|
{
|
|
3650
3791
|
variant: "secondary",
|
|
@@ -3663,20 +3804,20 @@ function InvoiceDetail(props) {
|
|
|
3663
3804
|
}
|
|
3664
3805
|
|
|
3665
3806
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3666
|
-
var
|
|
3807
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3667
3808
|
function InvoicesPanel(props) {
|
|
3668
3809
|
const a = useAppearance(props.appearance);
|
|
3669
3810
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3670
3811
|
const { t, locale } = useCopy(props.localization);
|
|
3671
3812
|
const { emailVerified } = useAuth();
|
|
3672
3813
|
const resource = useInvoices();
|
|
3673
|
-
const [openId, setOpenId] = (0,
|
|
3814
|
+
const [openId, setOpenId] = (0, import_react27.useState)(null);
|
|
3674
3815
|
const variant = props.variant ?? "table";
|
|
3675
3816
|
const rowsVariant = variant === "rows";
|
|
3676
3817
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3677
3818
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3678
3819
|
if (openId) {
|
|
3679
|
-
return /* @__PURE__ */ (0,
|
|
3820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3680
3821
|
InvoiceDetail,
|
|
3681
3822
|
{
|
|
3682
3823
|
invoiceId: openId,
|
|
@@ -3686,7 +3827,7 @@ function InvoicesPanel(props) {
|
|
|
3686
3827
|
}
|
|
3687
3828
|
);
|
|
3688
3829
|
}
|
|
3689
|
-
return /* @__PURE__ */ (0,
|
|
3830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3690
3831
|
PanelState,
|
|
3691
3832
|
{
|
|
3692
3833
|
resource,
|
|
@@ -3695,7 +3836,7 @@ function InvoicesPanel(props) {
|
|
|
3695
3836
|
isEmpty: (rows) => rows.length === 0,
|
|
3696
3837
|
emptyTitle: t.invoices.empty,
|
|
3697
3838
|
emptyDescription: t.invoices.emptyDescription,
|
|
3698
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3839
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3699
3840
|
DataTable,
|
|
3700
3841
|
{
|
|
3701
3842
|
tableKey: "invoicesPanel.table",
|
|
@@ -3706,24 +3847,24 @@ function InvoicesPanel(props) {
|
|
|
3706
3847
|
columns: [
|
|
3707
3848
|
{ key: "number", label: t.invoices.number },
|
|
3708
3849
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
3709
|
-
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0,
|
|
3850
|
+
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
|
|
3710
3851
|
{
|
|
3711
3852
|
key: "total",
|
|
3712
3853
|
label: t.invoices.total,
|
|
3713
|
-
render: (i) => /* @__PURE__ */ (0,
|
|
3854
|
+
render: (i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
3714
3855
|
}
|
|
3715
3856
|
]
|
|
3716
3857
|
}
|
|
3717
|
-
) : /* @__PURE__ */ (0,
|
|
3718
|
-
/* @__PURE__ */ (0,
|
|
3719
|
-
/* @__PURE__ */ (0,
|
|
3720
|
-
/* @__PURE__ */ (0,
|
|
3721
|
-
/* @__PURE__ */ (0,
|
|
3858
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("invoicesPanel.item", itemBase), children: [
|
|
3859
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { children: [
|
|
3860
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
|
|
3861
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: i.number }),
|
|
3862
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
|
|
3722
3863
|
] }),
|
|
3723
|
-
/* @__PURE__ */ (0,
|
|
3724
|
-
/* @__PURE__ */ (0,
|
|
3864
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
|
|
3725
3866
|
] }),
|
|
3726
|
-
/* @__PURE__ */ (0,
|
|
3867
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3727
3868
|
Button,
|
|
3728
3869
|
{
|
|
3729
3870
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3738,7 +3879,7 @@ function InvoicesPanel(props) {
|
|
|
3738
3879
|
}
|
|
3739
3880
|
|
|
3740
3881
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3741
|
-
var
|
|
3882
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3742
3883
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
3743
3884
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
3744
3885
|
var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
@@ -3760,8 +3901,8 @@ function SubscriptionsPanel(props) {
|
|
|
3760
3901
|
};
|
|
3761
3902
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3762
3903
|
const renewsLabel = (sub) => formatDate(sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd, locale);
|
|
3763
|
-
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0,
|
|
3764
|
-
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0,
|
|
3904
|
+
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-actions", children: [
|
|
3905
|
+
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3765
3906
|
Button,
|
|
3766
3907
|
{
|
|
3767
3908
|
variant: variantFor("secondary"),
|
|
@@ -3771,7 +3912,7 @@ function SubscriptionsPanel(props) {
|
|
|
3771
3912
|
children: t.subscriptions.pauseButton
|
|
3772
3913
|
}
|
|
3773
3914
|
) : null,
|
|
3774
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0,
|
|
3915
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3775
3916
|
Button,
|
|
3776
3917
|
{
|
|
3777
3918
|
variant: variantFor("secondary"),
|
|
@@ -3781,7 +3922,7 @@ function SubscriptionsPanel(props) {
|
|
|
3781
3922
|
children: t.subscriptions.resumeButton
|
|
3782
3923
|
}
|
|
3783
3924
|
) : null,
|
|
3784
|
-
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
3925
|
+
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3785
3926
|
Button,
|
|
3786
3927
|
{
|
|
3787
3928
|
variant: variantFor("secondary"),
|
|
@@ -3791,7 +3932,7 @@ function SubscriptionsPanel(props) {
|
|
|
3791
3932
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
3792
3933
|
}
|
|
3793
3934
|
) : null,
|
|
3794
|
-
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0,
|
|
3935
|
+
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3795
3936
|
Button,
|
|
3796
3937
|
{
|
|
3797
3938
|
variant: variantFor("danger"),
|
|
@@ -3802,9 +3943,9 @@ function SubscriptionsPanel(props) {
|
|
|
3802
3943
|
}
|
|
3803
3944
|
) : null
|
|
3804
3945
|
] });
|
|
3805
|
-
return /* @__PURE__ */ (0,
|
|
3806
|
-
error ? /* @__PURE__ */ (0,
|
|
3807
|
-
/* @__PURE__ */ (0,
|
|
3946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
|
|
3947
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3808
3949
|
PanelState,
|
|
3809
3950
|
{
|
|
3810
3951
|
resource,
|
|
@@ -3813,7 +3954,7 @@ function SubscriptionsPanel(props) {
|
|
|
3813
3954
|
isEmpty: (rows) => rows.length === 0,
|
|
3814
3955
|
emptyTitle: t.subscriptions.empty,
|
|
3815
3956
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
3816
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3957
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3817
3958
|
DataTable,
|
|
3818
3959
|
{
|
|
3819
3960
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -3822,42 +3963,42 @@ function SubscriptionsPanel(props) {
|
|
|
3822
3963
|
rows,
|
|
3823
3964
|
columns: [
|
|
3824
3965
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
3825
|
-
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0,
|
|
3966
|
+
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
3826
3967
|
{ key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
|
|
3827
|
-
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0,
|
|
3828
|
-
/* @__PURE__ */ (0,
|
|
3829
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
3968
|
+
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
|
|
3969
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
|
|
3970
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3830
3971
|
] }) },
|
|
3831
3972
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
3832
3973
|
]
|
|
3833
3974
|
}
|
|
3834
|
-
) : /* @__PURE__ */ (0,
|
|
3835
|
-
/* @__PURE__ */ (0,
|
|
3836
|
-
/* @__PURE__ */ (0,
|
|
3837
|
-
/* @__PURE__ */ (0,
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
3975
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
|
|
3976
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
|
|
3977
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
|
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("strong", { children: sub.planName ?? sub.planReference }),
|
|
3979
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
3839
3980
|
] }),
|
|
3840
|
-
/* @__PURE__ */ (0,
|
|
3981
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "throttle-muted", children: [
|
|
3841
3982
|
formatMoney(sub.amount, sub.currency, locale),
|
|
3842
3983
|
" / ",
|
|
3843
3984
|
sub.interval,
|
|
3844
3985
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3845
3986
|
] }),
|
|
3846
|
-
sub.status === "cancelled" ? /* @__PURE__ */ (0,
|
|
3987
|
+
sub.status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "throttle-muted", children: [
|
|
3847
3988
|
t.subscriptions.cancelledOn,
|
|
3848
3989
|
" ",
|
|
3849
3990
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
3850
|
-
] }) : /* @__PURE__ */ (0,
|
|
3991
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "throttle-muted", children: [
|
|
3851
3992
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
3852
3993
|
" ",
|
|
3853
3994
|
formatDate(sub.currentPeriodEnd, locale)
|
|
3854
3995
|
] }),
|
|
3855
|
-
sub.trialEnd ? /* @__PURE__ */ (0,
|
|
3996
|
+
sub.trialEnd ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "throttle-muted", children: [
|
|
3856
3997
|
t.subscriptions.trialEnds,
|
|
3857
3998
|
" ",
|
|
3858
3999
|
formatDate(sub.trialEnd, locale)
|
|
3859
4000
|
] }) : null,
|
|
3860
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
4001
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3861
4002
|
] }),
|
|
3862
4003
|
lifecycleActions(sub, actionVariant)
|
|
3863
4004
|
] }, sub.id)) })
|
|
@@ -3867,7 +4008,7 @@ function SubscriptionsPanel(props) {
|
|
|
3867
4008
|
}
|
|
3868
4009
|
|
|
3869
4010
|
// src/react/components/account/SecurityPanel.tsx
|
|
3870
|
-
var
|
|
4011
|
+
var import_react28 = require("react");
|
|
3871
4012
|
|
|
3872
4013
|
// src/react/components/account/device.ts
|
|
3873
4014
|
var BROWSERS = [
|
|
@@ -3900,7 +4041,7 @@ function describeDevice(userAgent) {
|
|
|
3900
4041
|
}
|
|
3901
4042
|
|
|
3902
4043
|
// src/react/components/account/SecurityPanel.tsx
|
|
3903
|
-
var
|
|
4044
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3904
4045
|
function SecurityPanel(props) {
|
|
3905
4046
|
const a = useAppearance(props.appearance);
|
|
3906
4047
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3910,16 +4051,16 @@ function SecurityPanel(props) {
|
|
|
3910
4051
|
const rowsVariant = variant === "rows";
|
|
3911
4052
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3912
4053
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
3913
|
-
const [password, setPassword] = (0,
|
|
4054
|
+
const [password, setPassword] = (0, import_react28.useState)("");
|
|
3914
4055
|
const passwordAction = useAction();
|
|
3915
4056
|
const sessionAction = useAction();
|
|
3916
|
-
const [sessions, setSessions] = (0,
|
|
3917
|
-
const [listError, setListError] = (0,
|
|
3918
|
-
const errorMessageRef = (0,
|
|
3919
|
-
(0,
|
|
4057
|
+
const [sessions, setSessions] = (0, import_react28.useState)(null);
|
|
4058
|
+
const [listError, setListError] = (0, import_react28.useState)(null);
|
|
4059
|
+
const errorMessageRef = (0, import_react28.useRef)(errorMessage);
|
|
4060
|
+
(0, import_react28.useEffect)(() => {
|
|
3920
4061
|
errorMessageRef.current = errorMessage;
|
|
3921
4062
|
});
|
|
3922
|
-
const load = (0,
|
|
4063
|
+
const load = (0, import_react28.useCallback)(async () => {
|
|
3923
4064
|
try {
|
|
3924
4065
|
setSessions(await auth.listSessions());
|
|
3925
4066
|
setListError(null);
|
|
@@ -3927,12 +4068,12 @@ function SecurityPanel(props) {
|
|
|
3927
4068
|
setListError(errorMessageRef.current(err));
|
|
3928
4069
|
}
|
|
3929
4070
|
}, [auth]);
|
|
3930
|
-
(0,
|
|
4071
|
+
(0, import_react28.useEffect)(() => {
|
|
3931
4072
|
void load();
|
|
3932
4073
|
}, [load]);
|
|
3933
4074
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
3934
|
-
return /* @__PURE__ */ (0,
|
|
3935
|
-
/* @__PURE__ */ (0,
|
|
4075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
|
|
4076
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
3936
4077
|
"form",
|
|
3937
4078
|
{
|
|
3938
4079
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -3945,8 +4086,8 @@ function SecurityPanel(props) {
|
|
|
3945
4086
|
});
|
|
3946
4087
|
},
|
|
3947
4088
|
children: [
|
|
3948
|
-
/* @__PURE__ */ (0,
|
|
3949
|
-
/* @__PURE__ */ (0,
|
|
4089
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: t.security.passwordTitle }),
|
|
4090
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3950
4091
|
Field,
|
|
3951
4092
|
{
|
|
3952
4093
|
label: t.security.newPassword,
|
|
@@ -3957,21 +4098,21 @@ function SecurityPanel(props) {
|
|
|
3957
4098
|
onChange: setPassword
|
|
3958
4099
|
}
|
|
3959
4100
|
),
|
|
3960
|
-
passwordAction.error ? /* @__PURE__ */ (0,
|
|
3961
|
-
passwordAction.notice ? /* @__PURE__ */ (0,
|
|
3962
|
-
/* @__PURE__ */ (0,
|
|
4101
|
+
passwordAction.error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: passwordAction.error }) : null,
|
|
4102
|
+
passwordAction.notice ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "success", children: passwordAction.notice }) : null,
|
|
4103
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
|
|
3963
4104
|
]
|
|
3964
4105
|
}
|
|
3965
4106
|
),
|
|
3966
|
-
/* @__PURE__ */ (0,
|
|
3967
|
-
/* @__PURE__ */ (0,
|
|
3968
|
-
listError ? /* @__PURE__ */ (0,
|
|
3969
|
-
/* @__PURE__ */ (0,
|
|
3970
|
-
/* @__PURE__ */ (0,
|
|
4107
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
|
|
4108
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: t.security.sessionsTitle }),
|
|
4109
|
+
listError ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
4110
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: listError }),
|
|
4111
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
|
|
3971
4112
|
] }) : null,
|
|
3972
|
-
sessionAction.error ? /* @__PURE__ */ (0,
|
|
3973
|
-
sessions === null && !listError ? /* @__PURE__ */ (0,
|
|
3974
|
-
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0,
|
|
4113
|
+
sessionAction.error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: sessionAction.error }) : null,
|
|
4114
|
+
sessions === null && !listError ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Skeleton, { count: 2 }) : null,
|
|
4115
|
+
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3975
4116
|
DataTable,
|
|
3976
4117
|
{
|
|
3977
4118
|
tableKey: "securityPanel.table",
|
|
@@ -3979,12 +4120,12 @@ function SecurityPanel(props) {
|
|
|
3979
4120
|
rowKey: (session) => session.id,
|
|
3980
4121
|
rows: sessions,
|
|
3981
4122
|
columns: [
|
|
3982
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0,
|
|
3983
|
-
/* @__PURE__ */ (0,
|
|
3984
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4123
|
+
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4125
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3985
4126
|
] }) },
|
|
3986
4127
|
{ key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
|
|
3987
|
-
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0,
|
|
4128
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3988
4129
|
Button,
|
|
3989
4130
|
{
|
|
3990
4131
|
variant: "danger",
|
|
@@ -3999,19 +4140,19 @@ function SecurityPanel(props) {
|
|
|
3999
4140
|
) : null }
|
|
4000
4141
|
]
|
|
4001
4142
|
}
|
|
4002
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0,
|
|
4003
|
-
/* @__PURE__ */ (0,
|
|
4004
|
-
/* @__PURE__ */ (0,
|
|
4005
|
-
/* @__PURE__ */ (0,
|
|
4006
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4143
|
+
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
|
|
4144
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { children: [
|
|
4145
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
4146
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4147
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
4007
4148
|
] }),
|
|
4008
|
-
/* @__PURE__ */ (0,
|
|
4149
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-muted", children: [
|
|
4009
4150
|
t.security.lastActive,
|
|
4010
4151
|
" ",
|
|
4011
4152
|
formatDate(session.lastUsedAt, locale)
|
|
4012
4153
|
] })
|
|
4013
4154
|
] }),
|
|
4014
|
-
!session.current ? /* @__PURE__ */ (0,
|
|
4155
|
+
!session.current ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4015
4156
|
Button,
|
|
4016
4157
|
{
|
|
4017
4158
|
variant: revokeVariant,
|
|
@@ -4025,8 +4166,8 @@ function SecurityPanel(props) {
|
|
|
4025
4166
|
}
|
|
4026
4167
|
) : null
|
|
4027
4168
|
] }, session.id)),
|
|
4028
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0,
|
|
4029
|
-
others.length > 0 ? /* @__PURE__ */ (0,
|
|
4169
|
+
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
|
|
4170
|
+
others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4030
4171
|
Button,
|
|
4031
4172
|
{
|
|
4032
4173
|
variant: "danger",
|
|
@@ -4046,7 +4187,7 @@ function SecurityPanel(props) {
|
|
|
4046
4187
|
}
|
|
4047
4188
|
|
|
4048
4189
|
// src/react/components/account/AccountDashboard.tsx
|
|
4049
|
-
var
|
|
4190
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4050
4191
|
var ACCOUNT_TABS = [
|
|
4051
4192
|
"profile",
|
|
4052
4193
|
"addresses",
|
|
@@ -4075,9 +4216,9 @@ function AccountDashboard(props) {
|
|
|
4075
4216
|
const { status } = useAuth();
|
|
4076
4217
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
4077
4218
|
const controlled = props.tab !== void 0;
|
|
4078
|
-
const [internal, setInternal] = (0,
|
|
4079
|
-
const idBase = (0,
|
|
4080
|
-
(0,
|
|
4219
|
+
const [internal, setInternal] = (0, import_react29.useState)(shown[0] ?? "profile");
|
|
4220
|
+
const idBase = (0, import_react29.useId)();
|
|
4221
|
+
(0, import_react29.useEffect)(() => {
|
|
4081
4222
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
4082
4223
|
const apply = () => {
|
|
4083
4224
|
const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
|
|
@@ -4098,7 +4239,7 @@ function AccountDashboard(props) {
|
|
|
4098
4239
|
};
|
|
4099
4240
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
4100
4241
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
4101
|
-
const nav = /* @__PURE__ */ (0,
|
|
4242
|
+
const nav = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4102
4243
|
Tabs,
|
|
4103
4244
|
{
|
|
4104
4245
|
idBase,
|
|
@@ -4114,7 +4255,7 @@ function AccountDashboard(props) {
|
|
|
4114
4255
|
}))
|
|
4115
4256
|
}
|
|
4116
4257
|
);
|
|
4117
|
-
const panel = /* @__PURE__ */ (0,
|
|
4258
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
4118
4259
|
"div",
|
|
4119
4260
|
{
|
|
4120
4261
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -4123,36 +4264,36 @@ function AccountDashboard(props) {
|
|
|
4123
4264
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
4124
4265
|
tabIndex: 0,
|
|
4125
4266
|
children: [
|
|
4126
|
-
active === "profile" ? /* @__PURE__ */ (0,
|
|
4127
|
-
active === "addresses" ? /* @__PURE__ */ (0,
|
|
4128
|
-
active === "paymentMethods" ? /* @__PURE__ */ (0,
|
|
4129
|
-
active === "orders" ? /* @__PURE__ */ (0,
|
|
4130
|
-
active === "invoices" ? /* @__PURE__ */ (0,
|
|
4131
|
-
active === "subscriptions" ? /* @__PURE__ */ (0,
|
|
4132
|
-
active === "security" ? /* @__PURE__ */ (0,
|
|
4267
|
+
active === "profile" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ProfilePanel, { ...shared }) : null,
|
|
4268
|
+
active === "addresses" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4269
|
+
active === "paymentMethods" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4270
|
+
active === "orders" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(OrdersPanel, { ...shared, variant: props.panelVariant, onViewSubscription: () => go("subscriptions") }) : null,
|
|
4271
|
+
active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4272
|
+
active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4273
|
+
active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
|
|
4133
4274
|
]
|
|
4134
4275
|
}
|
|
4135
4276
|
);
|
|
4136
|
-
return /* @__PURE__ */ (0,
|
|
4137
|
-
/* @__PURE__ */ (0,
|
|
4138
|
-
sidebar ? /* @__PURE__ */ (0,
|
|
4139
|
-
/* @__PURE__ */ (0,
|
|
4277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
|
|
4278
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(VerifyEmailBanner, { ...shared }),
|
|
4279
|
+
sidebar ? /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-account", children: [
|
|
4280
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
|
|
4140
4281
|
panel
|
|
4141
|
-
] }) : /* @__PURE__ */ (0,
|
|
4142
|
-
/* @__PURE__ */ (0,
|
|
4282
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
4283
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
4143
4284
|
panel
|
|
4144
4285
|
] })
|
|
4145
4286
|
] }) }) });
|
|
4146
4287
|
}
|
|
4147
4288
|
|
|
4148
4289
|
// src/react/components/account/AccountModal.tsx
|
|
4149
|
-
var
|
|
4290
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4150
4291
|
function AccountModal(props) {
|
|
4151
4292
|
const a = useAppearance(props.appearance);
|
|
4152
4293
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4153
4294
|
const { t } = useCopy(props.localization);
|
|
4154
|
-
const titleId = (0,
|
|
4155
|
-
return /* @__PURE__ */ (0,
|
|
4295
|
+
const titleId = (0, import_react30.useId)();
|
|
4296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
4156
4297
|
Modal,
|
|
4157
4298
|
{
|
|
4158
4299
|
open: props.open,
|
|
@@ -4162,15 +4303,15 @@ function AccountModal(props) {
|
|
|
4162
4303
|
overlayKey: "accountModal.overlay",
|
|
4163
4304
|
containerKey: "accountModal.container",
|
|
4164
4305
|
children: [
|
|
4165
|
-
/* @__PURE__ */ (0,
|
|
4166
|
-
/* @__PURE__ */ (0,
|
|
4306
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
|
|
4167
4308
|
]
|
|
4168
4309
|
}
|
|
4169
4310
|
) });
|
|
4170
4311
|
}
|
|
4171
4312
|
|
|
4172
4313
|
// src/react/components/provider.tsx
|
|
4173
|
-
var
|
|
4314
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4174
4315
|
var warned = /* @__PURE__ */ new Set();
|
|
4175
4316
|
function warnOnce(key, message) {
|
|
4176
4317
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -4178,9 +4319,9 @@ function warnOnce(key, message) {
|
|
|
4178
4319
|
warned.add(key);
|
|
4179
4320
|
console.warn(`[@usethrottle/auth] ${message}`);
|
|
4180
4321
|
}
|
|
4181
|
-
var ThrottleUIContext = (0,
|
|
4322
|
+
var ThrottleUIContext = (0, import_react31.createContext)(null);
|
|
4182
4323
|
function useThrottle() {
|
|
4183
|
-
const ctx = (0,
|
|
4324
|
+
const ctx = (0, import_react31.useContext)(ThrottleUIContext);
|
|
4184
4325
|
if (!ctx) {
|
|
4185
4326
|
warnOnce(
|
|
4186
4327
|
"use-throttle-no-provider",
|
|
@@ -4215,51 +4356,51 @@ function ThrottleProvider(props) {
|
|
|
4215
4356
|
__captureStepUp
|
|
4216
4357
|
} = props;
|
|
4217
4358
|
useInjectStyles(injectStyles);
|
|
4218
|
-
const [stepUpOpen, setStepUpOpen] = (0,
|
|
4219
|
-
const resolveStepUp = (0,
|
|
4220
|
-
const claimRef = (0,
|
|
4359
|
+
const [stepUpOpen, setStepUpOpen] = (0, import_react31.useState)(false);
|
|
4360
|
+
const resolveStepUp = (0, import_react31.useRef)(null);
|
|
4361
|
+
const claimRef = (0, import_react31.useRef)(claimCartOnSignIn);
|
|
4221
4362
|
claimRef.current = claimCartOnSignIn;
|
|
4222
|
-
const [overlay, setOverlay] = (0,
|
|
4223
|
-
const overlayRestoreFocus = (0,
|
|
4224
|
-
const [accountTabs, setAccountTabs] = (0,
|
|
4225
|
-
const onOverlaySuccess = (0,
|
|
4226
|
-
const openSignIn = (0,
|
|
4363
|
+
const [overlay, setOverlay] = (0, import_react31.useState)(null);
|
|
4364
|
+
const overlayRestoreFocus = (0, import_react31.useRef)(null);
|
|
4365
|
+
const [accountTabs, setAccountTabs] = (0, import_react31.useState)(void 0);
|
|
4366
|
+
const onOverlaySuccess = (0, import_react31.useRef)(null);
|
|
4367
|
+
const openSignIn = (0, import_react31.useCallback)((onSuccess) => {
|
|
4227
4368
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4228
4369
|
setOverlay("signIn");
|
|
4229
4370
|
}, []);
|
|
4230
|
-
const openSignUp = (0,
|
|
4371
|
+
const openSignUp = (0, import_react31.useCallback)((onSuccess) => {
|
|
4231
4372
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4232
4373
|
setOverlay("signUp");
|
|
4233
4374
|
}, []);
|
|
4234
|
-
const openAccount = (0,
|
|
4375
|
+
const openAccount = (0, import_react31.useCallback)((opts) => {
|
|
4235
4376
|
onOverlaySuccess.current = null;
|
|
4236
4377
|
overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
|
|
4237
4378
|
setAccountTabs(opts?.tabs);
|
|
4238
4379
|
setOverlay("account");
|
|
4239
4380
|
}, []);
|
|
4240
|
-
const closeOverlay = (0,
|
|
4381
|
+
const closeOverlay = (0, import_react31.useCallback)(() => {
|
|
4241
4382
|
onOverlaySuccess.current = null;
|
|
4242
4383
|
overlayRestoreFocus.current = null;
|
|
4243
4384
|
setOverlay(null);
|
|
4244
4385
|
}, []);
|
|
4245
|
-
const handleOverlaySuccess = (0,
|
|
4386
|
+
const handleOverlaySuccess = (0, import_react31.useCallback)(() => {
|
|
4246
4387
|
const fn = onOverlaySuccess.current;
|
|
4247
4388
|
onOverlaySuccess.current = null;
|
|
4248
4389
|
setOverlay(null);
|
|
4249
4390
|
fn?.();
|
|
4250
4391
|
}, []);
|
|
4251
|
-
const ui = (0,
|
|
4392
|
+
const ui = (0, import_react31.useMemo)(
|
|
4252
4393
|
() => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
|
|
4253
4394
|
[overlay, openSignIn, openSignUp, openAccount, closeOverlay]
|
|
4254
4395
|
);
|
|
4255
|
-
const askForStepUp = (0,
|
|
4396
|
+
const askForStepUp = (0, import_react31.useCallback)(
|
|
4256
4397
|
() => new Promise((resolve) => {
|
|
4257
4398
|
resolveStepUp.current = resolve;
|
|
4258
4399
|
setStepUpOpen(true);
|
|
4259
4400
|
}),
|
|
4260
4401
|
[]
|
|
4261
4402
|
);
|
|
4262
|
-
const auth = (0,
|
|
4403
|
+
const auth = (0, import_react31.useMemo)(() => {
|
|
4263
4404
|
__captureStepUp?.(askForStepUp);
|
|
4264
4405
|
const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
|
|
4265
4406
|
const account = createAccount(client);
|
|
@@ -4292,10 +4433,10 @@ function ThrottleProvider(props) {
|
|
|
4292
4433
|
resolve?.(password);
|
|
4293
4434
|
};
|
|
4294
4435
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
4295
|
-
return /* @__PURE__ */ (0,
|
|
4436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
|
|
4296
4437
|
children,
|
|
4297
|
-
/* @__PURE__ */ (0,
|
|
4298
|
-
/* @__PURE__ */ (0,
|
|
4438
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
|
|
4439
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4299
4440
|
AuthModal,
|
|
4300
4441
|
{
|
|
4301
4442
|
open: authOverlayOpen,
|
|
@@ -4306,23 +4447,23 @@ function ThrottleProvider(props) {
|
|
|
4306
4447
|
},
|
|
4307
4448
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
4308
4449
|
),
|
|
4309
|
-
/* @__PURE__ */ (0,
|
|
4450
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
4310
4451
|
] }) }) }) }) });
|
|
4311
4452
|
}
|
|
4312
4453
|
|
|
4313
4454
|
// src/react/components/auth/SignInButton.tsx
|
|
4314
|
-
var
|
|
4315
|
-
var
|
|
4455
|
+
var import_react32 = require("react");
|
|
4456
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4316
4457
|
function SignInButton(props) {
|
|
4317
4458
|
const a = useAppearance(props.appearance);
|
|
4318
4459
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4319
4460
|
const { t } = useCopy(props.localization);
|
|
4320
|
-
const ui = (0,
|
|
4321
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4461
|
+
const ui = (0, import_react32.useContext)(ThrottleUIContext);
|
|
4462
|
+
const [localOpen, setLocalOpen] = (0, import_react32.useState)(false);
|
|
4322
4463
|
const useShared = ui !== null && props.initialView === void 0;
|
|
4323
4464
|
const label = props.children ?? t.signIn.submitButton;
|
|
4324
4465
|
if (props.mode === "redirect") {
|
|
4325
|
-
return /* @__PURE__ */ (0,
|
|
4466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
4326
4467
|
}
|
|
4327
4468
|
const openModal = () => {
|
|
4328
4469
|
if (useShared) ui.openSignIn(props.afterSignIn);
|
|
@@ -4332,10 +4473,10 @@ function SignInButton(props) {
|
|
|
4332
4473
|
if (useShared) ui.close();
|
|
4333
4474
|
else setLocalOpen(false);
|
|
4334
4475
|
};
|
|
4335
|
-
const trigger = props.asChild && (0,
|
|
4336
|
-
return /* @__PURE__ */ (0,
|
|
4337
|
-
/* @__PURE__ */ (0,
|
|
4338
|
-
!useShared ? /* @__PURE__ */ (0,
|
|
4476
|
+
const trigger = props.asChild && (0, import_react32.isValidElement)(props.children) ? (0, import_react32.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
|
|
4477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(AppearanceProvider, { value: scoped, children: [
|
|
4478
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { ...a.rootProps, children: trigger }),
|
|
4479
|
+
!useShared ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4339
4480
|
AuthModal,
|
|
4340
4481
|
{
|
|
4341
4482
|
open: localOpen,
|
|
@@ -4353,18 +4494,18 @@ function SignInButton(props) {
|
|
|
4353
4494
|
}
|
|
4354
4495
|
|
|
4355
4496
|
// src/react/components/auth/SignUpButton.tsx
|
|
4356
|
-
var
|
|
4357
|
-
var
|
|
4497
|
+
var import_react33 = require("react");
|
|
4498
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4358
4499
|
function SignUpButton(props) {
|
|
4359
4500
|
const a = useAppearance(props.appearance);
|
|
4360
4501
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4361
4502
|
const { t } = useCopy(props.localization);
|
|
4362
|
-
const ui = (0,
|
|
4363
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4503
|
+
const ui = (0, import_react33.useContext)(ThrottleUIContext);
|
|
4504
|
+
const [localOpen, setLocalOpen] = (0, import_react33.useState)(false);
|
|
4364
4505
|
const useShared = ui !== null && props.initialView === void 0;
|
|
4365
4506
|
const label = props.children ?? t.signUp.submitButton;
|
|
4366
4507
|
if (props.mode === "redirect") {
|
|
4367
|
-
return /* @__PURE__ */ (0,
|
|
4508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
4368
4509
|
}
|
|
4369
4510
|
const openModal = () => {
|
|
4370
4511
|
if (useShared) ui.openSignUp(props.afterSignUp);
|
|
@@ -4374,10 +4515,10 @@ function SignUpButton(props) {
|
|
|
4374
4515
|
if (useShared) ui.close();
|
|
4375
4516
|
else setLocalOpen(false);
|
|
4376
4517
|
};
|
|
4377
|
-
const trigger = props.asChild && (0,
|
|
4378
|
-
return /* @__PURE__ */ (0,
|
|
4379
|
-
/* @__PURE__ */ (0,
|
|
4380
|
-
!useShared ? /* @__PURE__ */ (0,
|
|
4518
|
+
const trigger = props.asChild && (0, import_react33.isValidElement)(props.children) ? (0, import_react33.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
|
|
4519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(AppearanceProvider, { value: scoped, children: [
|
|
4520
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { ...a.rootProps, children: trigger }),
|
|
4521
|
+
!useShared ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4381
4522
|
AuthModal,
|
|
4382
4523
|
{
|
|
4383
4524
|
open: localOpen,
|
|
@@ -4395,14 +4536,14 @@ function SignUpButton(props) {
|
|
|
4395
4536
|
}
|
|
4396
4537
|
|
|
4397
4538
|
// src/react/components/auth/SignOutButton.tsx
|
|
4398
|
-
var
|
|
4539
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4399
4540
|
function SignOutButton(props) {
|
|
4400
4541
|
const a = useAppearance();
|
|
4401
4542
|
const { auth } = useAuth();
|
|
4402
4543
|
const { t } = useCopy(props.localization);
|
|
4403
4544
|
const { submitting, run } = useAction();
|
|
4404
4545
|
const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
|
|
4405
|
-
return /* @__PURE__ */ (0,
|
|
4546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4406
4547
|
Button,
|
|
4407
4548
|
{
|
|
4408
4549
|
variant: "secondary",
|
|
@@ -4419,13 +4560,13 @@ function SignOutButton(props) {
|
|
|
4419
4560
|
}
|
|
4420
4561
|
|
|
4421
4562
|
// src/react/components/auth/SignInPage.tsx
|
|
4422
|
-
var
|
|
4563
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4423
4564
|
function SignInPage(props) {
|
|
4424
4565
|
const a = useAppearance(props.appearance);
|
|
4425
4566
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4426
|
-
return /* @__PURE__ */ (0,
|
|
4427
|
-
props.logo ? /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { ...a.el("signInPage.root", "throttle-page"), children: [
|
|
4568
|
+
props.logo ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4569
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4429
4570
|
SignIn,
|
|
4430
4571
|
{
|
|
4431
4572
|
onSuccess: props.onSuccess,
|
|
@@ -4435,18 +4576,18 @@ function SignInPage(props) {
|
|
|
4435
4576
|
localization: props.localization
|
|
4436
4577
|
}
|
|
4437
4578
|
),
|
|
4438
|
-
props.footer ? /* @__PURE__ */ (0,
|
|
4579
|
+
props.footer ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
4439
4580
|
] }) }) });
|
|
4440
4581
|
}
|
|
4441
4582
|
|
|
4442
4583
|
// src/react/components/auth/SignUpPage.tsx
|
|
4443
|
-
var
|
|
4584
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
4444
4585
|
function SignUpPage(props) {
|
|
4445
4586
|
const a = useAppearance(props.appearance);
|
|
4446
4587
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4447
|
-
return /* @__PURE__ */ (0,
|
|
4448
|
-
props.logo ? /* @__PURE__ */ (0,
|
|
4449
|
-
/* @__PURE__ */ (0,
|
|
4588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
|
|
4589
|
+
props.logo ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4590
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4450
4591
|
SignUp,
|
|
4451
4592
|
{
|
|
4452
4593
|
onSuccess: props.onSuccess,
|
|
@@ -4455,42 +4596,42 @@ function SignUpPage(props) {
|
|
|
4455
4596
|
localization: props.localization
|
|
4456
4597
|
}
|
|
4457
4598
|
),
|
|
4458
|
-
props.footer ? /* @__PURE__ */ (0,
|
|
4599
|
+
props.footer ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
4459
4600
|
] }) }) });
|
|
4460
4601
|
}
|
|
4461
4602
|
|
|
4462
4603
|
// src/react/components/guards.tsx
|
|
4463
|
-
var
|
|
4604
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
4464
4605
|
function SignedIn(props) {
|
|
4465
4606
|
const { status } = useAuth();
|
|
4466
|
-
return status === "authenticated" ? /* @__PURE__ */ (0,
|
|
4607
|
+
return status === "authenticated" ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: props.children }) : null;
|
|
4467
4608
|
}
|
|
4468
4609
|
function SignedOut(props) {
|
|
4469
4610
|
const { status } = useAuth();
|
|
4470
|
-
return status === "unauthenticated" ? /* @__PURE__ */ (0,
|
|
4611
|
+
return status === "unauthenticated" ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: props.children }) : null;
|
|
4471
4612
|
}
|
|
4472
4613
|
function Protect(props) {
|
|
4473
4614
|
const { status, emailVerified } = useAuth();
|
|
4474
4615
|
if (status === "loading") return null;
|
|
4475
|
-
if (status !== "authenticated") return /* @__PURE__ */ (0,
|
|
4476
|
-
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0,
|
|
4477
|
-
return /* @__PURE__ */ (0,
|
|
4616
|
+
if (status !== "authenticated") return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: props.fallback ?? null });
|
|
4617
|
+
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: props.fallback ?? null });
|
|
4618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_jsx_runtime50.Fragment, { children: props.children });
|
|
4478
4619
|
}
|
|
4479
4620
|
|
|
4480
4621
|
// src/react/components/UserButton.tsx
|
|
4481
|
-
var
|
|
4482
|
-
var
|
|
4622
|
+
var import_react34 = require("react");
|
|
4623
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
4483
4624
|
function UserButtonRoot(props) {
|
|
4484
4625
|
const a = useAppearance(props.appearance);
|
|
4485
4626
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4486
4627
|
const { t } = useCopy(props.localization);
|
|
4487
4628
|
const { auth, status, customer, emailVerified } = useAuth();
|
|
4488
|
-
const ui = (0,
|
|
4489
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4629
|
+
const ui = (0, import_react34.useContext)(ThrottleUIContext);
|
|
4630
|
+
const [localOpen, setLocalOpen] = (0, import_react34.useState)(false);
|
|
4490
4631
|
const accountOpen = ui ? false : localOpen;
|
|
4491
|
-
const titleId = (0,
|
|
4492
|
-
const rootRef = (0,
|
|
4493
|
-
const openerRef = (0,
|
|
4632
|
+
const titleId = (0, import_react34.useId)();
|
|
4633
|
+
const rootRef = (0, import_react34.useRef)(null);
|
|
4634
|
+
const openerRef = (0, import_react34.useRef)(null);
|
|
4494
4635
|
const openAccount = () => {
|
|
4495
4636
|
const opener = rootRef.current?.querySelector('button[aria-haspopup="menu"]') ?? null;
|
|
4496
4637
|
openerRef.current = opener;
|
|
@@ -4499,25 +4640,25 @@ function UserButtonRoot(props) {
|
|
|
4499
4640
|
};
|
|
4500
4641
|
if (status !== "authenticated" || !customer) return null;
|
|
4501
4642
|
const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
|
|
4502
|
-
return /* @__PURE__ */ (0,
|
|
4503
|
-
/* @__PURE__ */ (0,
|
|
4643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { ref: rootRef, ...a.el("userButton.root"), children: [
|
|
4644
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4504
4645
|
Dropdown,
|
|
4505
4646
|
{
|
|
4506
4647
|
label: t.userButton.openMenu,
|
|
4507
4648
|
triggerKey: "userButton.trigger",
|
|
4508
4649
|
menuKey: "userButton.menu",
|
|
4509
|
-
trigger: /* @__PURE__ */ (0,
|
|
4650
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Avatar, { name, email: customer.email }),
|
|
4510
4651
|
children: [
|
|
4511
|
-
/* @__PURE__ */ (0,
|
|
4512
|
-
/* @__PURE__ */ (0,
|
|
4513
|
-
/* @__PURE__ */ (0,
|
|
4514
|
-
/* @__PURE__ */ (0,
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { children: [
|
|
4653
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { ...a.el("userButton.email"), children: customer.email }),
|
|
4654
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("br", {}),
|
|
4655
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
|
|
4515
4656
|
] }) }),
|
|
4516
|
-
/* @__PURE__ */ (0,
|
|
4517
|
-
props.mode === "navigate" ? /* @__PURE__ */ (0,
|
|
4657
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DropdownSeparator, {}),
|
|
4658
|
+
props.mode === "navigate" ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
|
|
4518
4659
|
props.children,
|
|
4519
|
-
/* @__PURE__ */ (0,
|
|
4520
|
-
/* @__PURE__ */ (0,
|
|
4660
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(DropdownSeparator, {}),
|
|
4661
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4521
4662
|
DropdownItem,
|
|
4522
4663
|
{
|
|
4523
4664
|
itemKey: "userButton.signOutButton",
|
|
@@ -4525,7 +4666,7 @@ function UserButtonRoot(props) {
|
|
|
4525
4666
|
children: t.userButton.signOut
|
|
4526
4667
|
}
|
|
4527
4668
|
),
|
|
4528
|
-
/* @__PURE__ */ (0,
|
|
4669
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4529
4670
|
DropdownItem,
|
|
4530
4671
|
{
|
|
4531
4672
|
itemKey: "userButton.signOutAllButton",
|
|
@@ -4536,7 +4677,7 @@ function UserButtonRoot(props) {
|
|
|
4536
4677
|
]
|
|
4537
4678
|
}
|
|
4538
4679
|
),
|
|
4539
|
-
props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0,
|
|
4680
|
+
props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4540
4681
|
Modal,
|
|
4541
4682
|
{
|
|
4542
4683
|
open: accountOpen,
|
|
@@ -4544,8 +4685,8 @@ function UserButtonRoot(props) {
|
|
|
4544
4685
|
labelledBy: titleId,
|
|
4545
4686
|
restoreFocusTo: openerRef.current,
|
|
4546
4687
|
children: [
|
|
4547
|
-
/* @__PURE__ */ (0,
|
|
4548
|
-
/* @__PURE__ */ (0,
|
|
4688
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
|
|
4689
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { style: { padding: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4549
4690
|
AccountDashboard,
|
|
4550
4691
|
{
|
|
4551
4692
|
tabs: props.tabs,
|
|
@@ -4559,13 +4700,13 @@ function UserButtonRoot(props) {
|
|
|
4559
4700
|
] }) }) });
|
|
4560
4701
|
}
|
|
4561
4702
|
function UserButtonLink(props) {
|
|
4562
|
-
return /* @__PURE__ */ (0,
|
|
4703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
|
|
4563
4704
|
props.icon,
|
|
4564
4705
|
props.label
|
|
4565
4706
|
] });
|
|
4566
4707
|
}
|
|
4567
4708
|
function UserButtonAction(props) {
|
|
4568
|
-
return /* @__PURE__ */ (0,
|
|
4709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
|
|
4569
4710
|
props.icon,
|
|
4570
4711
|
props.label
|
|
4571
4712
|
] });
|
|
@@ -4579,6 +4720,7 @@ var UserButton = Object.assign(UserButtonRoot, {
|
|
|
4579
4720
|
ACCOUNT_TABS,
|
|
4580
4721
|
AccountDashboard,
|
|
4581
4722
|
AccountModal,
|
|
4723
|
+
AddCardDialog,
|
|
4582
4724
|
AddressesPanel,
|
|
4583
4725
|
AuthFlow,
|
|
4584
4726
|
AuthModal,
|