@usethrottle/auth 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1012 -615
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +76 -14
- package/dist/react/components/index.d.ts +76 -14
- package/dist/react/components/index.js +974 -596
- 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 +31 -3
- 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_react32 = 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,16 @@ 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
|
+
// How wide the auth card (sign-in, sign-up, forgot-password) is allowed
|
|
626
|
+
// to grow. It was pinned at 400px, which is narrow for a page that is
|
|
627
|
+
// nothing but that card.
|
|
628
|
+
cardWidth: "--throttle-card-width",
|
|
629
|
+
accountSurface: "--throttle-color-account-surface",
|
|
630
|
+
accountPadding: "--throttle-account-padding",
|
|
613
631
|
shadowCard: "--throttle-shadow-card",
|
|
614
632
|
shadowPopover: "--throttle-shadow-popover",
|
|
615
633
|
transition: "--throttle-transition",
|
|
@@ -744,6 +762,20 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
744
762
|
"paymentMethodsPanel.item",
|
|
745
763
|
"paymentMethodsPanel.defaultButton",
|
|
746
764
|
"paymentMethodsPanel.deleteButton",
|
|
765
|
+
"paymentMethodsPanel.addButton",
|
|
766
|
+
"paymentMethodsPanel.addDialog",
|
|
767
|
+
"orderDetail.addresses",
|
|
768
|
+
"orderDetail.shippingAddress",
|
|
769
|
+
"orderDetail.billingAddress",
|
|
770
|
+
"orderDetail.timeline",
|
|
771
|
+
"orderDetail.payButton",
|
|
772
|
+
"orderDetail.trackButton",
|
|
773
|
+
"orderDetail.reorderButton",
|
|
774
|
+
"confirm.header",
|
|
775
|
+
"confirm.title",
|
|
776
|
+
"confirm.body",
|
|
777
|
+
"confirm.confirmButton",
|
|
778
|
+
"confirm.cancelButton",
|
|
747
779
|
"paymentMethodsPanel.table",
|
|
748
780
|
"paymentMethodsPanel.row",
|
|
749
781
|
"ordersPanel.root",
|
|
@@ -852,6 +884,10 @@ function waitCopy(seconds) {
|
|
|
852
884
|
const minutes = Math.ceil(seconds / 60);
|
|
853
885
|
return `Please wait ${minutes} ${minutes === 1 ? "minute" : "minutes"} and try again.`;
|
|
854
886
|
}
|
|
887
|
+
function fieldLabel(path) {
|
|
888
|
+
const words = path.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([a-zA-Z])([0-9])/g, "$1 $2").toLowerCase().trim();
|
|
889
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
890
|
+
}
|
|
855
891
|
function messageForError(err) {
|
|
856
892
|
const e = err;
|
|
857
893
|
switch (e?.code) {
|
|
@@ -884,6 +920,13 @@ function messageForError(err) {
|
|
|
884
920
|
return "We could not find that.";
|
|
885
921
|
case "payment_method_in_use":
|
|
886
922
|
return e.message || "That payment method is in use and cannot be removed.";
|
|
923
|
+
case "validation_error": {
|
|
924
|
+
const first2 = e.details?.[0];
|
|
925
|
+
if (first2?.path && first2?.message) {
|
|
926
|
+
return `${fieldLabel(first2.path)} ${first2.message.replace(/\bNOT\b/g, "not")}.`;
|
|
927
|
+
}
|
|
928
|
+
return "Please check the highlighted fields and try again.";
|
|
929
|
+
}
|
|
887
930
|
default:
|
|
888
931
|
return "Something went wrong. Please try again.";
|
|
889
932
|
}
|
|
@@ -903,6 +946,9 @@ var enUS = {
|
|
|
903
946
|
loading: "Loading\u2026",
|
|
904
947
|
close: "Close",
|
|
905
948
|
confirm: "Are you sure?",
|
|
949
|
+
// The dismissive half of a confirmation. "Cancel" is ambiguous next to
|
|
950
|
+
// "Cancel subscription" — one dismisses the dialog, the other ends the plan.
|
|
951
|
+
keepIt: "Keep it",
|
|
906
952
|
somethingWentWrong: "Something went wrong.",
|
|
907
953
|
actions: "Actions",
|
|
908
954
|
view: "View"
|
|
@@ -1000,6 +1046,7 @@ var enUS = {
|
|
|
1000
1046
|
addButton: "Add address",
|
|
1001
1047
|
defaultBadge: "Default",
|
|
1002
1048
|
makeDefault: "Make default",
|
|
1049
|
+
deleteConfirmAction: "Delete address",
|
|
1003
1050
|
empty: "No saved addresses",
|
|
1004
1051
|
emptyDescription: "Addresses you use at checkout can be saved here.",
|
|
1005
1052
|
label: "Label",
|
|
@@ -1018,8 +1065,9 @@ var enUS = {
|
|
|
1018
1065
|
},
|
|
1019
1066
|
paymentMethods: {
|
|
1020
1067
|
empty: "No saved cards",
|
|
1021
|
-
|
|
1022
|
-
|
|
1068
|
+
emptyDescription: "Add a card here, or one will be saved when you check out.",
|
|
1069
|
+
addButton: "Add card",
|
|
1070
|
+
addTitle: "Add a card",
|
|
1023
1071
|
// Shown whenever the panel is empty with no error and the buyer is not
|
|
1024
1072
|
// verified — including simply being signed out — matching the copy
|
|
1025
1073
|
// orders/invoices/subscriptions already show in that state.
|
|
@@ -1028,9 +1076,20 @@ var enUS = {
|
|
|
1028
1076
|
makeDefault: "Make default",
|
|
1029
1077
|
expires: "Expires",
|
|
1030
1078
|
deleteConfirm: "Remove this card?",
|
|
1079
|
+
deleteConfirmAction: "Remove card",
|
|
1031
1080
|
columnCard: "Card"
|
|
1032
1081
|
},
|
|
1033
1082
|
orders: {
|
|
1083
|
+
shipTo: "Ship to",
|
|
1084
|
+
billTo: "Bill to",
|
|
1085
|
+
history: "History",
|
|
1086
|
+
placed: "Order placed",
|
|
1087
|
+
completed: "Completed",
|
|
1088
|
+
cancelledAt: "Cancelled",
|
|
1089
|
+
closedAt: "Closed",
|
|
1090
|
+
payNow: "Pay now",
|
|
1091
|
+
track: "Track shipment",
|
|
1092
|
+
reorder: "Order again",
|
|
1034
1093
|
empty: "No orders yet",
|
|
1035
1094
|
emptyDescription: "Orders you place will appear here.",
|
|
1036
1095
|
gatedDescription: "Verify your email to see your order history.",
|
|
@@ -1099,6 +1158,12 @@ var enUS = {
|
|
|
1099
1158
|
downloadUnavailable: "This invoice is not available to download right now."
|
|
1100
1159
|
},
|
|
1101
1160
|
subscriptions: {
|
|
1161
|
+
cancelConfirmAction: "Cancel plan",
|
|
1162
|
+
pauseConfirm: "Pause this subscription?",
|
|
1163
|
+
resumeConfirm: "Resume this subscription?",
|
|
1164
|
+
// Distinct from cancelConfirm: ending it now is not the same promise as
|
|
1165
|
+
// letting it run to the end of a period the buyer already paid for.
|
|
1166
|
+
cancelNowConfirm: "End this subscription immediately?",
|
|
1102
1167
|
empty: "No subscriptions",
|
|
1103
1168
|
emptyDescription: "Subscriptions will appear here.",
|
|
1104
1169
|
gatedDescription: "Verify your email to see your subscriptions.",
|
|
@@ -1216,6 +1281,13 @@ var THROTTLE_STYLES = `
|
|
|
1216
1281
|
edges, table rules, dividers) keep --throttle-color-border: they do not
|
|
1217
1282
|
identify a control, so the requirement does not apply and darkening
|
|
1218
1283
|
them would only add noise. */
|
|
1284
|
+
/* The account dashboard paints nothing by default so it can drop into a
|
|
1285
|
+
merchant's page without fighting their background. The accountSurface and
|
|
1286
|
+
accountPadding appearance variables opt back into a card.
|
|
1287
|
+
No backticks in this comment: the sheet is a TS template literal. */
|
|
1288
|
+
--throttle-card-width: 400px;
|
|
1289
|
+
--throttle-color-account-surface: transparent;
|
|
1290
|
+
--throttle-account-padding: 0;
|
|
1219
1291
|
--throttle-color-border-control: #8b93a1;
|
|
1220
1292
|
--throttle-color-danger: #c2321f;
|
|
1221
1293
|
--throttle-color-danger-surface: #fef2f2;
|
|
@@ -1314,7 +1386,7 @@ var THROTTLE_STYLES = `
|
|
|
1314
1386
|
box-shadow: var(--throttle-shadow-card);
|
|
1315
1387
|
padding: var(--throttle-space-5);
|
|
1316
1388
|
width: 100%;
|
|
1317
|
-
max-width:
|
|
1389
|
+
max-width: var(--throttle-card-width);
|
|
1318
1390
|
margin-inline: auto;
|
|
1319
1391
|
}
|
|
1320
1392
|
/* Inside a Modal the dialog already provides the surface \u2014 background, radius
|
|
@@ -1364,7 +1436,13 @@ var THROTTLE_STYLES = `
|
|
|
1364
1436
|
/* Always mounted, so it reserves its line whether or not there is an error:
|
|
1365
1437
|
an error appearing on submit must not push the submit button out from
|
|
1366
1438
|
under the buyer's pointer. */
|
|
1367
|
-
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs);
|
|
1439
|
+
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs); line-height: 1rem; }
|
|
1440
|
+
/* Reserved a full line under EVERY input even with nothing to say, which
|
|
1441
|
+
with the stack gap put 28px of dead space beneath each field, on every
|
|
1442
|
+
form and all seven account panels. The element stays mounted when empty
|
|
1443
|
+
because role=alert only announces changes to a live region that was
|
|
1444
|
+
already there; it just stops occupying a line. */
|
|
1445
|
+
.throttle-field__error:empty { display: none; }
|
|
1368
1446
|
|
|
1369
1447
|
.throttle-field-group {
|
|
1370
1448
|
display: flex;
|
|
@@ -1423,6 +1501,11 @@ var THROTTLE_STYLES = `
|
|
|
1423
1501
|
animation: throttle-spin 700ms linear infinite;
|
|
1424
1502
|
}
|
|
1425
1503
|
@keyframes throttle-spin { to { transform: rotate(360deg); } }
|
|
1504
|
+
.throttle-button--loading { position: relative; }
|
|
1505
|
+
.throttle-button__label { display: inline-flex; align-items: center; justify-content: center; gap: var(--throttle-space-2); }
|
|
1506
|
+
.throttle-button__label--hidden { visibility: hidden; }
|
|
1507
|
+
.throttle-spinner--centred { position: absolute; top: 50%; left: 50%; margin: -0.5em 0 0 -0.5em; }
|
|
1508
|
+
|
|
1426
1509
|
@media (prefers-reduced-motion: reduce) { .throttle-spinner { animation-duration: 2.4s; } }
|
|
1427
1510
|
|
|
1428
1511
|
.throttle-skeleton {
|
|
@@ -1505,7 +1588,16 @@ var THROTTLE_STYLES = `
|
|
|
1505
1588
|
/* Paints its own ground. A UserButton in a navbar should stay transparent, but
|
|
1506
1589
|
the dashboard is a large surface of themed text: in dark theme its foreground
|
|
1507
1590
|
is near-white, so on a light host page it was rendering white-on-white. */
|
|
1508
|
-
.throttle-
|
|
1591
|
+
.throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
|
|
1592
|
+
.throttle-centre { display: flex; align-items: center; justify-content: center; min-height: 160px; }
|
|
1593
|
+
.throttle-section__title { font-size: var(--throttle-font-size-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--throttle-color-muted-foreground); margin: 0 0 var(--throttle-space-2); font-weight: 600; }
|
|
1594
|
+
.throttle-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: var(--throttle-space-5); }
|
|
1595
|
+
.throttle-addressblock__line { margin: 0 0 2px; }
|
|
1596
|
+
.throttle-timeline { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
|
|
1597
|
+
.throttle-timeline__row { display: flex; align-items: center; gap: var(--throttle-space-2); }
|
|
1598
|
+
.throttle-timeline__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--throttle-color-border-control); flex: none; }
|
|
1599
|
+
.throttle-timeline__label { flex: 1; }
|
|
1600
|
+
.throttle-account-root { container-type: inline-size; background: var(--throttle-color-account-surface); color: var(--throttle-color-foreground); padding: var(--throttle-account-padding); }
|
|
1509
1601
|
.throttle-account { display: flex; gap: var(--throttle-space-5); align-items: flex-start; }
|
|
1510
1602
|
.throttle-account__content { flex: 1; min-width: 0; }
|
|
1511
1603
|
.throttle-tabs__rail { flex: none; width: 220px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -1542,6 +1634,7 @@ var THROTTLE_STYLES = `
|
|
|
1542
1634
|
it shrinks the rail to its content width, so width:100% alone cannot make
|
|
1543
1635
|
it span. Stretch it explicitly when stacked. */
|
|
1544
1636
|
.throttle-account { flex-direction: column; align-items: stretch; gap: var(--throttle-space-4); }
|
|
1637
|
+
.throttle-addresses { grid-template-columns: 1fr; }
|
|
1545
1638
|
.throttle-tabs__rail { width: 100%; }
|
|
1546
1639
|
}
|
|
1547
1640
|
|
|
@@ -1644,93 +1737,78 @@ function useInjectStyles(enabled) {
|
|
|
1644
1737
|
}, [enabled]);
|
|
1645
1738
|
}
|
|
1646
1739
|
|
|
1647
|
-
// src/react/components/auth/StepUpDialog.tsx
|
|
1648
|
-
var import_react10 = require("react");
|
|
1649
|
-
|
|
1650
|
-
// src/react/components/surface.tsx
|
|
1651
|
-
var import_react6 = require("react");
|
|
1652
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1653
|
-
var Ctx5 = (0, import_react6.createContext)("standalone");
|
|
1654
|
-
function SurfaceProvider(props) {
|
|
1655
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Ctx5.Provider, { value: props.value, children: props.children });
|
|
1656
|
-
}
|
|
1657
|
-
function useSurface() {
|
|
1658
|
-
return (0, import_react6.useContext)(Ctx5);
|
|
1659
|
-
}
|
|
1660
|
-
function useCardClass() {
|
|
1661
|
-
return useSurface() === "modal" ? "throttle-card throttle-card--bare" : "throttle-card";
|
|
1662
|
-
}
|
|
1663
|
-
|
|
1664
1740
|
// src/react/components/primitives/Card.tsx
|
|
1665
|
-
var
|
|
1741
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1666
1742
|
function CardHeader(props) {
|
|
1667
1743
|
const a = useAppearance();
|
|
1668
1744
|
const headerClass = `throttle-card__header${props.branded ? " throttle-card__header--branded" : ""}`;
|
|
1669
1745
|
const titleClass = `throttle-card__title${props.branded ? " throttle-card__title--branded" : ""}`;
|
|
1670
|
-
return /* @__PURE__ */ (0,
|
|
1671
|
-
props.logo ? /* @__PURE__ */ (0,
|
|
1672
|
-
/* @__PURE__ */ (0,
|
|
1673
|
-
props.description ? /* @__PURE__ */ (0,
|
|
1746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ...a.el("card.header", headerClass), children: [
|
|
1747
|
+
props.logo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...a.el(props.logoKey ?? "card.logo", "throttle-card__logo"), children: props.logo }) : null,
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { ...a.el(props.titleKey ?? "card.title", titleClass), children: props.title }),
|
|
1749
|
+
props.description ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { ...a.el("card.description", "throttle-card__description"), children: props.description }) : null
|
|
1674
1750
|
] });
|
|
1675
1751
|
}
|
|
1676
1752
|
function CardBody(props) {
|
|
1677
1753
|
const a = useAppearance();
|
|
1678
|
-
return /* @__PURE__ */ (0,
|
|
1754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...a.el("card.body", "throttle-card__body"), children: props.children });
|
|
1679
1755
|
}
|
|
1680
1756
|
function CardFooter(props) {
|
|
1681
1757
|
const a = useAppearance();
|
|
1682
1758
|
const className = `throttle-card__footer${props.ruled ? " throttle-card__footer--ruled" : ""}`;
|
|
1683
|
-
return /* @__PURE__ */ (0,
|
|
1759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...a.el("card.footer", className), children: props.children });
|
|
1684
1760
|
}
|
|
1685
1761
|
|
|
1686
1762
|
// src/react/components/primitives/Spinner.tsx
|
|
1687
|
-
var
|
|
1688
|
-
function Spinner() {
|
|
1763
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1764
|
+
function Spinner({ centred } = {}) {
|
|
1689
1765
|
const a = useAppearance();
|
|
1690
1766
|
const Slot = a.slots.Spinner;
|
|
1691
|
-
if (Slot) return /* @__PURE__ */ (0,
|
|
1692
|
-
|
|
1767
|
+
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Slot, {});
|
|
1768
|
+
const cls = `throttle-spinner${centred ? " throttle-spinner--centred" : ""}`;
|
|
1769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ...a.el("spinner", cls), "aria-hidden": "true" });
|
|
1693
1770
|
}
|
|
1694
1771
|
|
|
1695
1772
|
// src/react/components/primitives/Button.tsx
|
|
1696
|
-
var
|
|
1773
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1697
1774
|
function Button({ variant = "primary", size = "default", elementKey, loading, children, ...rest }) {
|
|
1698
1775
|
const a = useAppearance();
|
|
1699
1776
|
const Slot = a.slots.Button;
|
|
1700
|
-
if (Slot) return /* @__PURE__ */ (0,
|
|
1701
|
-
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}`;
|
|
1702
|
-
return /* @__PURE__ */ (0,
|
|
1777
|
+
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { variant, loading, ...rest, children });
|
|
1778
|
+
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}${loading ? " throttle-button--loading" : ""}`;
|
|
1779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1703
1780
|
"button",
|
|
1704
1781
|
{
|
|
1705
1782
|
type: "button",
|
|
1706
1783
|
...rest,
|
|
1707
1784
|
...a.el(elementKey ?? "button", base),
|
|
1708
1785
|
disabled: rest.disabled || loading,
|
|
1786
|
+
"aria-busy": loading ? true : void 0,
|
|
1709
1787
|
children: [
|
|
1710
|
-
loading ? /* @__PURE__ */ (0,
|
|
1711
|
-
children
|
|
1788
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { centred: true }) : null,
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `throttle-button__label${loading ? " throttle-button__label--hidden" : ""}`, children })
|
|
1712
1790
|
]
|
|
1713
1791
|
}
|
|
1714
1792
|
);
|
|
1715
1793
|
}
|
|
1716
1794
|
|
|
1717
1795
|
// src/react/components/primitives/Field.tsx
|
|
1718
|
-
var
|
|
1719
|
-
var
|
|
1796
|
+
var import_react6 = require("react");
|
|
1797
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1720
1798
|
function Field(props) {
|
|
1721
1799
|
const a = useAppearance();
|
|
1722
|
-
const base = (0,
|
|
1800
|
+
const base = (0, import_react6.useId)();
|
|
1723
1801
|
const inputId = `${base}-input`;
|
|
1724
1802
|
const hintId = `${base}-hint`;
|
|
1725
1803
|
const errorId = `${base}-error`;
|
|
1726
1804
|
const describedBy = [props.hint ? hintId : null, props.error ? errorId : null].filter(Boolean).join(" ");
|
|
1727
|
-
const label = /* @__PURE__ */ (0,
|
|
1728
|
-
return /* @__PURE__ */ (0,
|
|
1729
|
-
props.labelExtra ? /* @__PURE__ */ (0,
|
|
1805
|
+
const label = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { ...a.el("field.label", "throttle-field__label"), htmlFor: inputId, children: props.label });
|
|
1806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ...a.el(props.elementKey ?? "field", "throttle-field"), children: [
|
|
1807
|
+
props.labelExtra ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "throttle-field__labelrow", children: [
|
|
1730
1808
|
label,
|
|
1731
1809
|
props.labelExtra
|
|
1732
1810
|
] }) : label,
|
|
1733
|
-
/* @__PURE__ */ (0,
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1734
1812
|
"input",
|
|
1735
1813
|
{
|
|
1736
1814
|
...a.el("field.input", `throttle-field__input${props.grouped ? " throttle-field__input--grouped" : ""}`),
|
|
@@ -1746,26 +1824,26 @@ function Field(props) {
|
|
|
1746
1824
|
onChange: (e) => props.onChange(e.target.value)
|
|
1747
1825
|
}
|
|
1748
1826
|
),
|
|
1749
|
-
props.hint ? /* @__PURE__ */ (0,
|
|
1750
|
-
/* @__PURE__ */ (0,
|
|
1827
|
+
props.hint ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { ...a.el("field.hint", "throttle-field__hint"), id: hintId, children: props.hint }) : null,
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { ...a.el("field.error", "throttle-field__error"), id: errorId, role: "alert", children: props.error ?? "" })
|
|
1751
1829
|
] });
|
|
1752
1830
|
}
|
|
1753
1831
|
function FieldGroup(props) {
|
|
1754
1832
|
const a = useAppearance();
|
|
1755
|
-
const items =
|
|
1756
|
-
return /* @__PURE__ */ (0,
|
|
1757
|
-
i > 0 ? /* @__PURE__ */ (0,
|
|
1758
|
-
/* @__PURE__ */ (0,
|
|
1833
|
+
const items = import_react6.Children.toArray(props.children).filter(Boolean);
|
|
1834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ...a.el(props.elementKey ?? "field.group", "throttle-field-group"), children: items.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react6.Fragment, { children: [
|
|
1835
|
+
i > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "throttle-field-group__divider" }) : null,
|
|
1836
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "throttle-field-group__item", children: child })
|
|
1759
1837
|
] }, i)) });
|
|
1760
1838
|
}
|
|
1761
1839
|
|
|
1762
1840
|
// src/react/components/primitives/Alert.tsx
|
|
1763
|
-
var
|
|
1841
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1764
1842
|
function Alert(props) {
|
|
1765
1843
|
const a = useAppearance();
|
|
1766
1844
|
const Slot = a.slots.Alert;
|
|
1767
|
-
if (Slot) return /* @__PURE__ */ (0,
|
|
1768
|
-
return /* @__PURE__ */ (0,
|
|
1845
|
+
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { tone: props.tone, children: props.children });
|
|
1846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1769
1847
|
"p",
|
|
1770
1848
|
{
|
|
1771
1849
|
...a.el("alert", `throttle-alert throttle-alert--${props.tone}`),
|
|
@@ -1776,16 +1854,32 @@ function Alert(props) {
|
|
|
1776
1854
|
}
|
|
1777
1855
|
|
|
1778
1856
|
// src/react/components/primitives/Skeleton.tsx
|
|
1779
|
-
var
|
|
1857
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1780
1858
|
function Skeleton(props) {
|
|
1781
1859
|
const a = useAppearance();
|
|
1782
1860
|
const rows = Array.from({ length: props.count ?? 1 });
|
|
1783
|
-
return /* @__PURE__ */ (0,
|
|
1861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "aria-hidden": "true", className: "throttle-stack", children: rows.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...a.el("skeleton", "throttle-skeleton") }, i)) });
|
|
1784
1862
|
}
|
|
1785
1863
|
|
|
1786
1864
|
// src/react/components/primitives/Modal.tsx
|
|
1787
1865
|
var import_react8 = require("react");
|
|
1788
1866
|
var import_react_dom = require("react-dom");
|
|
1867
|
+
|
|
1868
|
+
// src/react/components/surface.tsx
|
|
1869
|
+
var import_react7 = require("react");
|
|
1870
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1871
|
+
var Ctx5 = (0, import_react7.createContext)("standalone");
|
|
1872
|
+
function SurfaceProvider(props) {
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Ctx5.Provider, { value: props.value, children: props.children });
|
|
1874
|
+
}
|
|
1875
|
+
function useSurface() {
|
|
1876
|
+
return (0, import_react7.useContext)(Ctx5);
|
|
1877
|
+
}
|
|
1878
|
+
function useCardClass() {
|
|
1879
|
+
return useSurface() === "modal" ? "throttle-card throttle-card--bare" : "throttle-card";
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// src/react/components/primitives/Modal.tsx
|
|
1789
1883
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1790
1884
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1791
1885
|
function Modal(props) {
|
|
@@ -1875,16 +1969,69 @@ function Modal(props) {
|
|
|
1875
1969
|
);
|
|
1876
1970
|
}
|
|
1877
1971
|
|
|
1878
|
-
// src/react/components/primitives/
|
|
1972
|
+
// src/react/components/primitives/Confirm.tsx
|
|
1879
1973
|
var import_react9 = require("react");
|
|
1880
1974
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1975
|
+
var ConfirmContext = (0, import_react9.createContext)(null);
|
|
1976
|
+
function ConfirmProvider({ children }) {
|
|
1977
|
+
const [request2, setRequest] = (0, import_react9.useState)(null);
|
|
1978
|
+
const { t } = useCopy();
|
|
1979
|
+
const a = useAppearance();
|
|
1980
|
+
const titleId = (0, import_react9.useId)();
|
|
1981
|
+
const settle = (0, import_react9.useRef)(null);
|
|
1982
|
+
const answer = (0, import_react9.useCallback)((value) => {
|
|
1983
|
+
settle.current?.(value);
|
|
1984
|
+
settle.current = null;
|
|
1985
|
+
setRequest(null);
|
|
1986
|
+
}, []);
|
|
1987
|
+
const ask = (0, import_react9.useCallback)((next) => {
|
|
1988
|
+
settle.current?.(false);
|
|
1989
|
+
setRequest(next);
|
|
1990
|
+
return new Promise((resolve) => {
|
|
1991
|
+
settle.current = resolve;
|
|
1992
|
+
});
|
|
1993
|
+
}, []);
|
|
1994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(ConfirmContext.Provider, { value: ask, children: [
|
|
1995
|
+
children,
|
|
1996
|
+
request2 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Modal, { open: true, onClose: () => answer(false), labelledBy: titleId, size: "compact", children: [
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request2.title }) }),
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
|
|
1999
|
+
request2.body ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "throttle-muted", children: request2.body }) : null,
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "throttle-actions", children: [
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2002
|
+
Button,
|
|
2003
|
+
{
|
|
2004
|
+
elementKey: "confirm.confirmButton",
|
|
2005
|
+
variant: request2.tone === "danger" ? "danger" : "primary",
|
|
2006
|
+
onClick: () => answer(true),
|
|
2007
|
+
children: request2.confirmLabel ?? t.common.delete
|
|
2008
|
+
}
|
|
2009
|
+
),
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request2.cancelLabel ?? t.common.keepIt })
|
|
2011
|
+
] })
|
|
2012
|
+
] })
|
|
2013
|
+
] }) : null
|
|
2014
|
+
] });
|
|
2015
|
+
}
|
|
2016
|
+
function useConfirm() {
|
|
2017
|
+
const ask = (0, import_react9.useContext)(ConfirmContext);
|
|
2018
|
+
const { t } = useCopy();
|
|
2019
|
+
return (0, import_react9.useMemo)(
|
|
2020
|
+
() => ask ?? (async (request2) => window.confirm(request2.title || t.common.confirm)),
|
|
2021
|
+
[ask, t]
|
|
2022
|
+
);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// src/react/components/primitives/Dropdown.tsx
|
|
2026
|
+
var import_react10 = require("react");
|
|
2027
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1881
2028
|
function Dropdown(props) {
|
|
1882
2029
|
const a = useAppearance();
|
|
1883
|
-
const [open, setOpen] = (0,
|
|
1884
|
-
const root = (0,
|
|
1885
|
-
const trigger = (0,
|
|
1886
|
-
const menu = (0,
|
|
1887
|
-
(0,
|
|
2030
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
2031
|
+
const root = (0, import_react10.useRef)(null);
|
|
2032
|
+
const trigger = (0, import_react10.useRef)(null);
|
|
2033
|
+
const menu = (0, import_react10.useRef)(null);
|
|
2034
|
+
(0, import_react10.useEffect)(() => {
|
|
1888
2035
|
if (!open) return;
|
|
1889
2036
|
menu.current?.querySelector('[role="menuitem"]')?.focus();
|
|
1890
2037
|
const onDown = (e) => {
|
|
@@ -1910,8 +2057,8 @@ function Dropdown(props) {
|
|
|
1910
2057
|
const next = (at + delta + items.length) % items.length;
|
|
1911
2058
|
items[next < 0 ? items.length - 1 : next].focus();
|
|
1912
2059
|
};
|
|
1913
|
-
return /* @__PURE__ */ (0,
|
|
1914
|
-
/* @__PURE__ */ (0,
|
|
2060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ref: root, style: { position: "relative", display: "inline-block" }, children: [
|
|
2061
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1915
2062
|
"button",
|
|
1916
2063
|
{
|
|
1917
2064
|
ref: trigger,
|
|
@@ -1924,7 +2071,7 @@ function Dropdown(props) {
|
|
|
1924
2071
|
children: props.trigger
|
|
1925
2072
|
}
|
|
1926
2073
|
),
|
|
1927
|
-
open ? /* @__PURE__ */ (0,
|
|
2074
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1928
2075
|
"div",
|
|
1929
2076
|
{
|
|
1930
2077
|
ref: menu,
|
|
@@ -1950,24 +2097,24 @@ function DropdownItem(props) {
|
|
|
1950
2097
|
const a = useAppearance();
|
|
1951
2098
|
const attrs = a.el(props.itemKey ?? "dropdown.item", "throttle-dropdown__item");
|
|
1952
2099
|
if (props.href) {
|
|
1953
|
-
return /* @__PURE__ */ (0,
|
|
2100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("a", { ...attrs, role: "menuitem", href: props.href, tabIndex: -1, children: props.children });
|
|
1954
2101
|
}
|
|
1955
|
-
return /* @__PURE__ */ (0,
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { ...attrs, role: "menuitem", type: "button", tabIndex: -1, onClick: props.onClick, children: props.children });
|
|
1956
2103
|
}
|
|
1957
2104
|
function DropdownSeparator() {
|
|
1958
2105
|
const a = useAppearance();
|
|
1959
|
-
return /* @__PURE__ */ (0,
|
|
2106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", { ...a.el("dropdown.separator", "throttle-dropdown__separator") });
|
|
1960
2107
|
}
|
|
1961
2108
|
|
|
1962
2109
|
// src/react/components/primitives/Tabs.tsx
|
|
1963
|
-
var
|
|
2110
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1964
2111
|
function Tabs(props) {
|
|
1965
2112
|
const a = useAppearance();
|
|
1966
2113
|
const at = props.tabs.findIndex((t) => t.id === props.active);
|
|
1967
2114
|
const vertical = props.orientation === "vertical";
|
|
1968
2115
|
const listClass = vertical ? "throttle-tabs__rail" : "throttle-tabs__list";
|
|
1969
2116
|
const itemClass = vertical ? "throttle-tabs__railitem" : "throttle-tabs__tab";
|
|
1970
|
-
return /* @__PURE__ */ (0,
|
|
2117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1971
2118
|
"div",
|
|
1972
2119
|
{
|
|
1973
2120
|
...a.el("tabs.list", listClass),
|
|
@@ -1986,7 +2133,7 @@ function Tabs(props) {
|
|
|
1986
2133
|
children: props.tabs.map((tab) => {
|
|
1987
2134
|
const selected = tab.id === props.active;
|
|
1988
2135
|
const { className, ...rest } = a.el("tabs.tab", itemClass);
|
|
1989
|
-
return /* @__PURE__ */ (0,
|
|
2136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1990
2137
|
"button",
|
|
1991
2138
|
{
|
|
1992
2139
|
...rest,
|
|
@@ -2011,16 +2158,16 @@ function Tabs(props) {
|
|
|
2011
2158
|
}
|
|
2012
2159
|
|
|
2013
2160
|
// src/react/components/primitives/DataTable.tsx
|
|
2014
|
-
var
|
|
2161
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2015
2162
|
function DataTable(props) {
|
|
2016
2163
|
const a = useAppearance();
|
|
2017
2164
|
const clickable = Boolean(props.onRowClick);
|
|
2018
2165
|
return (
|
|
2019
2166
|
// Tables are the one thing allowed to be wider than the panel; it scrolls
|
|
2020
2167
|
// rather than forcing the whole page to.
|
|
2021
|
-
/* @__PURE__ */ (0,
|
|
2022
|
-
/* @__PURE__ */ (0,
|
|
2023
|
-
/* @__PURE__ */ (0,
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "throttle-table__scroll", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { ...a.el(props.tableKey ?? "table", "throttle-table"), children: [
|
|
2169
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("th", { ...a.el("table.head", "throttle-table__head"), scope: "col", children: col.label }, col.key)) }) }),
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { children: props.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2024
2171
|
"tr",
|
|
2025
2172
|
{
|
|
2026
2173
|
...a.el(props.rowElementKey ?? "table.row", "throttle-table__row"),
|
|
@@ -2032,7 +2179,7 @@ function DataTable(props) {
|
|
|
2032
2179
|
props.onRowClick(row);
|
|
2033
2180
|
}
|
|
2034
2181
|
} : void 0,
|
|
2035
|
-
children: props.columns.map((col) => /* @__PURE__ */ (0,
|
|
2182
|
+
children: props.columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("td", { ...a.el("table.cell", "throttle-table__cell"), children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
|
|
2036
2183
|
},
|
|
2037
2184
|
props.rowKey(row)
|
|
2038
2185
|
)) })
|
|
@@ -2041,48 +2188,49 @@ function DataTable(props) {
|
|
|
2041
2188
|
}
|
|
2042
2189
|
|
|
2043
2190
|
// src/react/components/primitives/EmptyState.tsx
|
|
2044
|
-
var
|
|
2191
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2045
2192
|
function EmptyState(props) {
|
|
2046
2193
|
const a = useAppearance();
|
|
2047
2194
|
const Slot = a.slots.EmptyState;
|
|
2048
|
-
if (Slot) return /* @__PURE__ */ (0,
|
|
2049
|
-
return /* @__PURE__ */ (0,
|
|
2050
|
-
/* @__PURE__ */ (0,
|
|
2051
|
-
props.description ? /* @__PURE__ */ (0,
|
|
2195
|
+
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Slot, { title: props.title, description: props.description });
|
|
2196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ...a.el("emptyState", "throttle-empty"), children: [
|
|
2197
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { ...a.el("emptyState.title", "throttle-empty__title"), children: props.title }),
|
|
2198
|
+
props.description ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { ...a.el("emptyState.description", "throttle-empty__description"), children: props.description }) : null
|
|
2052
2199
|
] });
|
|
2053
2200
|
}
|
|
2054
2201
|
|
|
2055
2202
|
// src/react/components/primitives/Avatar.tsx
|
|
2056
|
-
var
|
|
2203
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2057
2204
|
function Avatar(props) {
|
|
2058
2205
|
const a = useAppearance();
|
|
2059
2206
|
const Slot = a.slots.Avatar;
|
|
2060
|
-
if (Slot) return /* @__PURE__ */ (0,
|
|
2207
|
+
if (Slot) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Slot, { name: props.name, email: props.email });
|
|
2061
2208
|
const initials = props.name.split(" ").map((part) => part.trim()[0]).filter(Boolean).slice(0, 2).join("") || props.email.trim()[0] || "?";
|
|
2062
|
-
return /* @__PURE__ */ (0,
|
|
2209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { ...a.el("avatar", "throttle-avatar"), title: props.email, children: initials.toUpperCase() });
|
|
2063
2210
|
}
|
|
2064
2211
|
|
|
2065
2212
|
// src/react/components/primitives/Badge.tsx
|
|
2066
|
-
var
|
|
2213
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2067
2214
|
function Badge(props) {
|
|
2068
2215
|
const a = useAppearance();
|
|
2069
2216
|
const tone = props.tone ?? "neutral";
|
|
2070
2217
|
const base = tone === "neutral" ? "throttle-badge" : `throttle-badge throttle-badge--${tone}`;
|
|
2071
|
-
return /* @__PURE__ */ (0,
|
|
2218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
|
|
2072
2219
|
}
|
|
2073
2220
|
|
|
2074
2221
|
// src/react/components/auth/StepUpDialog.tsx
|
|
2075
|
-
var
|
|
2222
|
+
var import_react11 = require("react");
|
|
2223
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2076
2224
|
function StepUpDialog(props) {
|
|
2077
2225
|
const a = useAppearance();
|
|
2078
2226
|
const cardClass = useCardClass();
|
|
2079
2227
|
const { t } = useCopy();
|
|
2080
|
-
const [password, setPassword] = (0,
|
|
2081
|
-
const titleId = (0,
|
|
2082
|
-
(0,
|
|
2228
|
+
const [password, setPassword] = (0, import_react11.useState)("");
|
|
2229
|
+
const titleId = (0, import_react11.useId)();
|
|
2230
|
+
(0, import_react11.useEffect)(() => {
|
|
2083
2231
|
if (!props.open) setPassword("");
|
|
2084
2232
|
}, [props.open]);
|
|
2085
|
-
return /* @__PURE__ */ (0,
|
|
2233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Modal, { open: props.open, onClose: () => props.onResolve(null), labelledBy: titleId, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ...a.el("stepUp.root", cardClass), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2086
2234
|
"form",
|
|
2087
2235
|
{
|
|
2088
2236
|
onSubmit: (e) => {
|
|
@@ -2090,12 +2238,12 @@ function StepUpDialog(props) {
|
|
|
2090
2238
|
props.onResolve(password);
|
|
2091
2239
|
},
|
|
2092
2240
|
children: [
|
|
2093
|
-
/* @__PURE__ */ (0,
|
|
2094
|
-
/* @__PURE__ */ (0,
|
|
2095
|
-
/* @__PURE__ */ (0,
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "throttle-card__header", children: [
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-card__title"), children: t.stepUp.title }),
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "throttle-card__description", children: t.stepUp.description })
|
|
2096
2244
|
] }),
|
|
2097
|
-
/* @__PURE__ */ (0,
|
|
2098
|
-
/* @__PURE__ */ (0,
|
|
2245
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(CardBody, { children: [
|
|
2246
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2099
2247
|
Field,
|
|
2100
2248
|
{
|
|
2101
2249
|
label: t.stepUp.password,
|
|
@@ -2107,8 +2255,8 @@ function StepUpDialog(props) {
|
|
|
2107
2255
|
elementKey: "stepUp.passwordField"
|
|
2108
2256
|
}
|
|
2109
2257
|
),
|
|
2110
|
-
/* @__PURE__ */ (0,
|
|
2111
|
-
/* @__PURE__ */ (0,
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { variant: "link", elementKey: "stepUp.cancelButton", onClick: () => props.onResolve(null), children: t.stepUp.cancelButton })
|
|
2112
2260
|
] })
|
|
2113
2261
|
]
|
|
2114
2262
|
}
|
|
@@ -2116,23 +2264,23 @@ function StepUpDialog(props) {
|
|
|
2116
2264
|
}
|
|
2117
2265
|
|
|
2118
2266
|
// src/react/components/auth/AuthModal.tsx
|
|
2119
|
-
var
|
|
2267
|
+
var import_react19 = require("react");
|
|
2120
2268
|
|
|
2121
2269
|
// src/react/components/auth/AuthFlow.tsx
|
|
2122
|
-
var
|
|
2270
|
+
var import_react18 = require("react");
|
|
2123
2271
|
|
|
2124
2272
|
// src/react/components/auth/SignIn.tsx
|
|
2125
|
-
var
|
|
2273
|
+
var import_react13 = require("react");
|
|
2126
2274
|
|
|
2127
2275
|
// src/react/components/useAction.ts
|
|
2128
|
-
var
|
|
2276
|
+
var import_react12 = require("react");
|
|
2129
2277
|
function useAction() {
|
|
2130
2278
|
const { errorMessage } = useCopy();
|
|
2131
|
-
const [submitting, setSubmitting] = (0,
|
|
2132
|
-
const [error, setError] = (0,
|
|
2133
|
-
const [notice, setNotice] = (0,
|
|
2134
|
-
const inFlight = (0,
|
|
2135
|
-
const run = (0,
|
|
2279
|
+
const [submitting, setSubmitting] = (0, import_react12.useState)(false);
|
|
2280
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
2281
|
+
const [notice, setNotice] = (0, import_react12.useState)(null);
|
|
2282
|
+
const inFlight = (0, import_react12.useRef)(false);
|
|
2283
|
+
const run = (0, import_react12.useCallback)(
|
|
2136
2284
|
async (fn) => {
|
|
2137
2285
|
if (inFlight.current) return;
|
|
2138
2286
|
inFlight.current = true;
|
|
@@ -2155,7 +2303,7 @@ function useAction() {
|
|
|
2155
2303
|
}
|
|
2156
2304
|
|
|
2157
2305
|
// src/react/components/auth/SignIn.tsx
|
|
2158
|
-
var
|
|
2306
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2159
2307
|
function SignIn(props) {
|
|
2160
2308
|
const a = useAppearance(props.appearance);
|
|
2161
2309
|
const cardClass = useCardClass();
|
|
@@ -2163,14 +2311,14 @@ function SignIn(props) {
|
|
|
2163
2311
|
const { t } = useCopy(props.localization);
|
|
2164
2312
|
const { auth } = useAuth();
|
|
2165
2313
|
const { submitting, error, run } = useAction();
|
|
2166
|
-
const [email, setEmail] = (0,
|
|
2167
|
-
const [password, setPassword] = (0,
|
|
2314
|
+
const [email, setEmail] = (0, import_react13.useState)("");
|
|
2315
|
+
const [password, setPassword] = (0, import_react13.useState)("");
|
|
2168
2316
|
const variant = props.variant ?? "quiet";
|
|
2169
2317
|
const branded = variant === "branded";
|
|
2170
2318
|
const grouped = variant === "grouped";
|
|
2171
2319
|
const logo = useBrandLogo(props.logo);
|
|
2172
|
-
const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0,
|
|
2173
|
-
const emailField = /* @__PURE__ */ (0,
|
|
2320
|
+
const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", size: "xs", elementKey: "signIn.forgotLink", onClick: props.onForgotPassword, children: t.signIn.forgotLink }) : null;
|
|
2321
|
+
const emailField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2174
2322
|
Field,
|
|
2175
2323
|
{
|
|
2176
2324
|
label: t.signIn.email,
|
|
@@ -2183,7 +2331,7 @@ function SignIn(props) {
|
|
|
2183
2331
|
grouped
|
|
2184
2332
|
}
|
|
2185
2333
|
);
|
|
2186
|
-
const passwordField = /* @__PURE__ */ (0,
|
|
2334
|
+
const passwordField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2187
2335
|
Field,
|
|
2188
2336
|
{
|
|
2189
2337
|
label: t.signIn.password,
|
|
@@ -2197,7 +2345,7 @@ function SignIn(props) {
|
|
|
2197
2345
|
labelExtra: grouped ? void 0 : forgotLink
|
|
2198
2346
|
}
|
|
2199
2347
|
);
|
|
2200
|
-
return /* @__PURE__ */ (0,
|
|
2348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2201
2349
|
"form",
|
|
2202
2350
|
{
|
|
2203
2351
|
...a.el("signIn.root", cardClass),
|
|
@@ -2209,7 +2357,7 @@ function SignIn(props) {
|
|
|
2209
2357
|
});
|
|
2210
2358
|
},
|
|
2211
2359
|
children: [
|
|
2212
|
-
/* @__PURE__ */ (0,
|
|
2360
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2213
2361
|
CardHeader,
|
|
2214
2362
|
{
|
|
2215
2363
|
title: t.signIn.title,
|
|
@@ -2220,24 +2368,24 @@ function SignIn(props) {
|
|
|
2220
2368
|
branded
|
|
2221
2369
|
}
|
|
2222
2370
|
),
|
|
2223
|
-
/* @__PURE__ */ (0,
|
|
2224
|
-
grouped ? /* @__PURE__ */ (0,
|
|
2371
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardBody, { children: [
|
|
2372
|
+
grouped ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(FieldGroup, { children: [
|
|
2225
2373
|
emailField,
|
|
2226
2374
|
passwordField
|
|
2227
|
-
] }) : /* @__PURE__ */ (0,
|
|
2375
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2228
2376
|
emailField,
|
|
2229
2377
|
passwordField
|
|
2230
2378
|
] }),
|
|
2231
|
-
grouped && forgotLink ? /* @__PURE__ */ (0,
|
|
2232
|
-
error ? /* @__PURE__ */ (0,
|
|
2233
|
-
/* @__PURE__ */ (0,
|
|
2379
|
+
grouped && forgotLink ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "throttle-field-group__forgot", children: forgotLink }) : null,
|
|
2380
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signIn.submitButton", children: t.signIn.submitButton })
|
|
2234
2382
|
] }),
|
|
2235
|
-
props.onSignUp ? /* @__PURE__ */ (0,
|
|
2236
|
-
/* @__PURE__ */ (0,
|
|
2383
|
+
props.onSignUp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardFooter, { ruled: !branded, children: [
|
|
2384
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "throttle-muted", children: [
|
|
2237
2385
|
t.signIn.switchPrompt,
|
|
2238
2386
|
" "
|
|
2239
2387
|
] }),
|
|
2240
|
-
/* @__PURE__ */ (0,
|
|
2388
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
|
|
2241
2389
|
] }) : null
|
|
2242
2390
|
]
|
|
2243
2391
|
}
|
|
@@ -2245,8 +2393,8 @@ function SignIn(props) {
|
|
|
2245
2393
|
}
|
|
2246
2394
|
|
|
2247
2395
|
// src/react/components/auth/SignUp.tsx
|
|
2248
|
-
var
|
|
2249
|
-
var
|
|
2396
|
+
var import_react14 = require("react");
|
|
2397
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2250
2398
|
function SignUp(props) {
|
|
2251
2399
|
const a = useAppearance(props.appearance);
|
|
2252
2400
|
const cardClass = useCardClass();
|
|
@@ -2254,13 +2402,13 @@ function SignUp(props) {
|
|
|
2254
2402
|
const { t } = useCopy(props.localization);
|
|
2255
2403
|
const { auth } = useAuth();
|
|
2256
2404
|
const { submitting, error, notice, run } = useAction();
|
|
2257
|
-
const [email, setEmail] = (0,
|
|
2258
|
-
const [password, setPassword] = (0,
|
|
2405
|
+
const [email, setEmail] = (0, import_react14.useState)("");
|
|
2406
|
+
const [password, setPassword] = (0, import_react14.useState)("");
|
|
2259
2407
|
const variant = props.variant ?? "quiet";
|
|
2260
2408
|
const branded = variant === "branded";
|
|
2261
2409
|
const grouped = variant === "grouped";
|
|
2262
2410
|
const logo = useBrandLogo(props.logo);
|
|
2263
|
-
const emailField = /* @__PURE__ */ (0,
|
|
2411
|
+
const emailField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2264
2412
|
Field,
|
|
2265
2413
|
{
|
|
2266
2414
|
label: t.signUp.email,
|
|
@@ -2273,7 +2421,7 @@ function SignUp(props) {
|
|
|
2273
2421
|
grouped
|
|
2274
2422
|
}
|
|
2275
2423
|
);
|
|
2276
|
-
const passwordField = /* @__PURE__ */ (0,
|
|
2424
|
+
const passwordField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2277
2425
|
Field,
|
|
2278
2426
|
{
|
|
2279
2427
|
label: t.signUp.password,
|
|
@@ -2286,7 +2434,7 @@ function SignUp(props) {
|
|
|
2286
2434
|
grouped
|
|
2287
2435
|
}
|
|
2288
2436
|
);
|
|
2289
|
-
return /* @__PURE__ */ (0,
|
|
2437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2290
2438
|
"form",
|
|
2291
2439
|
{
|
|
2292
2440
|
...a.el("signUp.root", cardClass),
|
|
@@ -2302,7 +2450,7 @@ function SignUp(props) {
|
|
|
2302
2450
|
});
|
|
2303
2451
|
},
|
|
2304
2452
|
children: [
|
|
2305
|
-
/* @__PURE__ */ (0,
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2306
2454
|
CardHeader,
|
|
2307
2455
|
{
|
|
2308
2456
|
title: t.signUp.title,
|
|
@@ -2313,24 +2461,24 @@ function SignUp(props) {
|
|
|
2313
2461
|
branded
|
|
2314
2462
|
}
|
|
2315
2463
|
),
|
|
2316
|
-
/* @__PURE__ */ (0,
|
|
2317
|
-
grouped ? /* @__PURE__ */ (0,
|
|
2464
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardBody, { children: [
|
|
2465
|
+
grouped ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FieldGroup, { children: [
|
|
2318
2466
|
emailField,
|
|
2319
2467
|
passwordField
|
|
2320
|
-
] }) : /* @__PURE__ */ (0,
|
|
2468
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2321
2469
|
emailField,
|
|
2322
2470
|
passwordField
|
|
2323
2471
|
] }),
|
|
2324
|
-
error ? /* @__PURE__ */ (0,
|
|
2325
|
-
notice ? /* @__PURE__ */ (0,
|
|
2326
|
-
/* @__PURE__ */ (0,
|
|
2472
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2473
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "info", children: notice }) : null,
|
|
2474
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signUp.submitButton", children: t.signUp.submitButton })
|
|
2327
2475
|
] }),
|
|
2328
|
-
props.onSignIn ? /* @__PURE__ */ (0,
|
|
2329
|
-
/* @__PURE__ */ (0,
|
|
2476
|
+
props.onSignIn ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardFooter, { ruled: !branded, children: [
|
|
2477
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "throttle-muted", children: [
|
|
2330
2478
|
t.signUp.switchPrompt,
|
|
2331
2479
|
" "
|
|
2332
2480
|
] }),
|
|
2333
|
-
/* @__PURE__ */ (0,
|
|
2481
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
|
|
2334
2482
|
] }) : null
|
|
2335
2483
|
]
|
|
2336
2484
|
}
|
|
@@ -2338,8 +2486,8 @@ function SignUp(props) {
|
|
|
2338
2486
|
}
|
|
2339
2487
|
|
|
2340
2488
|
// src/react/components/auth/ForgotPassword.tsx
|
|
2341
|
-
var
|
|
2342
|
-
var
|
|
2489
|
+
var import_react15 = require("react");
|
|
2490
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2343
2491
|
function ForgotPassword(props) {
|
|
2344
2492
|
const a = useAppearance(props.appearance);
|
|
2345
2493
|
const cardClass = useCardClass();
|
|
@@ -2347,10 +2495,10 @@ function ForgotPassword(props) {
|
|
|
2347
2495
|
const { t } = useCopy(props.localization);
|
|
2348
2496
|
const { auth } = useAuth();
|
|
2349
2497
|
const { submitting, error, notice, run } = useAction();
|
|
2350
|
-
const [email, setEmail] = (0,
|
|
2498
|
+
const [email, setEmail] = (0, import_react15.useState)("");
|
|
2351
2499
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2352
2500
|
const logo = useBrandLogo(props.logo);
|
|
2353
|
-
return /* @__PURE__ */ (0,
|
|
2501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2354
2502
|
"form",
|
|
2355
2503
|
{
|
|
2356
2504
|
...a.el("forgotPassword.root", cardClass),
|
|
@@ -2362,7 +2510,7 @@ function ForgotPassword(props) {
|
|
|
2362
2510
|
});
|
|
2363
2511
|
},
|
|
2364
2512
|
children: [
|
|
2365
|
-
/* @__PURE__ */ (0,
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2366
2514
|
CardHeader,
|
|
2367
2515
|
{
|
|
2368
2516
|
title: t.forgotPassword.title,
|
|
@@ -2373,8 +2521,8 @@ function ForgotPassword(props) {
|
|
|
2373
2521
|
branded
|
|
2374
2522
|
}
|
|
2375
2523
|
),
|
|
2376
|
-
/* @__PURE__ */ (0,
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2524
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CardBody, { children: [
|
|
2525
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2378
2526
|
Field,
|
|
2379
2527
|
{
|
|
2380
2528
|
label: t.forgotPassword.email,
|
|
@@ -2386,19 +2534,19 @@ function ForgotPassword(props) {
|
|
|
2386
2534
|
elementKey: "forgotPassword.emailField"
|
|
2387
2535
|
}
|
|
2388
2536
|
),
|
|
2389
|
-
error ? /* @__PURE__ */ (0,
|
|
2390
|
-
notice ? /* @__PURE__ */ (0,
|
|
2391
|
-
/* @__PURE__ */ (0,
|
|
2537
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2538
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2539
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { type: "submit", loading: submitting, elementKey: "forgotPassword.submitButton", children: t.forgotPassword.submitButton })
|
|
2392
2540
|
] }),
|
|
2393
|
-
props.onBack ? /* @__PURE__ */ (0,
|
|
2541
|
+
props.onBack ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CardFooter, { ruled: !branded, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "link", elementKey: "forgotPassword.backLink", onClick: props.onBack, children: t.forgotPassword.backLink }) }) : null
|
|
2394
2542
|
]
|
|
2395
2543
|
}
|
|
2396
2544
|
) }) });
|
|
2397
2545
|
}
|
|
2398
2546
|
|
|
2399
2547
|
// src/react/components/auth/ResetPassword.tsx
|
|
2400
|
-
var
|
|
2401
|
-
var
|
|
2548
|
+
var import_react16 = require("react");
|
|
2549
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2402
2550
|
function ResetPassword(props) {
|
|
2403
2551
|
const a = useAppearance(props.appearance);
|
|
2404
2552
|
const cardClass = useCardClass();
|
|
@@ -2406,11 +2554,11 @@ function ResetPassword(props) {
|
|
|
2406
2554
|
const { t } = useCopy(props.localization);
|
|
2407
2555
|
const { auth } = useAuth();
|
|
2408
2556
|
const { submitting, error, notice, run } = useAction();
|
|
2409
|
-
const [password, setPassword] = (0,
|
|
2557
|
+
const [password, setPassword] = (0, import_react16.useState)("");
|
|
2410
2558
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2411
2559
|
const logo = useBrandLogo(props.logo);
|
|
2412
|
-
return /* @__PURE__ */ (0,
|
|
2413
|
-
/* @__PURE__ */ (0,
|
|
2560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { ...a.el("resetPassword.root", cardClass), children: [
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2414
2562
|
CardHeader,
|
|
2415
2563
|
{
|
|
2416
2564
|
title: t.resetPassword.title,
|
|
@@ -2420,11 +2568,11 @@ function ResetPassword(props) {
|
|
|
2420
2568
|
branded
|
|
2421
2569
|
}
|
|
2422
2570
|
),
|
|
2423
|
-
/* @__PURE__ */ (0,
|
|
2571
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardBody, { children: !props.token ? (
|
|
2424
2572
|
// No form at all without a token. A submit button that can only
|
|
2425
2573
|
// fail is worse than an explanation.
|
|
2426
|
-
/* @__PURE__ */ (0,
|
|
2427
|
-
) : /* @__PURE__ */ (0,
|
|
2574
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: t.resetPassword.missingToken })
|
|
2575
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2428
2576
|
"form",
|
|
2429
2577
|
{
|
|
2430
2578
|
onSubmit: (e) => {
|
|
@@ -2435,8 +2583,8 @@ function ResetPassword(props) {
|
|
|
2435
2583
|
return t.resetPassword.doneNotice;
|
|
2436
2584
|
});
|
|
2437
2585
|
},
|
|
2438
|
-
children: /* @__PURE__ */ (0,
|
|
2439
|
-
/* @__PURE__ */ (0,
|
|
2586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "throttle-stack", children: [
|
|
2587
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2440
2588
|
Field,
|
|
2441
2589
|
{
|
|
2442
2590
|
label: t.resetPassword.password,
|
|
@@ -2448,9 +2596,9 @@ function ResetPassword(props) {
|
|
|
2448
2596
|
elementKey: "resetPassword.passwordField"
|
|
2449
2597
|
}
|
|
2450
2598
|
),
|
|
2451
|
-
error ? /* @__PURE__ */ (0,
|
|
2452
|
-
notice ? /* @__PURE__ */ (0,
|
|
2453
|
-
/* @__PURE__ */ (0,
|
|
2599
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2600
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { type: "submit", loading: submitting, elementKey: "resetPassword.submitButton", children: t.resetPassword.submitButton })
|
|
2454
2602
|
] })
|
|
2455
2603
|
}
|
|
2456
2604
|
) })
|
|
@@ -2458,8 +2606,8 @@ function ResetPassword(props) {
|
|
|
2458
2606
|
}
|
|
2459
2607
|
|
|
2460
2608
|
// src/react/components/auth/VerifyEmail.tsx
|
|
2461
|
-
var
|
|
2462
|
-
var
|
|
2609
|
+
var import_react17 = require("react");
|
|
2610
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2463
2611
|
function VerifyEmail(props) {
|
|
2464
2612
|
const a = useAppearance(props.appearance);
|
|
2465
2613
|
const cardClass = useCardClass();
|
|
@@ -2467,12 +2615,12 @@ function VerifyEmail(props) {
|
|
|
2467
2615
|
const { t, errorMessage } = useCopy(props.localization);
|
|
2468
2616
|
const { auth } = useAuth();
|
|
2469
2617
|
const { submitting, notice, run } = useAction();
|
|
2470
|
-
const [state, setState] = (0,
|
|
2471
|
-
const [error, setError] = (0,
|
|
2618
|
+
const [state, setState] = (0, import_react17.useState)(props.token ? "verifying" : "idle");
|
|
2619
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
2472
2620
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
2473
2621
|
const logo = useBrandLogo(props.logo);
|
|
2474
|
-
const attempted = (0,
|
|
2475
|
-
(0,
|
|
2622
|
+
const attempted = (0, import_react17.useRef)(null);
|
|
2623
|
+
(0, import_react17.useEffect)(() => {
|
|
2476
2624
|
const token = props.token;
|
|
2477
2625
|
if (!token || attempted.current === token) return;
|
|
2478
2626
|
attempted.current = token;
|
|
@@ -2485,8 +2633,8 @@ function VerifyEmail(props) {
|
|
|
2485
2633
|
setState("failed");
|
|
2486
2634
|
});
|
|
2487
2635
|
}, [props.token, auth]);
|
|
2488
|
-
return /* @__PURE__ */ (0,
|
|
2489
|
-
/* @__PURE__ */ (0,
|
|
2636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ...a.el("verifyEmail.root", cardClass), children: [
|
|
2637
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2490
2638
|
CardHeader,
|
|
2491
2639
|
{
|
|
2492
2640
|
title: t.verifyEmail.title,
|
|
@@ -2496,17 +2644,17 @@ function VerifyEmail(props) {
|
|
|
2496
2644
|
branded
|
|
2497
2645
|
}
|
|
2498
2646
|
),
|
|
2499
|
-
/* @__PURE__ */ (0,
|
|
2500
|
-
state === "verifying" ? /* @__PURE__ */ (0,
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
2647
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(CardBody, { children: [
|
|
2648
|
+
state === "verifying" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { children: [
|
|
2649
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Spinner, {}),
|
|
2502
2650
|
" ",
|
|
2503
2651
|
t.verifyEmail.verifying
|
|
2504
2652
|
] }) : null,
|
|
2505
|
-
state === "done" ? /* @__PURE__ */ (0,
|
|
2506
|
-
state === "failed" && error ? /* @__PURE__ */ (0,
|
|
2507
|
-
state === "idle" ? /* @__PURE__ */ (0,
|
|
2508
|
-
notice ? /* @__PURE__ */ (0,
|
|
2509
|
-
state !== "done" ? /* @__PURE__ */ (0,
|
|
2653
|
+
state === "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: t.verifyEmail.success }) : null,
|
|
2654
|
+
state === "failed" && error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2655
|
+
state === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "throttle-muted", children: t.verifyEmail.instructions }) : null,
|
|
2656
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2657
|
+
state !== "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2510
2658
|
Button,
|
|
2511
2659
|
{
|
|
2512
2660
|
variant: "secondary",
|
|
@@ -2524,7 +2672,7 @@ function VerifyEmail(props) {
|
|
|
2524
2672
|
}
|
|
2525
2673
|
|
|
2526
2674
|
// src/react/components/auth/AuthFlow.tsx
|
|
2527
|
-
var
|
|
2675
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2528
2676
|
var HASH_FOR = {
|
|
2529
2677
|
signIn: "#/sign-in",
|
|
2530
2678
|
signUp: "#/sign-up",
|
|
@@ -2550,9 +2698,9 @@ function readLocation() {
|
|
|
2550
2698
|
function AuthFlow(props) {
|
|
2551
2699
|
const a = useAppearance(props.appearance);
|
|
2552
2700
|
const controlled = props.view !== void 0;
|
|
2553
|
-
const [internal, setInternal] = (0,
|
|
2554
|
-
const [urlToken, setUrlToken] = (0,
|
|
2555
|
-
(0,
|
|
2701
|
+
const [internal, setInternal] = (0, import_react18.useState)(props.initialView ?? "signIn");
|
|
2702
|
+
const [urlToken, setUrlToken] = (0, import_react18.useState)(void 0);
|
|
2703
|
+
(0, import_react18.useEffect)(() => {
|
|
2556
2704
|
const found = readLocation();
|
|
2557
2705
|
if (found.token) setUrlToken(found.token);
|
|
2558
2706
|
if (found.view && !controlled && props.initialView === void 0) setInternal(found.view);
|
|
@@ -2566,7 +2714,7 @@ function AuthFlow(props) {
|
|
|
2566
2714
|
window.location.hash = HASH_FOR[next];
|
|
2567
2715
|
}
|
|
2568
2716
|
};
|
|
2569
|
-
(0,
|
|
2717
|
+
(0, import_react18.useEffect)(() => {
|
|
2570
2718
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
2571
2719
|
const onHashChange = () => {
|
|
2572
2720
|
if (controlled) return;
|
|
@@ -2582,8 +2730,8 @@ function AuthFlow(props) {
|
|
|
2582
2730
|
return () => window.removeEventListener("hashchange", onHashChange);
|
|
2583
2731
|
}, [props.routing, controlled]);
|
|
2584
2732
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
2585
|
-
return /* @__PURE__ */ (0,
|
|
2586
|
-
view === "signIn" ? /* @__PURE__ */ (0,
|
|
2733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ...a.el("authFlow.root"), children: [
|
|
2734
|
+
view === "signIn" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2587
2735
|
SignIn,
|
|
2588
2736
|
{
|
|
2589
2737
|
...shared,
|
|
@@ -2592,19 +2740,19 @@ function AuthFlow(props) {
|
|
|
2592
2740
|
onSignUp: () => go("signUp")
|
|
2593
2741
|
}
|
|
2594
2742
|
) : null,
|
|
2595
|
-
view === "signUp" ? /* @__PURE__ */ (0,
|
|
2596
|
-
view === "forgotPassword" ? /* @__PURE__ */ (0,
|
|
2597
|
-
view === "resetPassword" ? /* @__PURE__ */ (0,
|
|
2598
|
-
view === "verifyEmail" ? /* @__PURE__ */ (0,
|
|
2743
|
+
view === "signUp" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SignUp, { ...shared, onSuccess: props.afterSignUp, onSignIn: () => go("signIn") }) : null,
|
|
2744
|
+
view === "forgotPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ForgotPassword, { ...shared, onBack: () => go("signIn") }) : null,
|
|
2745
|
+
view === "resetPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ResetPassword, { ...shared, token, onSuccess: () => go("signIn") }) : null,
|
|
2746
|
+
view === "verifyEmail" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VerifyEmail, { ...shared, token }) : null
|
|
2599
2747
|
] }) });
|
|
2600
2748
|
}
|
|
2601
2749
|
|
|
2602
2750
|
// src/react/components/auth/AuthModal.tsx
|
|
2603
|
-
var
|
|
2751
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2604
2752
|
function AuthModal(props) {
|
|
2605
2753
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2606
|
-
const titleId = (0,
|
|
2607
|
-
return /* @__PURE__ */ (0,
|
|
2754
|
+
const titleId = (0, import_react19.useId)();
|
|
2755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2608
2756
|
Modal,
|
|
2609
2757
|
{
|
|
2610
2758
|
open: props.open,
|
|
@@ -2614,8 +2762,8 @@ function AuthModal(props) {
|
|
|
2614
2762
|
overlayKey: "authModal.overlay",
|
|
2615
2763
|
containerKey: "authModal.container",
|
|
2616
2764
|
children: [
|
|
2617
|
-
/* @__PURE__ */ (0,
|
|
2618
|
-
/* @__PURE__ */ (0,
|
|
2765
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h2", { id: titleId, style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Account" }),
|
|
2766
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2619
2767
|
AuthFlow,
|
|
2620
2768
|
{
|
|
2621
2769
|
initialView: props.initialView,
|
|
@@ -2631,14 +2779,14 @@ function AuthModal(props) {
|
|
|
2631
2779
|
}
|
|
2632
2780
|
|
|
2633
2781
|
// src/react/components/account/AccountModal.tsx
|
|
2634
|
-
var
|
|
2782
|
+
var import_react31 = require("react");
|
|
2635
2783
|
|
|
2636
2784
|
// src/react/components/account/AccountDashboard.tsx
|
|
2637
|
-
var
|
|
2785
|
+
var import_react30 = require("react");
|
|
2638
2786
|
|
|
2639
2787
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2640
|
-
var
|
|
2641
|
-
var
|
|
2788
|
+
var import_react20 = require("react");
|
|
2789
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2642
2790
|
var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
|
|
2643
2791
|
function readDismissed() {
|
|
2644
2792
|
try {
|
|
@@ -2659,14 +2807,14 @@ function VerifyEmailBanner(props) {
|
|
|
2659
2807
|
const { t } = useCopy(props.localization);
|
|
2660
2808
|
const { auth, status, emailVerified } = useAuth();
|
|
2661
2809
|
const { submitting, notice, error, run } = useAction();
|
|
2662
|
-
const [dismissed, setDismissed] = (0,
|
|
2810
|
+
const [dismissed, setDismissed] = (0, import_react20.useState)(readDismissed);
|
|
2663
2811
|
if (status !== "authenticated" || emailVerified || dismissed) return null;
|
|
2664
|
-
return /* @__PURE__ */ (0,
|
|
2665
|
-
/* @__PURE__ */ (0,
|
|
2666
|
-
notice ? /* @__PURE__ */ (0,
|
|
2667
|
-
error ? /* @__PURE__ */ (0,
|
|
2668
|
-
/* @__PURE__ */ (0,
|
|
2669
|
-
/* @__PURE__ */ (0,
|
|
2812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
|
|
2813
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
|
|
2814
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
2815
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "throttle-actions", children: [
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2670
2818
|
Button,
|
|
2671
2819
|
{
|
|
2672
2820
|
variant: "secondary",
|
|
@@ -2679,7 +2827,7 @@ function VerifyEmailBanner(props) {
|
|
|
2679
2827
|
children: t.verifyBanner.resendButton
|
|
2680
2828
|
}
|
|
2681
2829
|
),
|
|
2682
|
-
/* @__PURE__ */ (0,
|
|
2830
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2683
2831
|
Button,
|
|
2684
2832
|
{
|
|
2685
2833
|
variant: "link",
|
|
@@ -2696,9 +2844,9 @@ function VerifyEmailBanner(props) {
|
|
|
2696
2844
|
}
|
|
2697
2845
|
|
|
2698
2846
|
// src/react/components/account/icons.tsx
|
|
2699
|
-
var
|
|
2847
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2700
2848
|
function Glyph(props) {
|
|
2701
|
-
return /* @__PURE__ */ (0,
|
|
2849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2702
2850
|
"svg",
|
|
2703
2851
|
{
|
|
2704
2852
|
className: "throttle-tabs__railicon",
|
|
@@ -2717,43 +2865,43 @@ function Glyph(props) {
|
|
|
2717
2865
|
);
|
|
2718
2866
|
}
|
|
2719
2867
|
var ACCOUNT_ICONS = {
|
|
2720
|
-
profile: /* @__PURE__ */ (0,
|
|
2721
|
-
/* @__PURE__ */ (0,
|
|
2722
|
-
/* @__PURE__ */ (0,
|
|
2868
|
+
profile: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2869
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "8", r: "4" }),
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 21c0-4 3.6-6 8-6s8 2 8 6" })
|
|
2723
2871
|
] }),
|
|
2724
|
-
addresses: /* @__PURE__ */ (0,
|
|
2725
|
-
/* @__PURE__ */ (0,
|
|
2726
|
-
/* @__PURE__ */ (0,
|
|
2872
|
+
addresses: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 21s7-5.3 7-11a7 7 0 1 0-14 0c0 5.7 7 11 7 11Z" }),
|
|
2874
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "10", r: "2.5" })
|
|
2727
2875
|
] }),
|
|
2728
|
-
paymentMethods: /* @__PURE__ */ (0,
|
|
2729
|
-
/* @__PURE__ */ (0,
|
|
2730
|
-
/* @__PURE__ */ (0,
|
|
2876
|
+
paymentMethods: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2877
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
|
|
2878
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M2.5 10h19" })
|
|
2731
2879
|
] }),
|
|
2732
|
-
orders: /* @__PURE__ */ (0,
|
|
2733
|
-
/* @__PURE__ */ (0,
|
|
2734
|
-
/* @__PURE__ */ (0,
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
2880
|
+
orders: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2881
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 7h16v13H4z" }),
|
|
2882
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 7V4h8v3" }),
|
|
2883
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 12h8" })
|
|
2736
2884
|
] }),
|
|
2737
|
-
invoices: /* @__PURE__ */ (0,
|
|
2738
|
-
/* @__PURE__ */ (0,
|
|
2739
|
-
/* @__PURE__ */ (0,
|
|
2885
|
+
invoices: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2886
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M6 3h12v18l-3-2-3 2-3-2-3 2Z" }),
|
|
2887
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M9 8h6M9 12h6" })
|
|
2740
2888
|
] }),
|
|
2741
|
-
subscriptions: /* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
2743
|
-
/* @__PURE__ */ (0,
|
|
2744
|
-
/* @__PURE__ */ (0,
|
|
2889
|
+
subscriptions: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2890
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M3 12a9 9 0 0 1 15.5-6.2" }),
|
|
2891
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M21 12a9 9 0 0 1-15.5 6.2" }),
|
|
2892
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M18 3v4h-4M6 21v-4h4" })
|
|
2745
2893
|
] }),
|
|
2746
|
-
security: /* @__PURE__ */ (0,
|
|
2747
|
-
/* @__PURE__ */ (0,
|
|
2748
|
-
/* @__PURE__ */ (0,
|
|
2894
|
+
security: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
|
|
2895
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 3 4 6.5V12c0 5 3.4 8.3 8 9 4.6-.7 8-4 8-9V6.5Z" }),
|
|
2896
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "m9 12 2 2 4-4" })
|
|
2749
2897
|
] })
|
|
2750
2898
|
};
|
|
2751
2899
|
|
|
2752
2900
|
// src/react/components/account/ProfilePanel.tsx
|
|
2753
|
-
var
|
|
2901
|
+
var import_react22 = require("react");
|
|
2754
2902
|
|
|
2755
2903
|
// src/react/hooks.ts
|
|
2756
|
-
var
|
|
2904
|
+
var import_react21 = require("react");
|
|
2757
2905
|
function asError(err) {
|
|
2758
2906
|
if (err instanceof ThrottleAuthError) return err;
|
|
2759
2907
|
const anyErr = err;
|
|
@@ -2765,19 +2913,19 @@ function asError(err) {
|
|
|
2765
2913
|
}
|
|
2766
2914
|
function useResource(empty, load, deps) {
|
|
2767
2915
|
const { status, emailVerified } = useAuth();
|
|
2768
|
-
const [data, setData] = (0,
|
|
2769
|
-
const [isLoading, setIsLoading] = (0,
|
|
2770
|
-
const [error, setError] = (0,
|
|
2771
|
-
const gen = (0,
|
|
2772
|
-
const alive = (0,
|
|
2773
|
-
(0,
|
|
2916
|
+
const [data, setData] = (0, import_react21.useState)(empty);
|
|
2917
|
+
const [isLoading, setIsLoading] = (0, import_react21.useState)(status === "loading");
|
|
2918
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
2919
|
+
const gen = (0, import_react21.useRef)(0);
|
|
2920
|
+
const alive = (0, import_react21.useRef)(true);
|
|
2921
|
+
(0, import_react21.useEffect)(() => {
|
|
2774
2922
|
alive.current = true;
|
|
2775
2923
|
return () => {
|
|
2776
2924
|
alive.current = false;
|
|
2777
2925
|
gen.current++;
|
|
2778
2926
|
};
|
|
2779
2927
|
}, []);
|
|
2780
|
-
const refetch = (0,
|
|
2928
|
+
const refetch = (0, import_react21.useCallback)(async () => {
|
|
2781
2929
|
const mine = ++gen.current;
|
|
2782
2930
|
setIsLoading(true);
|
|
2783
2931
|
try {
|
|
@@ -2792,7 +2940,7 @@ function useResource(empty, load, deps) {
|
|
|
2792
2940
|
if (alive.current && gen.current === mine) setIsLoading(false);
|
|
2793
2941
|
}
|
|
2794
2942
|
}, deps);
|
|
2795
|
-
(0,
|
|
2943
|
+
(0, import_react21.useEffect)(() => {
|
|
2796
2944
|
if (status !== "authenticated") {
|
|
2797
2945
|
gen.current++;
|
|
2798
2946
|
setData(empty);
|
|
@@ -2807,7 +2955,7 @@ function useResource(empty, load, deps) {
|
|
|
2807
2955
|
function useCustomer() {
|
|
2808
2956
|
const { account } = useAuth();
|
|
2809
2957
|
const res = useResource(null, () => account.getProfile(), [account]);
|
|
2810
|
-
const update = (0,
|
|
2958
|
+
const update = (0, import_react21.useCallback)(async (patch) => {
|
|
2811
2959
|
await account.updateProfile(patch);
|
|
2812
2960
|
await res.refetch();
|
|
2813
2961
|
}, [account, res]);
|
|
@@ -2876,32 +3024,32 @@ function useInvoice(id) {
|
|
|
2876
3024
|
}
|
|
2877
3025
|
|
|
2878
3026
|
// src/react/components/account/PanelState.tsx
|
|
2879
|
-
var
|
|
3027
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2880
3028
|
function PanelState(props) {
|
|
2881
3029
|
const { t, errorMessage } = useCopy();
|
|
2882
3030
|
const { data, isLoading, error, refetch } = props.resource;
|
|
2883
3031
|
const empty = props.isEmpty(data);
|
|
2884
|
-
if (isLoading && empty) return /* @__PURE__ */ (0,
|
|
2885
|
-
const errorBanner = error ? /* @__PURE__ */ (0,
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2887
|
-
/* @__PURE__ */ (0,
|
|
3032
|
+
if (isLoading && empty) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Skeleton, { count: props.skeletonRows ?? 3 });
|
|
3033
|
+
const errorBanner = error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "throttle-stack", children: [
|
|
3034
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "error", children: errorMessage(error) }),
|
|
3035
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { variant: "secondary", onClick: () => void refetch(), children: t.common.retry })
|
|
2888
3036
|
] }) : null;
|
|
2889
3037
|
const gatedByVerification = error?.code === "verification_required";
|
|
2890
3038
|
if (gatedByVerification && empty) {
|
|
2891
|
-
return /* @__PURE__ */ (0,
|
|
3039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
|
|
2892
3040
|
}
|
|
2893
3041
|
if (error && empty) return errorBanner;
|
|
2894
3042
|
if (empty) {
|
|
2895
|
-
return props.gated ? /* @__PURE__ */ (0,
|
|
3043
|
+
return props.gated ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.emptyDescription });
|
|
2896
3044
|
}
|
|
2897
|
-
return /* @__PURE__ */ (0,
|
|
3045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
2898
3046
|
errorBanner,
|
|
2899
3047
|
props.children(data)
|
|
2900
3048
|
] });
|
|
2901
3049
|
}
|
|
2902
3050
|
|
|
2903
3051
|
// src/react/components/account/ProfilePanel.tsx
|
|
2904
|
-
var
|
|
3052
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2905
3053
|
function ProfilePanel(props) {
|
|
2906
3054
|
const a = useAppearance(props.appearance);
|
|
2907
3055
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2909,28 +3057,27 @@ function ProfilePanel(props) {
|
|
|
2909
3057
|
const { status } = useAuth();
|
|
2910
3058
|
const resource = useCustomer();
|
|
2911
3059
|
const { submitting, error, notice, run } = useAction();
|
|
2912
|
-
const [form, setForm] = (0,
|
|
2913
|
-
const edited = (0,
|
|
2914
|
-
(0,
|
|
3060
|
+
const [form, setForm] = (0, import_react22.useState)({ firstName: "", lastName: "", phone: "", company: "" });
|
|
3061
|
+
const edited = (0, import_react22.useRef)(false);
|
|
3062
|
+
(0, import_react22.useEffect)(() => {
|
|
2915
3063
|
const c = resource.data;
|
|
2916
3064
|
if (!c || edited.current) return;
|
|
2917
3065
|
setForm({
|
|
2918
3066
|
firstName: c.firstName ?? "",
|
|
2919
3067
|
lastName: c.lastName ?? "",
|
|
2920
3068
|
phone: c.phone ?? "",
|
|
2921
|
-
company: c.company ?? ""
|
|
2922
|
-
acceptsMarketing: Boolean(c.acceptsMarketing)
|
|
3069
|
+
company: c.company ?? ""
|
|
2923
3070
|
});
|
|
2924
3071
|
}, [resource.data]);
|
|
2925
3072
|
if (status === "unauthenticated") return null;
|
|
2926
|
-
return /* @__PURE__ */ (0,
|
|
3073
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.el("profilePanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2927
3074
|
PanelState,
|
|
2928
3075
|
{
|
|
2929
3076
|
resource,
|
|
2930
3077
|
isEmpty: (c) => c === null,
|
|
2931
3078
|
emptyTitle: t.common.somethingWentWrong,
|
|
2932
3079
|
skeletonRows: 4,
|
|
2933
|
-
children: (customer) => /* @__PURE__ */ (0,
|
|
3080
|
+
children: (customer) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
2934
3081
|
"form",
|
|
2935
3082
|
{
|
|
2936
3083
|
...a.el("profilePanel.form", "throttle-stack"),
|
|
@@ -2942,14 +3089,13 @@ function ProfilePanel(props) {
|
|
|
2942
3089
|
firstName: form.firstName,
|
|
2943
3090
|
lastName: form.lastName,
|
|
2944
3091
|
phone: form.phone,
|
|
2945
|
-
company: form.company || null
|
|
2946
|
-
acceptsMarketing: form.acceptsMarketing
|
|
3092
|
+
company: form.company || null
|
|
2947
3093
|
});
|
|
2948
3094
|
return t.profile.savedNotice;
|
|
2949
3095
|
});
|
|
2950
3096
|
},
|
|
2951
3097
|
children: [
|
|
2952
|
-
/* @__PURE__ */ (0,
|
|
3098
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2953
3099
|
Field,
|
|
2954
3100
|
{
|
|
2955
3101
|
label: t.profile.email,
|
|
@@ -2961,7 +3107,7 @@ function ProfilePanel(props) {
|
|
|
2961
3107
|
hint: t.profile.emailReadOnly
|
|
2962
3108
|
}
|
|
2963
3109
|
),
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
3110
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2965
3111
|
Field,
|
|
2966
3112
|
{
|
|
2967
3113
|
label: t.profile.firstName,
|
|
@@ -2973,7 +3119,7 @@ function ProfilePanel(props) {
|
|
|
2973
3119
|
}
|
|
2974
3120
|
}
|
|
2975
3121
|
),
|
|
2976
|
-
/* @__PURE__ */ (0,
|
|
3122
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2977
3123
|
Field,
|
|
2978
3124
|
{
|
|
2979
3125
|
label: t.profile.lastName,
|
|
@@ -2985,7 +3131,7 @@ function ProfilePanel(props) {
|
|
|
2985
3131
|
}
|
|
2986
3132
|
}
|
|
2987
3133
|
),
|
|
2988
|
-
/* @__PURE__ */ (0,
|
|
3134
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2989
3135
|
Field,
|
|
2990
3136
|
{
|
|
2991
3137
|
label: t.profile.phone,
|
|
@@ -2998,7 +3144,7 @@ function ProfilePanel(props) {
|
|
|
2998
3144
|
}
|
|
2999
3145
|
}
|
|
3000
3146
|
),
|
|
3001
|
-
/* @__PURE__ */ (0,
|
|
3147
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3002
3148
|
Field,
|
|
3003
3149
|
{
|
|
3004
3150
|
label: t.profile.company,
|
|
@@ -3010,23 +3156,9 @@ function ProfilePanel(props) {
|
|
|
3010
3156
|
}
|
|
3011
3157
|
}
|
|
3012
3158
|
),
|
|
3013
|
-
/* @__PURE__ */ (0,
|
|
3014
|
-
|
|
3015
|
-
|
|
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
|
-
error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3028
|
-
notice ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
3029
|
-
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
3159
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3160
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "success", children: notice }) : null,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
3030
3162
|
]
|
|
3031
3163
|
}
|
|
3032
3164
|
)
|
|
@@ -3035,16 +3167,16 @@ function ProfilePanel(props) {
|
|
|
3035
3167
|
}
|
|
3036
3168
|
|
|
3037
3169
|
// src/react/components/account/AddressesPanel.tsx
|
|
3038
|
-
var
|
|
3170
|
+
var import_react24 = require("react");
|
|
3039
3171
|
|
|
3040
3172
|
// src/react/components/account/AddressForm.tsx
|
|
3041
|
-
var
|
|
3042
|
-
var
|
|
3173
|
+
var import_react23 = require("react");
|
|
3174
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3043
3175
|
function AddressForm(props) {
|
|
3044
3176
|
const a = useAppearance();
|
|
3045
3177
|
const { t } = useCopy();
|
|
3046
3178
|
const i = props.initial;
|
|
3047
|
-
const [form, setForm] = (0,
|
|
3179
|
+
const [form, setForm] = (0, import_react23.useState)({
|
|
3048
3180
|
label: i?.label ?? "",
|
|
3049
3181
|
firstName: i?.firstName ?? "",
|
|
3050
3182
|
lastName: i?.lastName ?? "",
|
|
@@ -3058,7 +3190,7 @@ function AddressForm(props) {
|
|
|
3058
3190
|
phone: i?.phone ?? ""
|
|
3059
3191
|
});
|
|
3060
3192
|
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
3061
|
-
return /* @__PURE__ */ (0,
|
|
3193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3062
3194
|
"form",
|
|
3063
3195
|
{
|
|
3064
3196
|
...a.el("addressesPanel.form", "throttle-stack"),
|
|
@@ -3080,11 +3212,11 @@ function AddressForm(props) {
|
|
|
3080
3212
|
});
|
|
3081
3213
|
},
|
|
3082
3214
|
children: [
|
|
3083
|
-
/* @__PURE__ */ (0,
|
|
3084
|
-
/* @__PURE__ */ (0,
|
|
3085
|
-
/* @__PURE__ */ (0,
|
|
3086
|
-
/* @__PURE__ */ (0,
|
|
3087
|
-
/* @__PURE__ */ (0,
|
|
3215
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
|
|
3216
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" }),
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" }),
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3088
3220
|
Field,
|
|
3089
3221
|
{
|
|
3090
3222
|
label: t.addresses.addressLine1,
|
|
@@ -3094,7 +3226,7 @@ function AddressForm(props) {
|
|
|
3094
3226
|
autoComplete: "address-line1"
|
|
3095
3227
|
}
|
|
3096
3228
|
),
|
|
3097
|
-
/* @__PURE__ */ (0,
|
|
3229
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3098
3230
|
Field,
|
|
3099
3231
|
{
|
|
3100
3232
|
label: t.addresses.addressLine2,
|
|
@@ -3103,8 +3235,8 @@ function AddressForm(props) {
|
|
|
3103
3235
|
autoComplete: "address-line2"
|
|
3104
3236
|
}
|
|
3105
3237
|
),
|
|
3106
|
-
/* @__PURE__ */ (0,
|
|
3107
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3108
3240
|
Field,
|
|
3109
3241
|
{
|
|
3110
3242
|
label: t.addresses.stateProvince,
|
|
@@ -3113,7 +3245,7 @@ function AddressForm(props) {
|
|
|
3113
3245
|
autoComplete: "address-level1"
|
|
3114
3246
|
}
|
|
3115
3247
|
),
|
|
3116
|
-
/* @__PURE__ */ (0,
|
|
3248
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3117
3249
|
Field,
|
|
3118
3250
|
{
|
|
3119
3251
|
label: t.addresses.postalCode,
|
|
@@ -3122,7 +3254,7 @@ function AddressForm(props) {
|
|
|
3122
3254
|
autoComplete: "postal-code"
|
|
3123
3255
|
}
|
|
3124
3256
|
),
|
|
3125
|
-
/* @__PURE__ */ (0,
|
|
3257
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3126
3258
|
Field,
|
|
3127
3259
|
{
|
|
3128
3260
|
label: t.addresses.countryCode,
|
|
@@ -3133,11 +3265,11 @@ function AddressForm(props) {
|
|
|
3133
3265
|
hint: "ISO 3166-1 alpha-2, e.g. GB"
|
|
3134
3266
|
}
|
|
3135
3267
|
),
|
|
3136
|
-
/* @__PURE__ */ (0,
|
|
3137
|
-
props.error ? /* @__PURE__ */ (0,
|
|
3138
|
-
/* @__PURE__ */ (0,
|
|
3139
|
-
/* @__PURE__ */ (0,
|
|
3140
|
-
/* @__PURE__ */ (0,
|
|
3268
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
|
|
3269
|
+
props.error ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "error", children: props.error }) : null,
|
|
3270
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "throttle-actions", children: [
|
|
3271
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { type: "submit", loading: props.submitting, children: t.common.save }),
|
|
3272
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "link", onClick: props.onCancel, children: t.common.cancel })
|
|
3141
3273
|
] })
|
|
3142
3274
|
]
|
|
3143
3275
|
}
|
|
@@ -3145,14 +3277,15 @@ function AddressForm(props) {
|
|
|
3145
3277
|
}
|
|
3146
3278
|
|
|
3147
3279
|
// src/react/components/account/AddressesPanel.tsx
|
|
3148
|
-
var
|
|
3280
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3149
3281
|
function AddressesPanel(props) {
|
|
3150
3282
|
const a = useAppearance(props.appearance);
|
|
3151
3283
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3152
3284
|
const { t } = useCopy(props.localization);
|
|
3153
3285
|
const resource = useAddresses();
|
|
3154
3286
|
const { submitting, error, run } = useAction();
|
|
3155
|
-
const
|
|
3287
|
+
const confirm = useConfirm();
|
|
3288
|
+
const [editing, setEditing] = (0, import_react24.useState)(null);
|
|
3156
3289
|
const variant = props.variant ?? "rows";
|
|
3157
3290
|
const rowsVariant = variant === "rows";
|
|
3158
3291
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -3160,9 +3293,9 @@ function AddressesPanel(props) {
|
|
|
3160
3293
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3161
3294
|
const close = () => setEditing(null);
|
|
3162
3295
|
const formatAddress = (address) => [address.addressLine2, address.city, address.stateProvince, address.postalCode, address.countryCode].filter(Boolean).join(", ");
|
|
3163
|
-
return /* @__PURE__ */ (0,
|
|
3164
|
-
!editing && error ? /* @__PURE__ */ (0,
|
|
3165
|
-
editing ? /* @__PURE__ */ (0,
|
|
3296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.root", "throttle-panel"), children: [
|
|
3297
|
+
!editing && error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3298
|
+
editing ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3166
3299
|
AddressForm,
|
|
3167
3300
|
{
|
|
3168
3301
|
initial: editing === "new" ? void 0 : editing,
|
|
@@ -3175,16 +3308,16 @@ function AddressesPanel(props) {
|
|
|
3175
3308
|
close();
|
|
3176
3309
|
})
|
|
3177
3310
|
}
|
|
3178
|
-
) : /* @__PURE__ */ (0,
|
|
3179
|
-
/* @__PURE__ */ (0,
|
|
3180
|
-
/* @__PURE__ */ (0,
|
|
3311
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
3312
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
|
|
3313
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3181
3314
|
PanelState,
|
|
3182
3315
|
{
|
|
3183
3316
|
resource,
|
|
3184
3317
|
isEmpty: (rows) => rows.length === 0,
|
|
3185
3318
|
emptyTitle: t.addresses.empty,
|
|
3186
3319
|
emptyDescription: t.addresses.emptyDescription,
|
|
3187
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3320
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3188
3321
|
DataTable,
|
|
3189
3322
|
{
|
|
3190
3323
|
tableKey: "addressesPanel.table",
|
|
@@ -3193,13 +3326,13 @@ function AddressesPanel(props) {
|
|
|
3193
3326
|
rows,
|
|
3194
3327
|
columns: [
|
|
3195
3328
|
{ key: "label", label: t.addresses.label, render: (address) => address.label || address.addressLine1 },
|
|
3196
|
-
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0,
|
|
3329
|
+
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
3197
3330
|
address.addressLine1,
|
|
3198
3331
|
formatAddress(address) ? `, ${formatAddress(address)}` : ""
|
|
3199
3332
|
] }) },
|
|
3200
|
-
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0,
|
|
3201
|
-
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0,
|
|
3202
|
-
!address.isDefault ? /* @__PURE__ */ (0,
|
|
3333
|
+
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null },
|
|
3334
|
+
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
|
|
3335
|
+
!address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3203
3336
|
Button,
|
|
3204
3337
|
{
|
|
3205
3338
|
variant: "secondary",
|
|
@@ -3208,7 +3341,7 @@ function AddressesPanel(props) {
|
|
|
3208
3341
|
children: t.addresses.makeDefault
|
|
3209
3342
|
}
|
|
3210
3343
|
) : null,
|
|
3211
|
-
/* @__PURE__ */ (0,
|
|
3344
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3212
3345
|
Button,
|
|
3213
3346
|
{
|
|
3214
3347
|
variant: "secondary",
|
|
@@ -3217,14 +3350,14 @@ function AddressesPanel(props) {
|
|
|
3217
3350
|
children: t.common.edit
|
|
3218
3351
|
}
|
|
3219
3352
|
),
|
|
3220
|
-
/* @__PURE__ */ (0,
|
|
3353
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3221
3354
|
Button,
|
|
3222
3355
|
{
|
|
3223
3356
|
variant: "danger",
|
|
3224
3357
|
elementKey: "addressesPanel.deleteButton",
|
|
3225
3358
|
disabled: submitting,
|
|
3226
|
-
onClick: () => {
|
|
3227
|
-
if (!
|
|
3359
|
+
onClick: async () => {
|
|
3360
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
3228
3361
|
void run(() => resource.remove(address.id));
|
|
3229
3362
|
},
|
|
3230
3363
|
children: t.common.delete
|
|
@@ -3233,17 +3366,17 @@ function AddressesPanel(props) {
|
|
|
3233
3366
|
] }) }
|
|
3234
3367
|
]
|
|
3235
3368
|
}
|
|
3236
|
-
) : /* @__PURE__ */ (0,
|
|
3237
|
-
/* @__PURE__ */ (0,
|
|
3238
|
-
/* @__PURE__ */ (0,
|
|
3239
|
-
/* @__PURE__ */ (0,
|
|
3240
|
-
address.isDefault ? /* @__PURE__ */ (0,
|
|
3369
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.el("addressesPanel.list", listBase), children: rows.map((address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.item", itemBase), children: [
|
|
3370
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
|
|
3371
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-row", children: [
|
|
3372
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("strong", { children: address.label || address.addressLine1 }),
|
|
3373
|
+
address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null
|
|
3241
3374
|
] }),
|
|
3242
|
-
/* @__PURE__ */ (0,
|
|
3243
|
-
/* @__PURE__ */ (0,
|
|
3375
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: address.addressLine1 }),
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: formatAddress(address) })
|
|
3244
3377
|
] }),
|
|
3245
|
-
/* @__PURE__ */ (0,
|
|
3246
|
-
!address.isDefault ? /* @__PURE__ */ (0,
|
|
3378
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
|
|
3379
|
+
!address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3247
3380
|
Button,
|
|
3248
3381
|
{
|
|
3249
3382
|
variant: actionVariant("secondary"),
|
|
@@ -3252,7 +3385,7 @@ function AddressesPanel(props) {
|
|
|
3252
3385
|
children: t.addresses.makeDefault
|
|
3253
3386
|
}
|
|
3254
3387
|
) : null,
|
|
3255
|
-
/* @__PURE__ */ (0,
|
|
3388
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3256
3389
|
Button,
|
|
3257
3390
|
{
|
|
3258
3391
|
variant: actionVariant("secondary"),
|
|
@@ -3261,14 +3394,14 @@ function AddressesPanel(props) {
|
|
|
3261
3394
|
children: t.common.edit
|
|
3262
3395
|
}
|
|
3263
3396
|
),
|
|
3264
|
-
/* @__PURE__ */ (0,
|
|
3397
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3265
3398
|
Button,
|
|
3266
3399
|
{
|
|
3267
3400
|
variant: actionVariant("danger"),
|
|
3268
3401
|
elementKey: "addressesPanel.deleteButton",
|
|
3269
3402
|
disabled: submitting,
|
|
3270
|
-
onClick: () => {
|
|
3271
|
-
if (!
|
|
3403
|
+
onClick: async () => {
|
|
3404
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
3272
3405
|
void run(() => resource.remove(address.id));
|
|
3273
3406
|
},
|
|
3274
3407
|
children: t.common.delete
|
|
@@ -3283,7 +3416,104 @@ function AddressesPanel(props) {
|
|
|
3283
3416
|
}
|
|
3284
3417
|
|
|
3285
3418
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3286
|
-
var
|
|
3419
|
+
var import_react26 = require("react");
|
|
3420
|
+
|
|
3421
|
+
// src/react/components/account/AddCardDialog.tsx
|
|
3422
|
+
var import_react25 = require("react");
|
|
3423
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3424
|
+
function AddCardDialog(props) {
|
|
3425
|
+
const { account } = useAuth();
|
|
3426
|
+
const titleId = (0, import_react25.useId)();
|
|
3427
|
+
const { t } = useCopy(props.localization);
|
|
3428
|
+
const [src, setSrc] = (0, import_react25.useState)(null);
|
|
3429
|
+
const [error, setError] = (0, import_react25.useState)(null);
|
|
3430
|
+
const [busy, setBusy] = (0, import_react25.useState)(false);
|
|
3431
|
+
const onAdded = (0, import_react25.useRef)(props.onAdded);
|
|
3432
|
+
const onClose = (0, import_react25.useRef)(props.onClose);
|
|
3433
|
+
onAdded.current = props.onAdded;
|
|
3434
|
+
onClose.current = props.onClose;
|
|
3435
|
+
(0, import_react25.useEffect)(() => {
|
|
3436
|
+
if (!props.open) {
|
|
3437
|
+
setSrc(null);
|
|
3438
|
+
setError(null);
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
let live = true;
|
|
3442
|
+
setError(null);
|
|
3443
|
+
account.startCardSetup().then(
|
|
3444
|
+
(session) => {
|
|
3445
|
+
if (!live) return;
|
|
3446
|
+
let url = session.embedUrl;
|
|
3447
|
+
try {
|
|
3448
|
+
const u = new URL(session.embedUrl, window.location.origin);
|
|
3449
|
+
u.searchParams.set("parentOrigin", window.location.origin);
|
|
3450
|
+
url = u.toString();
|
|
3451
|
+
} catch {
|
|
3452
|
+
}
|
|
3453
|
+
setSrc(url);
|
|
3454
|
+
},
|
|
3455
|
+
(err) => {
|
|
3456
|
+
if (live) setError(messageForError(err));
|
|
3457
|
+
}
|
|
3458
|
+
);
|
|
3459
|
+
return () => {
|
|
3460
|
+
live = false;
|
|
3461
|
+
};
|
|
3462
|
+
}, [props.open, account]);
|
|
3463
|
+
(0, import_react25.useEffect)(() => {
|
|
3464
|
+
if (!src) return;
|
|
3465
|
+
const frameOrigin = (() => {
|
|
3466
|
+
try {
|
|
3467
|
+
return new URL(src).origin;
|
|
3468
|
+
} catch {
|
|
3469
|
+
return null;
|
|
3470
|
+
}
|
|
3471
|
+
})();
|
|
3472
|
+
if (!frameOrigin) return;
|
|
3473
|
+
async function onMessage(event) {
|
|
3474
|
+
if (event.origin !== frameOrigin) return;
|
|
3475
|
+
const data = event.data;
|
|
3476
|
+
if (!data || typeof data.type !== "string") return;
|
|
3477
|
+
if (data.type === "throttle.completed" && data.paymentId) {
|
|
3478
|
+
setBusy(true);
|
|
3479
|
+
try {
|
|
3480
|
+
await account.confirmCardSetup(data.paymentId);
|
|
3481
|
+
onAdded.current();
|
|
3482
|
+
onClose.current();
|
|
3483
|
+
} catch (err) {
|
|
3484
|
+
setError(messageForError(err));
|
|
3485
|
+
} finally {
|
|
3486
|
+
setBusy(false);
|
|
3487
|
+
}
|
|
3488
|
+
} else if (data.type === "throttle.error") {
|
|
3489
|
+
setError(data.message || t.common.somethingWentWrong);
|
|
3490
|
+
} else if (data.type === "throttle.cancelled") {
|
|
3491
|
+
onClose.current();
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
window.addEventListener("message", onMessage);
|
|
3495
|
+
return () => window.removeEventListener("message", onMessage);
|
|
3496
|
+
}, [src, account, t]);
|
|
3497
|
+
if (!props.open) return null;
|
|
3498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
|
|
3499
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-modal__header", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h2", { id: titleId, className: "throttle-modal__title", children: t.paymentMethods.addTitle }) }),
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-modal__body", children: [
|
|
3501
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3502
|
+
busy ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : src ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3503
|
+
"iframe",
|
|
3504
|
+
{
|
|
3505
|
+
className: "throttle-cardframe",
|
|
3506
|
+
src,
|
|
3507
|
+
title: t.paymentMethods.addTitle,
|
|
3508
|
+
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
3509
|
+
}
|
|
3510
|
+
) : !error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : null
|
|
3511
|
+
] })
|
|
3512
|
+
] });
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
3516
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3287
3517
|
function PaymentMethodsPanel(props) {
|
|
3288
3518
|
const a = useAppearance(props.appearance);
|
|
3289
3519
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3291,6 +3521,8 @@ function PaymentMethodsPanel(props) {
|
|
|
3291
3521
|
const { emailVerified } = useAuth();
|
|
3292
3522
|
const resource = useSavedCards();
|
|
3293
3523
|
const { submitting, error, run } = useAction();
|
|
3524
|
+
const confirm = useConfirm();
|
|
3525
|
+
const [adding, setAdding] = (0, import_react26.useState)(false);
|
|
3294
3526
|
const variant = props.variant ?? "rows";
|
|
3295
3527
|
const rowsVariant = variant === "rows";
|
|
3296
3528
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -3298,9 +3530,21 @@ function PaymentMethodsPanel(props) {
|
|
|
3298
3530
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3299
3531
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
3300
3532
|
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,
|
|
3533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
|
|
3534
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
3535
|
+
emailVerified ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
|
|
3536
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3537
|
+
AddCardDialog,
|
|
3538
|
+
{
|
|
3539
|
+
open: adding,
|
|
3540
|
+
onClose: () => setAdding(false),
|
|
3541
|
+
onAdded: () => {
|
|
3542
|
+
void resource.refetch();
|
|
3543
|
+
},
|
|
3544
|
+
localization: props.localization
|
|
3545
|
+
}
|
|
3546
|
+
),
|
|
3547
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3304
3548
|
PanelState,
|
|
3305
3549
|
{
|
|
3306
3550
|
resource,
|
|
@@ -3309,7 +3553,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3309
3553
|
isEmpty: (rows) => rows.length === 0,
|
|
3310
3554
|
emptyTitle: t.paymentMethods.empty,
|
|
3311
3555
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
3312
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3556
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3313
3557
|
DataTable,
|
|
3314
3558
|
{
|
|
3315
3559
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -3319,9 +3563,9 @@ function PaymentMethodsPanel(props) {
|
|
|
3319
3563
|
columns: [
|
|
3320
3564
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
3321
3565
|
{ 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,
|
|
3566
|
+
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
|
|
3567
|
+
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
|
|
3568
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3325
3569
|
Button,
|
|
3326
3570
|
{
|
|
3327
3571
|
variant: "secondary",
|
|
@@ -3331,14 +3575,14 @@ function PaymentMethodsPanel(props) {
|
|
|
3331
3575
|
children: t.paymentMethods.makeDefault
|
|
3332
3576
|
}
|
|
3333
3577
|
) : null,
|
|
3334
|
-
/* @__PURE__ */ (0,
|
|
3578
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3335
3579
|
Button,
|
|
3336
3580
|
{
|
|
3337
3581
|
variant: "danger",
|
|
3338
3582
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
3339
3583
|
disabled: submitting,
|
|
3340
|
-
onClick: () => {
|
|
3341
|
-
if (!
|
|
3584
|
+
onClick: async () => {
|
|
3585
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
3342
3586
|
void run(() => resource.remove(card.id));
|
|
3343
3587
|
},
|
|
3344
3588
|
children: t.common.delete
|
|
@@ -3347,13 +3591,13 @@ function PaymentMethodsPanel(props) {
|
|
|
3347
3591
|
] }) }
|
|
3348
3592
|
]
|
|
3349
3593
|
}
|
|
3350
|
-
) : /* @__PURE__ */ (0,
|
|
3351
|
-
/* @__PURE__ */ (0,
|
|
3352
|
-
/* @__PURE__ */ (0,
|
|
3353
|
-
/* @__PURE__ */ (0,
|
|
3354
|
-
card.isDefault ? /* @__PURE__ */ (0,
|
|
3594
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
|
|
3595
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { children: [
|
|
3596
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-row", children: [
|
|
3597
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("strong", { children: cardLabel(card) }),
|
|
3598
|
+
card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
|
|
3355
3599
|
] }),
|
|
3356
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0,
|
|
3600
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "throttle-muted", children: [
|
|
3357
3601
|
t.paymentMethods.expires,
|
|
3358
3602
|
" ",
|
|
3359
3603
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -3361,8 +3605,8 @@ function PaymentMethodsPanel(props) {
|
|
|
3361
3605
|
card.cardExpYear
|
|
3362
3606
|
] }) : null
|
|
3363
3607
|
] }),
|
|
3364
|
-
/* @__PURE__ */ (0,
|
|
3365
|
-
!card.isDefault ? /* @__PURE__ */ (0,
|
|
3608
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
|
|
3609
|
+
!card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3366
3610
|
Button,
|
|
3367
3611
|
{
|
|
3368
3612
|
variant: actionVariant("secondary"),
|
|
@@ -3372,14 +3616,14 @@ function PaymentMethodsPanel(props) {
|
|
|
3372
3616
|
children: t.paymentMethods.makeDefault
|
|
3373
3617
|
}
|
|
3374
3618
|
) : null,
|
|
3375
|
-
/* @__PURE__ */ (0,
|
|
3619
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3376
3620
|
Button,
|
|
3377
3621
|
{
|
|
3378
3622
|
variant: actionVariant("danger"),
|
|
3379
3623
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
3380
3624
|
disabled: submitting,
|
|
3381
|
-
onClick: () => {
|
|
3382
|
-
if (!
|
|
3625
|
+
onClick: async () => {
|
|
3626
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
3383
3627
|
void run(() => resource.remove(card.id));
|
|
3384
3628
|
},
|
|
3385
3629
|
children: t.common.delete
|
|
@@ -3393,7 +3637,7 @@ function PaymentMethodsPanel(props) {
|
|
|
3393
3637
|
}
|
|
3394
3638
|
|
|
3395
3639
|
// src/react/components/account/OrdersPanel.tsx
|
|
3396
|
-
var
|
|
3640
|
+
var import_react27 = require("react");
|
|
3397
3641
|
|
|
3398
3642
|
// src/react/components/format.ts
|
|
3399
3643
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -3425,7 +3669,7 @@ function formatDate(value, locale) {
|
|
|
3425
3669
|
}
|
|
3426
3670
|
|
|
3427
3671
|
// src/react/components/account/OrderStatus.tsx
|
|
3428
|
-
var
|
|
3672
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3429
3673
|
function copyKey(wire) {
|
|
3430
3674
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
3431
3675
|
}
|
|
@@ -3433,25 +3677,76 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
3433
3677
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
3434
3678
|
function StatusBadge(props) {
|
|
3435
3679
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3436
|
-
return /* @__PURE__ */ (0,
|
|
3680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
3437
3681
|
}
|
|
3438
3682
|
function OrderStatus(props) {
|
|
3439
3683
|
const labels = props.t.orders.statusLabels;
|
|
3440
3684
|
const payLabels = props.t.orders.paymentLabels;
|
|
3441
3685
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
3442
3686
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
3443
|
-
return /* @__PURE__ */ (0,
|
|
3444
|
-
/* @__PURE__ */ (0,
|
|
3445
|
-
money ? /* @__PURE__ */ (0,
|
|
3687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
3688
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
|
|
3689
|
+
money ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
|
|
3690
|
+
] });
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
// src/react/components/account/AddressBlock.tsx
|
|
3694
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3695
|
+
function addressLines(address) {
|
|
3696
|
+
if (!address || typeof address !== "object") return [];
|
|
3697
|
+
const a = address;
|
|
3698
|
+
const str = (k) => typeof a[k] === "string" && a[k].trim() ? a[k].trim() : null;
|
|
3699
|
+
const name = [str("firstName"), str("lastName")].filter(Boolean).join(" ");
|
|
3700
|
+
const cityLine = [str("city"), str("stateProvince"), str("postalCode")].filter(Boolean).join(", ");
|
|
3701
|
+
return [
|
|
3702
|
+
name || null,
|
|
3703
|
+
str("company"),
|
|
3704
|
+
str("addressLine1") ?? str("line1"),
|
|
3705
|
+
str("addressLine2") ?? str("line2"),
|
|
3706
|
+
cityLine || null,
|
|
3707
|
+
str("countryCode") ?? str("country")
|
|
3708
|
+
].filter((l) => Boolean(l));
|
|
3709
|
+
}
|
|
3710
|
+
function AddressBlock(props) {
|
|
3711
|
+
const a = useAppearance();
|
|
3712
|
+
const lines = addressLines(props.address);
|
|
3713
|
+
if (lines.length === 0) return null;
|
|
3714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { ...a.el(props.elementKey ?? "orderDetail.address", "throttle-addressblock"), children: [
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3716
|
+
lines.map((l) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "throttle-addressblock__line throttle-muted", children: l }, l))
|
|
3717
|
+
] });
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
// src/react/components/account/OrderTimeline.tsx
|
|
3721
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3722
|
+
function orderTimeline(order, labels) {
|
|
3723
|
+
const entries = [{ label: labels.placed, at: order.createdAt }];
|
|
3724
|
+
if (order.completedAt) entries.push({ label: labels.completed, at: order.completedAt });
|
|
3725
|
+
if (order.cancelledAt) entries.push({ label: labels.cancelled, at: order.cancelledAt });
|
|
3726
|
+
if (order.closedAt) entries.push({ label: labels.closed, at: order.closedAt });
|
|
3727
|
+
return entries.sort((x, y) => new Date(x.at).getTime() - new Date(y.at).getTime());
|
|
3728
|
+
}
|
|
3729
|
+
function OrderTimeline(props) {
|
|
3730
|
+
const a = useAppearance();
|
|
3731
|
+
if (props.entries.length <= 1) return null;
|
|
3732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el("orderDetail.timeline", "throttle-timeline"), children: [
|
|
3733
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3734
|
+
props.entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "throttle-timeline__row", children: [
|
|
3735
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__dot", "aria-hidden": "true" }),
|
|
3736
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__label", children: e.label }),
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-muted", children: formatDate(e.at, props.locale) })
|
|
3738
|
+
] }, `${e.label}-${e.at}`))
|
|
3446
3739
|
] });
|
|
3447
3740
|
}
|
|
3448
3741
|
|
|
3449
3742
|
// src/react/components/account/OrderDetail.tsx
|
|
3450
|
-
var
|
|
3743
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3744
|
+
var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
|
|
3745
|
+
var CAN_REORDER = /* @__PURE__ */ new Set(["fulfilled", "cancelled", "closed"]);
|
|
3451
3746
|
function Line(props) {
|
|
3452
|
-
return /* @__PURE__ */ (0,
|
|
3453
|
-
/* @__PURE__ */ (0,
|
|
3454
|
-
/* @__PURE__ */ (0,
|
|
3747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
|
|
3748
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
3749
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: props.value })
|
|
3455
3750
|
] });
|
|
3456
3751
|
}
|
|
3457
3752
|
function OrderDetail(props) {
|
|
@@ -3459,7 +3754,7 @@ function OrderDetail(props) {
|
|
|
3459
3754
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3460
3755
|
const { t, locale } = useCopy(props.localization);
|
|
3461
3756
|
const resource = useOrder(props.orderId);
|
|
3462
|
-
return /* @__PURE__ */ (0,
|
|
3757
|
+
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.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
|
|
3463
3758
|
props.onBack ? (
|
|
3464
3759
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3465
3760
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3467,27 +3762,27 @@ function OrderDetail(props) {
|
|
|
3467
3762
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3468
3763
|
// its own width. A CSS fix would need a compound selector, and
|
|
3469
3764
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3470
|
-
/* @__PURE__ */ (0,
|
|
3765
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3471
3766
|
) : null,
|
|
3472
|
-
/* @__PURE__ */ (0,
|
|
3767
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3473
3768
|
PanelState,
|
|
3474
3769
|
{
|
|
3475
3770
|
resource,
|
|
3476
3771
|
isEmpty: (o) => o === null,
|
|
3477
3772
|
emptyTitle: t.orders.empty,
|
|
3478
3773
|
skeletonRows: 5,
|
|
3479
|
-
children: (order) => /* @__PURE__ */ (0,
|
|
3480
|
-
/* @__PURE__ */ (0,
|
|
3481
|
-
/* @__PURE__ */ (0,
|
|
3482
|
-
/* @__PURE__ */ (0,
|
|
3774
|
+
children: (order) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
3775
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
|
|
3776
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { children: order.orderNumber }),
|
|
3777
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
|
|
3483
3778
|
] }),
|
|
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,
|
|
3779
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
|
|
3780
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
|
|
3781
|
+
item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
|
|
3782
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { style: { flex: 1 }, children: [
|
|
3783
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: item.name }),
|
|
3784
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: item.description }) : null,
|
|
3785
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "throttle-muted", children: [
|
|
3491
3786
|
t.orders.quantity,
|
|
3492
3787
|
" ",
|
|
3493
3788
|
item.quantity,
|
|
@@ -3495,16 +3790,87 @@ function OrderDetail(props) {
|
|
|
3495
3790
|
formatMoney(item.unitPrice, order.currency, locale)
|
|
3496
3791
|
] })
|
|
3497
3792
|
] }),
|
|
3498
|
-
/* @__PURE__ */ (0,
|
|
3793
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: formatMoney(item.total, order.currency, locale) })
|
|
3499
3794
|
] }, item.id)) }),
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
3501
|
-
/* @__PURE__ */ (0,
|
|
3502
|
-
order.discountTotal ? /* @__PURE__ */ (0,
|
|
3503
|
-
/* @__PURE__ */ (0,
|
|
3504
|
-
/* @__PURE__ */ (0,
|
|
3505
|
-
/* @__PURE__ */ (0,
|
|
3795
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
|
|
3796
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
|
|
3797
|
+
order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
|
|
3798
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
|
|
3800
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
|
|
3801
|
+
] }),
|
|
3802
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
|
|
3803
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3804
|
+
AddressBlock,
|
|
3805
|
+
{
|
|
3806
|
+
heading: t.orders.shipTo,
|
|
3807
|
+
address: order.shippingAddress,
|
|
3808
|
+
elementKey: "orderDetail.shippingAddress"
|
|
3809
|
+
}
|
|
3810
|
+
),
|
|
3811
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3812
|
+
AddressBlock,
|
|
3813
|
+
{
|
|
3814
|
+
heading: t.orders.billTo,
|
|
3815
|
+
address: order.billingAddress,
|
|
3816
|
+
elementKey: "orderDetail.billingAddress"
|
|
3817
|
+
}
|
|
3818
|
+
)
|
|
3506
3819
|
] }),
|
|
3507
|
-
|
|
3820
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3821
|
+
OrderTimeline,
|
|
3822
|
+
{
|
|
3823
|
+
heading: t.orders.history,
|
|
3824
|
+
locale,
|
|
3825
|
+
entries: orderTimeline(order, {
|
|
3826
|
+
placed: t.orders.placed,
|
|
3827
|
+
completed: t.orders.completed,
|
|
3828
|
+
cancelled: t.orders.cancelledAt,
|
|
3829
|
+
closed: t.orders.closedAt
|
|
3830
|
+
})
|
|
3831
|
+
}
|
|
3832
|
+
),
|
|
3833
|
+
(() => {
|
|
3834
|
+
const target = {
|
|
3835
|
+
id: order.id,
|
|
3836
|
+
orderNumber: order.orderNumber,
|
|
3837
|
+
currency: order.currency,
|
|
3838
|
+
lineItems: order.lineItems.map((li) => ({
|
|
3839
|
+
name: li.name,
|
|
3840
|
+
unitPrice: li.unitPrice,
|
|
3841
|
+
quantity: li.quantity
|
|
3842
|
+
}))
|
|
3843
|
+
};
|
|
3844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-actions", children: [
|
|
3845
|
+
props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3846
|
+
Button,
|
|
3847
|
+
{
|
|
3848
|
+
elementKey: "orderDetail.payButton",
|
|
3849
|
+
onClick: () => props.onPayNow(target),
|
|
3850
|
+
children: t.orders.payNow
|
|
3851
|
+
}
|
|
3852
|
+
) : null,
|
|
3853
|
+
props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3854
|
+
Button,
|
|
3855
|
+
{
|
|
3856
|
+
variant: "secondary",
|
|
3857
|
+
elementKey: "orderDetail.trackButton",
|
|
3858
|
+
onClick: () => props.onTrackShipment(target),
|
|
3859
|
+
children: t.orders.track
|
|
3860
|
+
}
|
|
3861
|
+
) : null,
|
|
3862
|
+
props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3863
|
+
Button,
|
|
3864
|
+
{
|
|
3865
|
+
variant: "secondary",
|
|
3866
|
+
elementKey: "orderDetail.reorderButton",
|
|
3867
|
+
onClick: () => props.onReorder(target),
|
|
3868
|
+
children: t.orders.reorder
|
|
3869
|
+
}
|
|
3870
|
+
) : null,
|
|
3871
|
+
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
|
|
3872
|
+
] });
|
|
3873
|
+
})()
|
|
3508
3874
|
] })
|
|
3509
3875
|
}
|
|
3510
3876
|
)
|
|
@@ -3512,31 +3878,34 @@ function OrderDetail(props) {
|
|
|
3512
3878
|
}
|
|
3513
3879
|
|
|
3514
3880
|
// src/react/components/account/OrdersPanel.tsx
|
|
3515
|
-
var
|
|
3881
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3516
3882
|
function OrdersPanel(props) {
|
|
3517
3883
|
const a = useAppearance(props.appearance);
|
|
3518
3884
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3519
3885
|
const { t, locale } = useCopy(props.localization);
|
|
3520
3886
|
const { emailVerified } = useAuth();
|
|
3521
3887
|
const resource = useOrders();
|
|
3522
|
-
const [openId, setOpenId] = (0,
|
|
3888
|
+
const [openId, setOpenId] = (0, import_react27.useState)(null);
|
|
3523
3889
|
const variant = props.variant ?? "table";
|
|
3524
3890
|
const rowsVariant = variant === "rows";
|
|
3525
3891
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3526
3892
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3527
3893
|
if (openId) {
|
|
3528
|
-
return /* @__PURE__ */ (0,
|
|
3894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3529
3895
|
OrderDetail,
|
|
3530
3896
|
{
|
|
3531
3897
|
orderId: openId,
|
|
3532
3898
|
onBack: () => setOpenId(null),
|
|
3899
|
+
onPayNow: props.onPayNow,
|
|
3900
|
+
onReorder: props.onReorder,
|
|
3901
|
+
onTrackShipment: props.onTrackShipment,
|
|
3533
3902
|
onViewSubscription: props.onViewSubscription,
|
|
3534
3903
|
appearance: props.appearance,
|
|
3535
3904
|
localization: props.localization
|
|
3536
3905
|
}
|
|
3537
3906
|
);
|
|
3538
3907
|
}
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
3908
|
+
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.jsx)("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3540
3909
|
PanelState,
|
|
3541
3910
|
{
|
|
3542
3911
|
resource,
|
|
@@ -3545,7 +3914,7 @@ function OrdersPanel(props) {
|
|
|
3545
3914
|
isEmpty: (rows) => rows.length === 0,
|
|
3546
3915
|
emptyTitle: t.orders.empty,
|
|
3547
3916
|
emptyDescription: t.orders.emptyDescription,
|
|
3548
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
3917
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3549
3918
|
DataTable,
|
|
3550
3919
|
{
|
|
3551
3920
|
tableKey: "ordersPanel.table",
|
|
@@ -3559,25 +3928,25 @@ function OrdersPanel(props) {
|
|
|
3559
3928
|
{
|
|
3560
3929
|
key: "status",
|
|
3561
3930
|
label: t.orders.status,
|
|
3562
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
3931
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3563
3932
|
},
|
|
3564
3933
|
{
|
|
3565
3934
|
key: "total",
|
|
3566
3935
|
label: t.orders.total,
|
|
3567
|
-
render: (o) => /* @__PURE__ */ (0,
|
|
3936
|
+
render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
3568
3937
|
}
|
|
3569
3938
|
]
|
|
3570
3939
|
}
|
|
3571
|
-
) : /* @__PURE__ */ (0,
|
|
3572
|
-
/* @__PURE__ */ (0,
|
|
3573
|
-
/* @__PURE__ */ (0,
|
|
3574
|
-
/* @__PURE__ */ (0,
|
|
3575
|
-
/* @__PURE__ */ (0,
|
|
3940
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("ordersPanel.item", itemBase), children: [
|
|
3941
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
|
|
3942
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
|
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("strong", { children: o.orderNumber }),
|
|
3944
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3576
3945
|
] }),
|
|
3577
|
-
/* @__PURE__ */ (0,
|
|
3578
|
-
/* @__PURE__ */ (0,
|
|
3946
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
|
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
|
|
3579
3948
|
] }),
|
|
3580
|
-
/* @__PURE__ */ (0,
|
|
3949
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3581
3950
|
Button,
|
|
3582
3951
|
{
|
|
3583
3952
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3592,14 +3961,14 @@ function OrdersPanel(props) {
|
|
|
3592
3961
|
}
|
|
3593
3962
|
|
|
3594
3963
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3595
|
-
var
|
|
3964
|
+
var import_react28 = require("react");
|
|
3596
3965
|
|
|
3597
3966
|
// src/react/components/account/InvoiceDetail.tsx
|
|
3598
|
-
var
|
|
3967
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3599
3968
|
function Line2(props) {
|
|
3600
|
-
return /* @__PURE__ */ (0,
|
|
3601
|
-
/* @__PURE__ */ (0,
|
|
3602
|
-
/* @__PURE__ */ (0,
|
|
3969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
3970
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-muted", children: props.label }),
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: props.value })
|
|
3603
3972
|
] });
|
|
3604
3973
|
}
|
|
3605
3974
|
function InvoiceDetail(props) {
|
|
@@ -3609,7 +3978,7 @@ function InvoiceDetail(props) {
|
|
|
3609
3978
|
const { account } = useAuth();
|
|
3610
3979
|
const resource = useInvoice(props.invoiceId);
|
|
3611
3980
|
const { submitting, error, run } = useAction();
|
|
3612
|
-
return /* @__PURE__ */ (0,
|
|
3981
|
+
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("invoiceDetail.root", "throttle-panel"), children: [
|
|
3613
3982
|
props.onBack ? (
|
|
3614
3983
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3615
3984
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3617,25 +3986,25 @@ function InvoiceDetail(props) {
|
|
|
3617
3986
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3618
3987
|
// its own width. A CSS fix would need a compound selector, and
|
|
3619
3988
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3620
|
-
/* @__PURE__ */ (0,
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3621
3990
|
) : null,
|
|
3622
|
-
/* @__PURE__ */ (0,
|
|
3623
|
-
/* @__PURE__ */ (0,
|
|
3624
|
-
/* @__PURE__ */ (0,
|
|
3625
|
-
/* @__PURE__ */ (0,
|
|
3991
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
3992
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
|
|
3993
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: invoice.number }),
|
|
3994
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
|
|
3626
3995
|
] }),
|
|
3627
|
-
/* @__PURE__ */ (0,
|
|
3628
|
-
/* @__PURE__ */ (0,
|
|
3629
|
-
invoice.dueAt ? /* @__PURE__ */ (0,
|
|
3630
|
-
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0,
|
|
3996
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
|
|
3997
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
|
|
3998
|
+
invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
|
|
3999
|
+
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3631
4000
|
Line2,
|
|
3632
4001
|
{
|
|
3633
4002
|
label: t.invoices.period,
|
|
3634
4003
|
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
3635
4004
|
}
|
|
3636
4005
|
) : null,
|
|
3637
|
-
/* @__PURE__ */ (0,
|
|
3638
|
-
invoice.amountRefunded ? /* @__PURE__ */ (0,
|
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
|
|
4007
|
+
invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3639
4008
|
Line2,
|
|
3640
4009
|
{
|
|
3641
4010
|
label: t.invoices.refunded,
|
|
@@ -3643,8 +4012,8 @@ function InvoiceDetail(props) {
|
|
|
3643
4012
|
}
|
|
3644
4013
|
) : null
|
|
3645
4014
|
] }),
|
|
3646
|
-
error ? /* @__PURE__ */ (0,
|
|
3647
|
-
/* @__PURE__ */ (0,
|
|
4015
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
4016
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3648
4017
|
Button,
|
|
3649
4018
|
{
|
|
3650
4019
|
variant: "secondary",
|
|
@@ -3663,20 +4032,20 @@ function InvoiceDetail(props) {
|
|
|
3663
4032
|
}
|
|
3664
4033
|
|
|
3665
4034
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3666
|
-
var
|
|
4035
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3667
4036
|
function InvoicesPanel(props) {
|
|
3668
4037
|
const a = useAppearance(props.appearance);
|
|
3669
4038
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3670
4039
|
const { t, locale } = useCopy(props.localization);
|
|
3671
4040
|
const { emailVerified } = useAuth();
|
|
3672
4041
|
const resource = useInvoices();
|
|
3673
|
-
const [openId, setOpenId] = (0,
|
|
4042
|
+
const [openId, setOpenId] = (0, import_react28.useState)(null);
|
|
3674
4043
|
const variant = props.variant ?? "table";
|
|
3675
4044
|
const rowsVariant = variant === "rows";
|
|
3676
4045
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3677
4046
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3678
4047
|
if (openId) {
|
|
3679
|
-
return /* @__PURE__ */ (0,
|
|
4048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3680
4049
|
InvoiceDetail,
|
|
3681
4050
|
{
|
|
3682
4051
|
invoiceId: openId,
|
|
@@ -3686,7 +4055,7 @@ function InvoicesPanel(props) {
|
|
|
3686
4055
|
}
|
|
3687
4056
|
);
|
|
3688
4057
|
}
|
|
3689
|
-
return /* @__PURE__ */ (0,
|
|
4058
|
+
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.jsx)("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3690
4059
|
PanelState,
|
|
3691
4060
|
{
|
|
3692
4061
|
resource,
|
|
@@ -3695,7 +4064,7 @@ function InvoicesPanel(props) {
|
|
|
3695
4064
|
isEmpty: (rows) => rows.length === 0,
|
|
3696
4065
|
emptyTitle: t.invoices.empty,
|
|
3697
4066
|
emptyDescription: t.invoices.emptyDescription,
|
|
3698
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
4067
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3699
4068
|
DataTable,
|
|
3700
4069
|
{
|
|
3701
4070
|
tableKey: "invoicesPanel.table",
|
|
@@ -3706,24 +4075,24 @@ function InvoicesPanel(props) {
|
|
|
3706
4075
|
columns: [
|
|
3707
4076
|
{ key: "number", label: t.invoices.number },
|
|
3708
4077
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
3709
|
-
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0,
|
|
4078
|
+
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
|
|
3710
4079
|
{
|
|
3711
4080
|
key: "total",
|
|
3712
4081
|
label: t.invoices.total,
|
|
3713
|
-
render: (i) => /* @__PURE__ */ (0,
|
|
4082
|
+
render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
3714
4083
|
}
|
|
3715
4084
|
]
|
|
3716
4085
|
}
|
|
3717
|
-
) : /* @__PURE__ */ (0,
|
|
3718
|
-
/* @__PURE__ */ (0,
|
|
3719
|
-
/* @__PURE__ */ (0,
|
|
3720
|
-
/* @__PURE__ */ (0,
|
|
3721
|
-
/* @__PURE__ */ (0,
|
|
4086
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("invoicesPanel.item", itemBase), children: [
|
|
4087
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { children: [
|
|
4088
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-row", children: [
|
|
4089
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: i.number }),
|
|
4090
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
|
|
3722
4091
|
] }),
|
|
3723
|
-
/* @__PURE__ */ (0,
|
|
3724
|
-
/* @__PURE__ */ (0,
|
|
4092
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
|
|
4093
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
|
|
3725
4094
|
] }),
|
|
3726
|
-
/* @__PURE__ */ (0,
|
|
4095
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3727
4096
|
Button,
|
|
3728
4097
|
{
|
|
3729
4098
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3738,7 +4107,7 @@ function InvoicesPanel(props) {
|
|
|
3738
4107
|
}
|
|
3739
4108
|
|
|
3740
4109
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3741
|
-
var
|
|
4110
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3742
4111
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
3743
4112
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
3744
4113
|
var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
@@ -3749,62 +4118,79 @@ function SubscriptionsPanel(props) {
|
|
|
3749
4118
|
const { emailVerified } = useAuth();
|
|
3750
4119
|
const resource = useSubscriptions();
|
|
3751
4120
|
const { submitting, error, run } = useAction();
|
|
4121
|
+
const confirm = useConfirm();
|
|
3752
4122
|
const variant = props.variant ?? "rows";
|
|
3753
4123
|
const rowsVariant = variant === "rows";
|
|
3754
4124
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3755
4125
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3756
4126
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3757
|
-
const confirmThen = (fn) => () => {
|
|
3758
|
-
|
|
3759
|
-
|
|
4127
|
+
const confirmThen = (fn, ask) => () => {
|
|
4128
|
+
void (async () => {
|
|
4129
|
+
if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
|
|
4130
|
+
await run(fn);
|
|
4131
|
+
})();
|
|
3760
4132
|
};
|
|
3761
4133
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3762
4134
|
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,
|
|
4135
|
+
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-actions", children: [
|
|
4136
|
+
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3765
4137
|
Button,
|
|
3766
4138
|
{
|
|
3767
4139
|
variant: variantFor("secondary"),
|
|
3768
4140
|
loading: submitting,
|
|
3769
4141
|
elementKey: "subscriptionsPanel.pauseButton",
|
|
3770
|
-
onClick: (
|
|
4142
|
+
onClick: confirmThen(() => resource.pause(sub.id), {
|
|
4143
|
+
title: t.subscriptions.pauseConfirm,
|
|
4144
|
+
confirmLabel: t.subscriptions.pauseButton
|
|
4145
|
+
}),
|
|
3771
4146
|
children: t.subscriptions.pauseButton
|
|
3772
4147
|
}
|
|
3773
4148
|
) : null,
|
|
3774
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0,
|
|
4149
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3775
4150
|
Button,
|
|
3776
4151
|
{
|
|
3777
4152
|
variant: variantFor("secondary"),
|
|
3778
4153
|
loading: submitting,
|
|
3779
4154
|
elementKey: "subscriptionsPanel.resumeButton",
|
|
3780
|
-
onClick: (
|
|
4155
|
+
onClick: confirmThen(() => resource.resume(sub.id), {
|
|
4156
|
+
title: t.subscriptions.resumeConfirm,
|
|
4157
|
+
confirmLabel: t.subscriptions.resumeButton
|
|
4158
|
+
}),
|
|
3781
4159
|
children: t.subscriptions.resumeButton
|
|
3782
4160
|
}
|
|
3783
4161
|
) : null,
|
|
3784
|
-
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
4162
|
+
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3785
4163
|
Button,
|
|
3786
4164
|
{
|
|
3787
4165
|
variant: variantFor("secondary"),
|
|
3788
4166
|
elementKey: "subscriptionsPanel.cancelButton",
|
|
3789
4167
|
disabled: submitting,
|
|
3790
|
-
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: true })
|
|
4168
|
+
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: true }), {
|
|
4169
|
+
title: t.subscriptions.cancelConfirm,
|
|
4170
|
+
confirmLabel: t.subscriptions.cancelConfirmAction,
|
|
4171
|
+
tone: "danger"
|
|
4172
|
+
}),
|
|
3791
4173
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
3792
4174
|
}
|
|
3793
4175
|
) : null,
|
|
3794
|
-
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0,
|
|
4176
|
+
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3795
4177
|
Button,
|
|
3796
4178
|
{
|
|
3797
4179
|
variant: variantFor("danger"),
|
|
3798
4180
|
elementKey: "subscriptionsPanel.cancelNowButton",
|
|
3799
4181
|
disabled: submitting,
|
|
3800
|
-
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: false })
|
|
4182
|
+
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: false }), {
|
|
4183
|
+
title: t.subscriptions.cancelNowConfirm,
|
|
4184
|
+
confirmLabel: t.subscriptions.cancelConfirmAction,
|
|
4185
|
+
tone: "danger"
|
|
4186
|
+
}),
|
|
3801
4187
|
children: t.subscriptions.cancelNow
|
|
3802
4188
|
}
|
|
3803
4189
|
) : null
|
|
3804
4190
|
] });
|
|
3805
|
-
return /* @__PURE__ */ (0,
|
|
3806
|
-
error ? /* @__PURE__ */ (0,
|
|
3807
|
-
/* @__PURE__ */ (0,
|
|
4191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
|
|
4192
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Alert, { tone: "error", children: error }) : null,
|
|
4193
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3808
4194
|
PanelState,
|
|
3809
4195
|
{
|
|
3810
4196
|
resource,
|
|
@@ -3813,7 +4199,7 @@ function SubscriptionsPanel(props) {
|
|
|
3813
4199
|
isEmpty: (rows) => rows.length === 0,
|
|
3814
4200
|
emptyTitle: t.subscriptions.empty,
|
|
3815
4201
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
3816
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */ (0,
|
|
4202
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3817
4203
|
DataTable,
|
|
3818
4204
|
{
|
|
3819
4205
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -3822,42 +4208,42 @@ function SubscriptionsPanel(props) {
|
|
|
3822
4208
|
rows,
|
|
3823
4209
|
columns: [
|
|
3824
4210
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
3825
|
-
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0,
|
|
4211
|
+
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
3826
4212
|
{ 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,
|
|
4213
|
+
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
|
|
4214
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
|
|
4215
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3830
4216
|
] }) },
|
|
3831
4217
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
3832
4218
|
]
|
|
3833
4219
|
}
|
|
3834
|
-
) : /* @__PURE__ */ (0,
|
|
3835
|
-
/* @__PURE__ */ (0,
|
|
3836
|
-
/* @__PURE__ */ (0,
|
|
3837
|
-
/* @__PURE__ */ (0,
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
4220
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
|
|
4221
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
4222
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
|
|
4223
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("strong", { children: sub.planName ?? sub.planReference }),
|
|
4224
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
3839
4225
|
] }),
|
|
3840
|
-
/* @__PURE__ */ (0,
|
|
4226
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
3841
4227
|
formatMoney(sub.amount, sub.currency, locale),
|
|
3842
4228
|
" / ",
|
|
3843
4229
|
sub.interval,
|
|
3844
4230
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3845
4231
|
] }),
|
|
3846
|
-
sub.status === "cancelled" ? /* @__PURE__ */ (0,
|
|
4232
|
+
sub.status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
3847
4233
|
t.subscriptions.cancelledOn,
|
|
3848
4234
|
" ",
|
|
3849
4235
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
3850
|
-
] }) : /* @__PURE__ */ (0,
|
|
4236
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
3851
4237
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
3852
4238
|
" ",
|
|
3853
4239
|
formatDate(sub.currentPeriodEnd, locale)
|
|
3854
4240
|
] }),
|
|
3855
|
-
sub.trialEnd ? /* @__PURE__ */ (0,
|
|
4241
|
+
sub.trialEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
|
|
3856
4242
|
t.subscriptions.trialEnds,
|
|
3857
4243
|
" ",
|
|
3858
4244
|
formatDate(sub.trialEnd, locale)
|
|
3859
4245
|
] }) : null,
|
|
3860
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0,
|
|
4246
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3861
4247
|
] }),
|
|
3862
4248
|
lifecycleActions(sub, actionVariant)
|
|
3863
4249
|
] }, sub.id)) })
|
|
@@ -3867,7 +4253,7 @@ function SubscriptionsPanel(props) {
|
|
|
3867
4253
|
}
|
|
3868
4254
|
|
|
3869
4255
|
// src/react/components/account/SecurityPanel.tsx
|
|
3870
|
-
var
|
|
4256
|
+
var import_react29 = require("react");
|
|
3871
4257
|
|
|
3872
4258
|
// src/react/components/account/device.ts
|
|
3873
4259
|
var BROWSERS = [
|
|
@@ -3900,7 +4286,7 @@ function describeDevice(userAgent) {
|
|
|
3900
4286
|
}
|
|
3901
4287
|
|
|
3902
4288
|
// src/react/components/account/SecurityPanel.tsx
|
|
3903
|
-
var
|
|
4289
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3904
4290
|
function SecurityPanel(props) {
|
|
3905
4291
|
const a = useAppearance(props.appearance);
|
|
3906
4292
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3910,16 +4296,16 @@ function SecurityPanel(props) {
|
|
|
3910
4296
|
const rowsVariant = variant === "rows";
|
|
3911
4297
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3912
4298
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
3913
|
-
const [password, setPassword] = (0,
|
|
4299
|
+
const [password, setPassword] = (0, import_react29.useState)("");
|
|
3914
4300
|
const passwordAction = useAction();
|
|
3915
4301
|
const sessionAction = useAction();
|
|
3916
|
-
const [sessions, setSessions] = (0,
|
|
3917
|
-
const [listError, setListError] = (0,
|
|
3918
|
-
const errorMessageRef = (0,
|
|
3919
|
-
(0,
|
|
4302
|
+
const [sessions, setSessions] = (0, import_react29.useState)(null);
|
|
4303
|
+
const [listError, setListError] = (0, import_react29.useState)(null);
|
|
4304
|
+
const errorMessageRef = (0, import_react29.useRef)(errorMessage);
|
|
4305
|
+
(0, import_react29.useEffect)(() => {
|
|
3920
4306
|
errorMessageRef.current = errorMessage;
|
|
3921
4307
|
});
|
|
3922
|
-
const load = (0,
|
|
4308
|
+
const load = (0, import_react29.useCallback)(async () => {
|
|
3923
4309
|
try {
|
|
3924
4310
|
setSessions(await auth.listSessions());
|
|
3925
4311
|
setListError(null);
|
|
@@ -3927,12 +4313,12 @@ function SecurityPanel(props) {
|
|
|
3927
4313
|
setListError(errorMessageRef.current(err));
|
|
3928
4314
|
}
|
|
3929
4315
|
}, [auth]);
|
|
3930
|
-
(0,
|
|
4316
|
+
(0, import_react29.useEffect)(() => {
|
|
3931
4317
|
void load();
|
|
3932
4318
|
}, [load]);
|
|
3933
4319
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
3934
|
-
return /* @__PURE__ */ (0,
|
|
3935
|
-
/* @__PURE__ */ (0,
|
|
4320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
|
|
4321
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
3936
4322
|
"form",
|
|
3937
4323
|
{
|
|
3938
4324
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -3945,8 +4331,8 @@ function SecurityPanel(props) {
|
|
|
3945
4331
|
});
|
|
3946
4332
|
},
|
|
3947
4333
|
children: [
|
|
3948
|
-
/* @__PURE__ */ (0,
|
|
3949
|
-
/* @__PURE__ */ (0,
|
|
4334
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.passwordTitle }),
|
|
4335
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3950
4336
|
Field,
|
|
3951
4337
|
{
|
|
3952
4338
|
label: t.security.newPassword,
|
|
@@ -3957,21 +4343,21 @@ function SecurityPanel(props) {
|
|
|
3957
4343
|
onChange: setPassword
|
|
3958
4344
|
}
|
|
3959
4345
|
),
|
|
3960
|
-
passwordAction.error ? /* @__PURE__ */ (0,
|
|
3961
|
-
passwordAction.notice ? /* @__PURE__ */ (0,
|
|
3962
|
-
/* @__PURE__ */ (0,
|
|
4346
|
+
passwordAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: passwordAction.error }) : null,
|
|
4347
|
+
passwordAction.notice ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "success", children: passwordAction.notice }) : null,
|
|
4348
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
|
|
3963
4349
|
]
|
|
3964
4350
|
}
|
|
3965
4351
|
),
|
|
3966
|
-
/* @__PURE__ */ (0,
|
|
3967
|
-
/* @__PURE__ */ (0,
|
|
3968
|
-
listError ? /* @__PURE__ */ (0,
|
|
3969
|
-
/* @__PURE__ */ (0,
|
|
3970
|
-
/* @__PURE__ */ (0,
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.sessionsTitle }),
|
|
4354
|
+
listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
4355
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: listError }),
|
|
4356
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
|
|
3971
4357
|
] }) : null,
|
|
3972
|
-
sessionAction.error ? /* @__PURE__ */ (0,
|
|
3973
|
-
sessions === null && !listError ? /* @__PURE__ */ (0,
|
|
3974
|
-
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0,
|
|
4358
|
+
sessionAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: sessionAction.error }) : null,
|
|
4359
|
+
sessions === null && !listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Skeleton, { count: 2 }) : null,
|
|
4360
|
+
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3975
4361
|
DataTable,
|
|
3976
4362
|
{
|
|
3977
4363
|
tableKey: "securityPanel.table",
|
|
@@ -3979,12 +4365,12 @@ function SecurityPanel(props) {
|
|
|
3979
4365
|
rowKey: (session) => session.id,
|
|
3980
4366
|
rows: sessions,
|
|
3981
4367
|
columns: [
|
|
3982
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0,
|
|
3983
|
-
/* @__PURE__ */ (0,
|
|
3984
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4368
|
+
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
|
|
4369
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4370
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3985
4371
|
] }) },
|
|
3986
4372
|
{ 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,
|
|
4373
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3988
4374
|
Button,
|
|
3989
4375
|
{
|
|
3990
4376
|
variant: "danger",
|
|
@@ -3999,19 +4385,19 @@ function SecurityPanel(props) {
|
|
|
3999
4385
|
) : null }
|
|
4000
4386
|
]
|
|
4001
4387
|
}
|
|
4002
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0,
|
|
4003
|
-
/* @__PURE__ */ (0,
|
|
4004
|
-
/* @__PURE__ */ (0,
|
|
4005
|
-
/* @__PURE__ */ (0,
|
|
4006
|
-
session.current ? /* @__PURE__ */ (0,
|
|
4388
|
+
) : (sessions ?? []).map((session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
|
|
4389
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { children: [
|
|
4390
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
|
|
4391
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
4392
|
+
session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
4007
4393
|
] }),
|
|
4008
|
-
/* @__PURE__ */ (0,
|
|
4394
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
|
|
4009
4395
|
t.security.lastActive,
|
|
4010
4396
|
" ",
|
|
4011
4397
|
formatDate(session.lastUsedAt, locale)
|
|
4012
4398
|
] })
|
|
4013
4399
|
] }),
|
|
4014
|
-
!session.current ? /* @__PURE__ */ (0,
|
|
4400
|
+
!session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4015
4401
|
Button,
|
|
4016
4402
|
{
|
|
4017
4403
|
variant: revokeVariant,
|
|
@@ -4025,8 +4411,8 @@ function SecurityPanel(props) {
|
|
|
4025
4411
|
}
|
|
4026
4412
|
) : null
|
|
4027
4413
|
] }, session.id)),
|
|
4028
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0,
|
|
4029
|
-
others.length > 0 ? /* @__PURE__ */ (0,
|
|
4414
|
+
sessions !== null && others.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
|
|
4415
|
+
others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
4030
4416
|
Button,
|
|
4031
4417
|
{
|
|
4032
4418
|
variant: "danger",
|
|
@@ -4046,7 +4432,7 @@ function SecurityPanel(props) {
|
|
|
4046
4432
|
}
|
|
4047
4433
|
|
|
4048
4434
|
// src/react/components/account/AccountDashboard.tsx
|
|
4049
|
-
var
|
|
4435
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4050
4436
|
var ACCOUNT_TABS = [
|
|
4051
4437
|
"profile",
|
|
4052
4438
|
"addresses",
|
|
@@ -4075,9 +4461,9 @@ function AccountDashboard(props) {
|
|
|
4075
4461
|
const { status } = useAuth();
|
|
4076
4462
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
4077
4463
|
const controlled = props.tab !== void 0;
|
|
4078
|
-
const [internal, setInternal] = (0,
|
|
4079
|
-
const idBase = (0,
|
|
4080
|
-
(0,
|
|
4464
|
+
const [internal, setInternal] = (0, import_react30.useState)(shown[0] ?? "profile");
|
|
4465
|
+
const idBase = (0, import_react30.useId)();
|
|
4466
|
+
(0, import_react30.useEffect)(() => {
|
|
4081
4467
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
4082
4468
|
const apply = () => {
|
|
4083
4469
|
const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
|
|
@@ -4098,7 +4484,7 @@ function AccountDashboard(props) {
|
|
|
4098
4484
|
};
|
|
4099
4485
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
4100
4486
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
4101
|
-
const nav = /* @__PURE__ */ (0,
|
|
4487
|
+
const nav = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4102
4488
|
Tabs,
|
|
4103
4489
|
{
|
|
4104
4490
|
idBase,
|
|
@@ -4114,7 +4500,7 @@ function AccountDashboard(props) {
|
|
|
4114
4500
|
}))
|
|
4115
4501
|
}
|
|
4116
4502
|
);
|
|
4117
|
-
const panel = /* @__PURE__ */ (0,
|
|
4503
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
4118
4504
|
"div",
|
|
4119
4505
|
{
|
|
4120
4506
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -4123,36 +4509,46 @@ function AccountDashboard(props) {
|
|
|
4123
4509
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
4124
4510
|
tabIndex: 0,
|
|
4125
4511
|
children: [
|
|
4126
|
-
active === "profile" ? /* @__PURE__ */ (0,
|
|
4127
|
-
active === "addresses" ? /* @__PURE__ */ (0,
|
|
4128
|
-
active === "paymentMethods" ? /* @__PURE__ */ (0,
|
|
4129
|
-
active === "orders" ? /* @__PURE__ */ (0,
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4512
|
+
active === "profile" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ProfilePanel, { ...shared }) : null,
|
|
4513
|
+
active === "addresses" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4514
|
+
active === "paymentMethods" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4515
|
+
active === "orders" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4516
|
+
OrdersPanel,
|
|
4517
|
+
{
|
|
4518
|
+
...shared,
|
|
4519
|
+
variant: props.panelVariant,
|
|
4520
|
+
onViewSubscription: () => go("subscriptions"),
|
|
4521
|
+
onPayNow: props.onPayNow,
|
|
4522
|
+
onReorder: props.onReorder,
|
|
4523
|
+
onTrackShipment: props.onTrackShipment
|
|
4524
|
+
}
|
|
4525
|
+
) : null,
|
|
4526
|
+
active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4527
|
+
active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
4528
|
+
active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
|
|
4133
4529
|
]
|
|
4134
4530
|
}
|
|
4135
4531
|
);
|
|
4136
|
-
return /* @__PURE__ */ (0,
|
|
4137
|
-
/* @__PURE__ */ (0,
|
|
4138
|
-
sidebar ? /* @__PURE__ */ (0,
|
|
4139
|
-
/* @__PURE__ */ (0,
|
|
4532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
|
|
4533
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(VerifyEmailBanner, { ...shared }),
|
|
4534
|
+
sidebar ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "throttle-account", children: [
|
|
4535
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
|
|
4140
4536
|
panel
|
|
4141
|
-
] }) : /* @__PURE__ */ (0,
|
|
4142
|
-
/* @__PURE__ */ (0,
|
|
4537
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
4538
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
4143
4539
|
panel
|
|
4144
4540
|
] })
|
|
4145
4541
|
] }) }) });
|
|
4146
4542
|
}
|
|
4147
4543
|
|
|
4148
4544
|
// src/react/components/account/AccountModal.tsx
|
|
4149
|
-
var
|
|
4545
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4150
4546
|
function AccountModal(props) {
|
|
4151
4547
|
const a = useAppearance(props.appearance);
|
|
4152
4548
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4153
4549
|
const { t } = useCopy(props.localization);
|
|
4154
|
-
const titleId = (0,
|
|
4155
|
-
return /* @__PURE__ */ (0,
|
|
4550
|
+
const titleId = (0, import_react31.useId)();
|
|
4551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
4156
4552
|
Modal,
|
|
4157
4553
|
{
|
|
4158
4554
|
open: props.open,
|
|
@@ -4162,15 +4558,15 @@ function AccountModal(props) {
|
|
|
4162
4558
|
overlayKey: "accountModal.overlay",
|
|
4163
4559
|
containerKey: "accountModal.container",
|
|
4164
4560
|
children: [
|
|
4165
|
-
/* @__PURE__ */ (0,
|
|
4166
|
-
/* @__PURE__ */ (0,
|
|
4561
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
|
|
4562
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
|
|
4167
4563
|
]
|
|
4168
4564
|
}
|
|
4169
4565
|
) });
|
|
4170
4566
|
}
|
|
4171
4567
|
|
|
4172
4568
|
// src/react/components/provider.tsx
|
|
4173
|
-
var
|
|
4569
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4174
4570
|
var warned = /* @__PURE__ */ new Set();
|
|
4175
4571
|
function warnOnce(key, message) {
|
|
4176
4572
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -4178,9 +4574,9 @@ function warnOnce(key, message) {
|
|
|
4178
4574
|
warned.add(key);
|
|
4179
4575
|
console.warn(`[@usethrottle/auth] ${message}`);
|
|
4180
4576
|
}
|
|
4181
|
-
var ThrottleUIContext = (0,
|
|
4577
|
+
var ThrottleUIContext = (0, import_react32.createContext)(null);
|
|
4182
4578
|
function useThrottle() {
|
|
4183
|
-
const ctx = (0,
|
|
4579
|
+
const ctx = (0, import_react32.useContext)(ThrottleUIContext);
|
|
4184
4580
|
if (!ctx) {
|
|
4185
4581
|
warnOnce(
|
|
4186
4582
|
"use-throttle-no-provider",
|
|
@@ -4215,51 +4611,51 @@ function ThrottleProvider(props) {
|
|
|
4215
4611
|
__captureStepUp
|
|
4216
4612
|
} = props;
|
|
4217
4613
|
useInjectStyles(injectStyles);
|
|
4218
|
-
const [stepUpOpen, setStepUpOpen] = (0,
|
|
4219
|
-
const resolveStepUp = (0,
|
|
4220
|
-
const claimRef = (0,
|
|
4614
|
+
const [stepUpOpen, setStepUpOpen] = (0, import_react32.useState)(false);
|
|
4615
|
+
const resolveStepUp = (0, import_react32.useRef)(null);
|
|
4616
|
+
const claimRef = (0, import_react32.useRef)(claimCartOnSignIn);
|
|
4221
4617
|
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,
|
|
4618
|
+
const [overlay, setOverlay] = (0, import_react32.useState)(null);
|
|
4619
|
+
const overlayRestoreFocus = (0, import_react32.useRef)(null);
|
|
4620
|
+
const [accountTabs, setAccountTabs] = (0, import_react32.useState)(void 0);
|
|
4621
|
+
const onOverlaySuccess = (0, import_react32.useRef)(null);
|
|
4622
|
+
const openSignIn = (0, import_react32.useCallback)((onSuccess) => {
|
|
4227
4623
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4228
4624
|
setOverlay("signIn");
|
|
4229
4625
|
}, []);
|
|
4230
|
-
const openSignUp = (0,
|
|
4626
|
+
const openSignUp = (0, import_react32.useCallback)((onSuccess) => {
|
|
4231
4627
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
4232
4628
|
setOverlay("signUp");
|
|
4233
4629
|
}, []);
|
|
4234
|
-
const openAccount = (0,
|
|
4630
|
+
const openAccount = (0, import_react32.useCallback)((opts) => {
|
|
4235
4631
|
onOverlaySuccess.current = null;
|
|
4236
4632
|
overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
|
|
4237
4633
|
setAccountTabs(opts?.tabs);
|
|
4238
4634
|
setOverlay("account");
|
|
4239
4635
|
}, []);
|
|
4240
|
-
const closeOverlay = (0,
|
|
4636
|
+
const closeOverlay = (0, import_react32.useCallback)(() => {
|
|
4241
4637
|
onOverlaySuccess.current = null;
|
|
4242
4638
|
overlayRestoreFocus.current = null;
|
|
4243
4639
|
setOverlay(null);
|
|
4244
4640
|
}, []);
|
|
4245
|
-
const handleOverlaySuccess = (0,
|
|
4641
|
+
const handleOverlaySuccess = (0, import_react32.useCallback)(() => {
|
|
4246
4642
|
const fn = onOverlaySuccess.current;
|
|
4247
4643
|
onOverlaySuccess.current = null;
|
|
4248
4644
|
setOverlay(null);
|
|
4249
4645
|
fn?.();
|
|
4250
4646
|
}, []);
|
|
4251
|
-
const ui = (0,
|
|
4647
|
+
const ui = (0, import_react32.useMemo)(
|
|
4252
4648
|
() => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
|
|
4253
4649
|
[overlay, openSignIn, openSignUp, openAccount, closeOverlay]
|
|
4254
4650
|
);
|
|
4255
|
-
const askForStepUp = (0,
|
|
4651
|
+
const askForStepUp = (0, import_react32.useCallback)(
|
|
4256
4652
|
() => new Promise((resolve) => {
|
|
4257
4653
|
resolveStepUp.current = resolve;
|
|
4258
4654
|
setStepUpOpen(true);
|
|
4259
4655
|
}),
|
|
4260
4656
|
[]
|
|
4261
4657
|
);
|
|
4262
|
-
const auth = (0,
|
|
4658
|
+
const auth = (0, import_react32.useMemo)(() => {
|
|
4263
4659
|
__captureStepUp?.(askForStepUp);
|
|
4264
4660
|
const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
|
|
4265
4661
|
const account = createAccount(client);
|
|
@@ -4292,10 +4688,10 @@ function ThrottleProvider(props) {
|
|
|
4292
4688
|
resolve?.(password);
|
|
4293
4689
|
};
|
|
4294
4690
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
4295
|
-
return /* @__PURE__ */ (0,
|
|
4691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ConfirmProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
|
|
4296
4692
|
children,
|
|
4297
|
-
/* @__PURE__ */ (0,
|
|
4298
|
-
/* @__PURE__ */ (0,
|
|
4693
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
|
|
4694
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4299
4695
|
AuthModal,
|
|
4300
4696
|
{
|
|
4301
4697
|
open: authOverlayOpen,
|
|
@@ -4306,23 +4702,23 @@ function ThrottleProvider(props) {
|
|
|
4306
4702
|
},
|
|
4307
4703
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
4308
4704
|
),
|
|
4309
|
-
/* @__PURE__ */ (0,
|
|
4310
|
-
] }) }) }) }) });
|
|
4705
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
4706
|
+
] }) }) }) }) }) });
|
|
4311
4707
|
}
|
|
4312
4708
|
|
|
4313
4709
|
// src/react/components/auth/SignInButton.tsx
|
|
4314
|
-
var
|
|
4315
|
-
var
|
|
4710
|
+
var import_react33 = require("react");
|
|
4711
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4316
4712
|
function SignInButton(props) {
|
|
4317
4713
|
const a = useAppearance(props.appearance);
|
|
4318
4714
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4319
4715
|
const { t } = useCopy(props.localization);
|
|
4320
|
-
const ui = (0,
|
|
4321
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4716
|
+
const ui = (0, import_react33.useContext)(ThrottleUIContext);
|
|
4717
|
+
const [localOpen, setLocalOpen] = (0, import_react33.useState)(false);
|
|
4322
4718
|
const useShared = ui !== null && props.initialView === void 0;
|
|
4323
4719
|
const label = props.children ?? t.signIn.submitButton;
|
|
4324
4720
|
if (props.mode === "redirect") {
|
|
4325
|
-
return /* @__PURE__ */ (0,
|
|
4721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
4326
4722
|
}
|
|
4327
4723
|
const openModal = () => {
|
|
4328
4724
|
if (useShared) ui.openSignIn(props.afterSignIn);
|
|
@@ -4332,10 +4728,10 @@ function SignInButton(props) {
|
|
|
4332
4728
|
if (useShared) ui.close();
|
|
4333
4729
|
else setLocalOpen(false);
|
|
4334
4730
|
};
|
|
4335
|
-
const trigger = props.asChild && (0,
|
|
4336
|
-
return /* @__PURE__ */ (0,
|
|
4337
|
-
/* @__PURE__ */ (0,
|
|
4338
|
-
!useShared ? /* @__PURE__ */ (0,
|
|
4731
|
+
const trigger = props.asChild && (0, import_react33.isValidElement)(props.children) ? (0, import_react33.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
|
|
4732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(AppearanceProvider, { value: scoped, children: [
|
|
4733
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("span", { ...a.rootProps, children: trigger }),
|
|
4734
|
+
!useShared ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4339
4735
|
AuthModal,
|
|
4340
4736
|
{
|
|
4341
4737
|
open: localOpen,
|
|
@@ -4353,18 +4749,18 @@ function SignInButton(props) {
|
|
|
4353
4749
|
}
|
|
4354
4750
|
|
|
4355
4751
|
// src/react/components/auth/SignUpButton.tsx
|
|
4356
|
-
var
|
|
4357
|
-
var
|
|
4752
|
+
var import_react34 = require("react");
|
|
4753
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
4358
4754
|
function SignUpButton(props) {
|
|
4359
4755
|
const a = useAppearance(props.appearance);
|
|
4360
4756
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4361
4757
|
const { t } = useCopy(props.localization);
|
|
4362
|
-
const ui = (0,
|
|
4363
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4758
|
+
const ui = (0, import_react34.useContext)(ThrottleUIContext);
|
|
4759
|
+
const [localOpen, setLocalOpen] = (0, import_react34.useState)(false);
|
|
4364
4760
|
const useShared = ui !== null && props.initialView === void 0;
|
|
4365
4761
|
const label = props.children ?? t.signUp.submitButton;
|
|
4366
4762
|
if (props.mode === "redirect") {
|
|
4367
|
-
return /* @__PURE__ */ (0,
|
|
4763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
4368
4764
|
}
|
|
4369
4765
|
const openModal = () => {
|
|
4370
4766
|
if (useShared) ui.openSignUp(props.afterSignUp);
|
|
@@ -4374,10 +4770,10 @@ function SignUpButton(props) {
|
|
|
4374
4770
|
if (useShared) ui.close();
|
|
4375
4771
|
else setLocalOpen(false);
|
|
4376
4772
|
};
|
|
4377
|
-
const trigger = props.asChild && (0,
|
|
4378
|
-
return /* @__PURE__ */ (0,
|
|
4379
|
-
/* @__PURE__ */ (0,
|
|
4380
|
-
!useShared ? /* @__PURE__ */ (0,
|
|
4773
|
+
const trigger = props.asChild && (0, import_react34.isValidElement)(props.children) ? (0, import_react34.cloneElement)(props.children, { onClick: openModal }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
|
|
4774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(AppearanceProvider, { value: scoped, children: [
|
|
4775
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { ...a.rootProps, children: trigger }),
|
|
4776
|
+
!useShared ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4381
4777
|
AuthModal,
|
|
4382
4778
|
{
|
|
4383
4779
|
open: localOpen,
|
|
@@ -4395,14 +4791,14 @@ function SignUpButton(props) {
|
|
|
4395
4791
|
}
|
|
4396
4792
|
|
|
4397
4793
|
// src/react/components/auth/SignOutButton.tsx
|
|
4398
|
-
var
|
|
4794
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
4399
4795
|
function SignOutButton(props) {
|
|
4400
4796
|
const a = useAppearance();
|
|
4401
4797
|
const { auth } = useAuth();
|
|
4402
4798
|
const { t } = useCopy(props.localization);
|
|
4403
4799
|
const { submitting, run } = useAction();
|
|
4404
4800
|
const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
|
|
4405
|
-
return /* @__PURE__ */ (0,
|
|
4801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4406
4802
|
Button,
|
|
4407
4803
|
{
|
|
4408
4804
|
variant: "secondary",
|
|
@@ -4419,13 +4815,13 @@ function SignOutButton(props) {
|
|
|
4419
4815
|
}
|
|
4420
4816
|
|
|
4421
4817
|
// src/react/components/auth/SignInPage.tsx
|
|
4422
|
-
var
|
|
4818
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
4423
4819
|
function SignInPage(props) {
|
|
4424
4820
|
const a = useAppearance(props.appearance);
|
|
4425
4821
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4426
|
-
return /* @__PURE__ */ (0,
|
|
4427
|
-
props.logo ? /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { ...a.el("signInPage.root", "throttle-page"), children: [
|
|
4823
|
+
props.logo ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4429
4825
|
SignIn,
|
|
4430
4826
|
{
|
|
4431
4827
|
onSuccess: props.onSuccess,
|
|
@@ -4435,18 +4831,18 @@ function SignInPage(props) {
|
|
|
4435
4831
|
localization: props.localization
|
|
4436
4832
|
}
|
|
4437
4833
|
),
|
|
4438
|
-
props.footer ? /* @__PURE__ */ (0,
|
|
4834
|
+
props.footer ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
4439
4835
|
] }) }) });
|
|
4440
4836
|
}
|
|
4441
4837
|
|
|
4442
4838
|
// src/react/components/auth/SignUpPage.tsx
|
|
4443
|
-
var
|
|
4839
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4444
4840
|
function SignUpPage(props) {
|
|
4445
4841
|
const a = useAppearance(props.appearance);
|
|
4446
4842
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4447
|
-
return /* @__PURE__ */ (0,
|
|
4448
|
-
props.logo ? /* @__PURE__ */ (0,
|
|
4449
|
-
/* @__PURE__ */ (0,
|
|
4843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
|
|
4844
|
+
props.logo ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4845
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4450
4846
|
SignUp,
|
|
4451
4847
|
{
|
|
4452
4848
|
onSuccess: props.onSuccess,
|
|
@@ -4455,42 +4851,42 @@ function SignUpPage(props) {
|
|
|
4455
4851
|
localization: props.localization
|
|
4456
4852
|
}
|
|
4457
4853
|
),
|
|
4458
|
-
props.footer ? /* @__PURE__ */ (0,
|
|
4854
|
+
props.footer ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
4459
4855
|
] }) }) });
|
|
4460
4856
|
}
|
|
4461
4857
|
|
|
4462
4858
|
// src/react/components/guards.tsx
|
|
4463
|
-
var
|
|
4859
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4464
4860
|
function SignedIn(props) {
|
|
4465
4861
|
const { status } = useAuth();
|
|
4466
|
-
return status === "authenticated" ? /* @__PURE__ */ (0,
|
|
4862
|
+
return status === "authenticated" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children }) : null;
|
|
4467
4863
|
}
|
|
4468
4864
|
function SignedOut(props) {
|
|
4469
4865
|
const { status } = useAuth();
|
|
4470
|
-
return status === "unauthenticated" ? /* @__PURE__ */ (0,
|
|
4866
|
+
return status === "unauthenticated" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children }) : null;
|
|
4471
4867
|
}
|
|
4472
4868
|
function Protect(props) {
|
|
4473
4869
|
const { status, emailVerified } = useAuth();
|
|
4474
4870
|
if (status === "loading") return null;
|
|
4475
|
-
if (status !== "authenticated") return /* @__PURE__ */ (0,
|
|
4476
|
-
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0,
|
|
4477
|
-
return /* @__PURE__ */ (0,
|
|
4871
|
+
if (status !== "authenticated") return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.fallback ?? null });
|
|
4872
|
+
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.fallback ?? null });
|
|
4873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: props.children });
|
|
4478
4874
|
}
|
|
4479
4875
|
|
|
4480
4876
|
// src/react/components/UserButton.tsx
|
|
4481
|
-
var
|
|
4482
|
-
var
|
|
4877
|
+
var import_react35 = require("react");
|
|
4878
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4483
4879
|
function UserButtonRoot(props) {
|
|
4484
4880
|
const a = useAppearance(props.appearance);
|
|
4485
4881
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
4486
4882
|
const { t } = useCopy(props.localization);
|
|
4487
4883
|
const { auth, status, customer, emailVerified } = useAuth();
|
|
4488
|
-
const ui = (0,
|
|
4489
|
-
const [localOpen, setLocalOpen] = (0,
|
|
4884
|
+
const ui = (0, import_react35.useContext)(ThrottleUIContext);
|
|
4885
|
+
const [localOpen, setLocalOpen] = (0, import_react35.useState)(false);
|
|
4490
4886
|
const accountOpen = ui ? false : localOpen;
|
|
4491
|
-
const titleId = (0,
|
|
4492
|
-
const rootRef = (0,
|
|
4493
|
-
const openerRef = (0,
|
|
4887
|
+
const titleId = (0, import_react35.useId)();
|
|
4888
|
+
const rootRef = (0, import_react35.useRef)(null);
|
|
4889
|
+
const openerRef = (0, import_react35.useRef)(null);
|
|
4494
4890
|
const openAccount = () => {
|
|
4495
4891
|
const opener = rootRef.current?.querySelector('button[aria-haspopup="menu"]') ?? null;
|
|
4496
4892
|
openerRef.current = opener;
|
|
@@ -4499,25 +4895,25 @@ function UserButtonRoot(props) {
|
|
|
4499
4895
|
};
|
|
4500
4896
|
if (status !== "authenticated" || !customer) return null;
|
|
4501
4897
|
const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
|
|
4502
|
-
return /* @__PURE__ */ (0,
|
|
4503
|
-
/* @__PURE__ */ (0,
|
|
4898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { ref: rootRef, ...a.el("userButton.root"), children: [
|
|
4899
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
4504
4900
|
Dropdown,
|
|
4505
4901
|
{
|
|
4506
4902
|
label: t.userButton.openMenu,
|
|
4507
4903
|
triggerKey: "userButton.trigger",
|
|
4508
4904
|
menuKey: "userButton.menu",
|
|
4509
|
-
trigger: /* @__PURE__ */ (0,
|
|
4905
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Avatar, { name, email: customer.email }),
|
|
4510
4906
|
children: [
|
|
4511
|
-
/* @__PURE__ */ (0,
|
|
4512
|
-
/* @__PURE__ */ (0,
|
|
4513
|
-
/* @__PURE__ */ (0,
|
|
4514
|
-
/* @__PURE__ */ (0,
|
|
4907
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { children: [
|
|
4908
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { ...a.el("userButton.email"), children: customer.email }),
|
|
4909
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("br", {}),
|
|
4910
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
|
|
4515
4911
|
] }) }),
|
|
4516
|
-
/* @__PURE__ */ (0,
|
|
4517
|
-
props.mode === "navigate" ? /* @__PURE__ */ (0,
|
|
4912
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownSeparator, {}),
|
|
4913
|
+
props.mode === "navigate" ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
|
|
4518
4914
|
props.children,
|
|
4519
|
-
/* @__PURE__ */ (0,
|
|
4520
|
-
/* @__PURE__ */ (0,
|
|
4915
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DropdownSeparator, {}),
|
|
4916
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
4521
4917
|
DropdownItem,
|
|
4522
4918
|
{
|
|
4523
4919
|
itemKey: "userButton.signOutButton",
|
|
@@ -4525,7 +4921,7 @@ function UserButtonRoot(props) {
|
|
|
4525
4921
|
children: t.userButton.signOut
|
|
4526
4922
|
}
|
|
4527
4923
|
),
|
|
4528
|
-
/* @__PURE__ */ (0,
|
|
4924
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
4529
4925
|
DropdownItem,
|
|
4530
4926
|
{
|
|
4531
4927
|
itemKey: "userButton.signOutAllButton",
|
|
@@ -4536,7 +4932,7 @@ function UserButtonRoot(props) {
|
|
|
4536
4932
|
]
|
|
4537
4933
|
}
|
|
4538
4934
|
),
|
|
4539
|
-
props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0,
|
|
4935
|
+
props.mode !== "navigate" && !ui ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
4540
4936
|
Modal,
|
|
4541
4937
|
{
|
|
4542
4938
|
open: accountOpen,
|
|
@@ -4544,8 +4940,8 @@ function UserButtonRoot(props) {
|
|
|
4544
4940
|
labelledBy: titleId,
|
|
4545
4941
|
restoreFocusTo: openerRef.current,
|
|
4546
4942
|
children: [
|
|
4547
|
-
/* @__PURE__ */ (0,
|
|
4548
|
-
/* @__PURE__ */ (0,
|
|
4943
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
|
|
4944
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { padding: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
4549
4945
|
AccountDashboard,
|
|
4550
4946
|
{
|
|
4551
4947
|
tabs: props.tabs,
|
|
@@ -4559,13 +4955,13 @@ function UserButtonRoot(props) {
|
|
|
4559
4955
|
] }) }) });
|
|
4560
4956
|
}
|
|
4561
4957
|
function UserButtonLink(props) {
|
|
4562
|
-
return /* @__PURE__ */ (0,
|
|
4958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
|
|
4563
4959
|
props.icon,
|
|
4564
4960
|
props.label
|
|
4565
4961
|
] });
|
|
4566
4962
|
}
|
|
4567
4963
|
function UserButtonAction(props) {
|
|
4568
|
-
return /* @__PURE__ */ (0,
|
|
4964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
|
|
4569
4965
|
props.icon,
|
|
4570
4966
|
props.label
|
|
4571
4967
|
] });
|
|
@@ -4579,6 +4975,7 @@ var UserButton = Object.assign(UserButtonRoot, {
|
|
|
4579
4975
|
ACCOUNT_TABS,
|
|
4580
4976
|
AccountDashboard,
|
|
4581
4977
|
AccountModal,
|
|
4978
|
+
AddCardDialog,
|
|
4582
4979
|
AddressesPanel,
|
|
4583
4980
|
AuthFlow,
|
|
4584
4981
|
AuthModal,
|