@usethrottle/auth 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-HGBAIM6B.js → chunk-2DREGJUF.js} +2 -2
- package/dist/{chunk-SZ427BQ3.js → chunk-NCSTIPJF.js} +8 -1
- package/dist/{chunk-SZ427BQ3.js.map → chunk-NCSTIPJF.js.map} +1 -1
- package/dist/{chunk-AIXBUDOT.js → chunk-ST77QX7X.js} +12 -1
- package/dist/chunk-ST77QX7X.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/react/components/index.cjs +439 -297
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +24 -8
- package/dist/react/components/index.d.ts +24 -8
- package/dist/react/components/index.js +409 -286
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/forms/index.cjs +11 -0
- package/dist/react/forms/index.cjs.map +1 -1
- package/dist/react/forms/index.js +2 -2
- package/dist/react/index.cjs +7 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +24 -0
- package/dist/react/index.d.ts +24 -0
- package/dist/react/index.js +2 -2
- package/dist/styles.css +21 -2
- package/package.json +1 -1
- package/dist/chunk-AIXBUDOT.js.map +0 -1
- /package/dist/{chunk-HGBAIM6B.js.map → chunk-2DREGJUF.js.map} +0 -0
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
useOrders,
|
|
9
9
|
useSavedCards,
|
|
10
10
|
useSubscriptions
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-2DREGJUF.js";
|
|
12
12
|
import {
|
|
13
13
|
messageForError
|
|
14
|
-
} from "../../chunk-
|
|
14
|
+
} from "../../chunk-ST77QX7X.js";
|
|
15
15
|
import {
|
|
16
16
|
ThrottleAuthError,
|
|
17
17
|
ThrottleAuthProvider,
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
memoryStorage,
|
|
22
22
|
useAuth,
|
|
23
23
|
useAuthContext
|
|
24
|
-
} from "../../chunk-
|
|
24
|
+
} from "../../chunk-NCSTIPJF.js";
|
|
25
25
|
|
|
26
26
|
// src/react/components/provider.tsx
|
|
27
|
-
import { createContext as createContext5, useCallback as useCallback3, useContext as useContext5, useMemo as useMemo3, useRef as
|
|
27
|
+
import { createContext as createContext5, useCallback as useCallback3, useContext as useContext5, useMemo as useMemo3, useRef as useRef8, useState as useState21 } from "react";
|
|
28
28
|
|
|
29
29
|
// src/react/components/appearance.tsx
|
|
30
30
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -140,6 +140,12 @@ var VARIABLE_PROPERTY = {
|
|
|
140
140
|
borderRadius: "--throttle-radius",
|
|
141
141
|
borderWidth: "--throttle-border-width",
|
|
142
142
|
spacing: "--throttle-spacing",
|
|
143
|
+
// The account dashboard's own surface and outer padding. Separate from
|
|
144
|
+
// colorBackground/colorSurface because a merchant embedding the dashboard
|
|
145
|
+
// in their page usually wants it to paint nothing at all, while still
|
|
146
|
+
// theming the cards inside it.
|
|
147
|
+
accountSurface: "--throttle-color-account-surface",
|
|
148
|
+
accountPadding: "--throttle-account-padding",
|
|
143
149
|
shadowCard: "--throttle-shadow-card",
|
|
144
150
|
shadowPopover: "--throttle-shadow-popover",
|
|
145
151
|
transition: "--throttle-transition",
|
|
@@ -274,6 +280,8 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
274
280
|
"paymentMethodsPanel.item",
|
|
275
281
|
"paymentMethodsPanel.defaultButton",
|
|
276
282
|
"paymentMethodsPanel.deleteButton",
|
|
283
|
+
"paymentMethodsPanel.addButton",
|
|
284
|
+
"paymentMethodsPanel.addDialog",
|
|
277
285
|
"paymentMethodsPanel.table",
|
|
278
286
|
"paymentMethodsPanel.row",
|
|
279
287
|
"ordersPanel.root",
|
|
@@ -502,8 +510,9 @@ var enUS = {
|
|
|
502
510
|
},
|
|
503
511
|
paymentMethods: {
|
|
504
512
|
empty: "No saved cards",
|
|
505
|
-
|
|
506
|
-
|
|
513
|
+
emptyDescription: "Add a card here, or one will be saved when you check out.",
|
|
514
|
+
addButton: "Add card",
|
|
515
|
+
addTitle: "Add a card",
|
|
507
516
|
// Shown whenever the panel is empty with no error and the buyer is not
|
|
508
517
|
// verified — including simply being signed out — matching the copy
|
|
509
518
|
// orders/invoices/subscriptions already show in that state.
|
|
@@ -700,6 +709,12 @@ var THROTTLE_STYLES = `
|
|
|
700
709
|
edges, table rules, dividers) keep --throttle-color-border: they do not
|
|
701
710
|
identify a control, so the requirement does not apply and darkening
|
|
702
711
|
them would only add noise. */
|
|
712
|
+
/* The account dashboard paints nothing by default so it can drop into a
|
|
713
|
+
merchant's page without fighting their background. The accountSurface and
|
|
714
|
+
accountPadding appearance variables opt back into a card.
|
|
715
|
+
No backticks in this comment: the sheet is a TS template literal. */
|
|
716
|
+
--throttle-color-account-surface: transparent;
|
|
717
|
+
--throttle-account-padding: 0;
|
|
703
718
|
--throttle-color-border-control: #8b93a1;
|
|
704
719
|
--throttle-color-danger: #c2321f;
|
|
705
720
|
--throttle-color-danger-surface: #fef2f2;
|
|
@@ -848,7 +863,13 @@ var THROTTLE_STYLES = `
|
|
|
848
863
|
/* Always mounted, so it reserves its line whether or not there is an error:
|
|
849
864
|
an error appearing on submit must not push the submit button out from
|
|
850
865
|
under the buyer's pointer. */
|
|
851
|
-
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs);
|
|
866
|
+
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs); line-height: 1rem; }
|
|
867
|
+
/* Reserved a full line under EVERY input even with nothing to say, which
|
|
868
|
+
with the stack gap put 28px of dead space beneath each field, on every
|
|
869
|
+
form and all seven account panels. The element stays mounted when empty
|
|
870
|
+
because role=alert only announces changes to a live region that was
|
|
871
|
+
already there; it just stops occupying a line. */
|
|
872
|
+
.throttle-field__error:empty { display: none; }
|
|
852
873
|
|
|
853
874
|
.throttle-field-group {
|
|
854
875
|
display: flex;
|
|
@@ -907,6 +928,11 @@ var THROTTLE_STYLES = `
|
|
|
907
928
|
animation: throttle-spin 700ms linear infinite;
|
|
908
929
|
}
|
|
909
930
|
@keyframes throttle-spin { to { transform: rotate(360deg); } }
|
|
931
|
+
.throttle-button--loading { position: relative; }
|
|
932
|
+
.throttle-button__label { display: inline-flex; align-items: center; justify-content: center; gap: var(--throttle-space-2); }
|
|
933
|
+
.throttle-button__label--hidden { visibility: hidden; }
|
|
934
|
+
.throttle-spinner--centred { position: absolute; top: 50%; left: 50%; margin: -0.5em 0 0 -0.5em; }
|
|
935
|
+
|
|
910
936
|
@media (prefers-reduced-motion: reduce) { .throttle-spinner { animation-duration: 2.4s; } }
|
|
911
937
|
|
|
912
938
|
.throttle-skeleton {
|
|
@@ -989,7 +1015,9 @@ var THROTTLE_STYLES = `
|
|
|
989
1015
|
/* Paints its own ground. A UserButton in a navbar should stay transparent, but
|
|
990
1016
|
the dashboard is a large surface of themed text: in dark theme its foreground
|
|
991
1017
|
is near-white, so on a light host page it was rendering white-on-white. */
|
|
992
|
-
.throttle-
|
|
1018
|
+
.throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
|
|
1019
|
+
.throttle-centre { display: flex; align-items: center; justify-content: center; min-height: 160px; }
|
|
1020
|
+
.throttle-account-root { container-type: inline-size; background: var(--throttle-color-account-surface); color: var(--throttle-color-foreground); padding: var(--throttle-account-padding); }
|
|
993
1021
|
.throttle-account { display: flex; gap: var(--throttle-space-5); align-items: flex-start; }
|
|
994
1022
|
.throttle-account__content { flex: 1; min-width: 0; }
|
|
995
1023
|
.throttle-tabs__rail { flex: none; width: 220px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -1169,11 +1197,12 @@ function CardFooter(props) {
|
|
|
1169
1197
|
|
|
1170
1198
|
// src/react/components/primitives/Spinner.tsx
|
|
1171
1199
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1172
|
-
function Spinner() {
|
|
1200
|
+
function Spinner({ centred } = {}) {
|
|
1173
1201
|
const a = useAppearance();
|
|
1174
1202
|
const Slot = a.slots.Spinner;
|
|
1175
1203
|
if (Slot) return /* @__PURE__ */ jsx6(Slot, {});
|
|
1176
|
-
|
|
1204
|
+
const cls = `throttle-spinner${centred ? " throttle-spinner--centred" : ""}`;
|
|
1205
|
+
return /* @__PURE__ */ jsx6("span", { ...a.el("spinner", cls), "aria-hidden": "true" });
|
|
1177
1206
|
}
|
|
1178
1207
|
|
|
1179
1208
|
// src/react/components/primitives/Button.tsx
|
|
@@ -1182,7 +1211,7 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1182
1211
|
const a = useAppearance();
|
|
1183
1212
|
const Slot = a.slots.Button;
|
|
1184
1213
|
if (Slot) return /* @__PURE__ */ jsx7(Slot, { variant, loading, ...rest, children });
|
|
1185
|
-
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}`;
|
|
1214
|
+
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}${loading ? " throttle-button--loading" : ""}`;
|
|
1186
1215
|
return /* @__PURE__ */ jsxs2(
|
|
1187
1216
|
"button",
|
|
1188
1217
|
{
|
|
@@ -1190,9 +1219,10 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1190
1219
|
...rest,
|
|
1191
1220
|
...a.el(elementKey ?? "button", base),
|
|
1192
1221
|
disabled: rest.disabled || loading,
|
|
1222
|
+
"aria-busy": loading ? true : void 0,
|
|
1193
1223
|
children: [
|
|
1194
|
-
loading ? /* @__PURE__ */ jsx7(Spinner, {}) : null,
|
|
1195
|
-
children
|
|
1224
|
+
loading ? /* @__PURE__ */ jsx7(Spinner, { centred: true }) : null,
|
|
1225
|
+
/* @__PURE__ */ jsx7("span", { className: `throttle-button__label${loading ? " throttle-button__label--hidden" : ""}`, children })
|
|
1196
1226
|
]
|
|
1197
1227
|
}
|
|
1198
1228
|
);
|
|
@@ -2115,10 +2145,10 @@ function AuthModal(props) {
|
|
|
2115
2145
|
}
|
|
2116
2146
|
|
|
2117
2147
|
// src/react/components/account/AccountModal.tsx
|
|
2118
|
-
import { useId as
|
|
2148
|
+
import { useId as useId6 } from "react";
|
|
2119
2149
|
|
|
2120
2150
|
// src/react/components/account/AccountDashboard.tsx
|
|
2121
|
-
import { useEffect as
|
|
2151
|
+
import { useEffect as useEffect9, useId as useId5, useState as useState20 } from "react";
|
|
2122
2152
|
|
|
2123
2153
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2124
2154
|
import { useState as useState11 } from "react";
|
|
@@ -2270,7 +2300,7 @@ function ProfilePanel(props) {
|
|
|
2270
2300
|
const { status } = useAuth();
|
|
2271
2301
|
const resource = useCustomer();
|
|
2272
2302
|
const { submitting, error, notice, run } = useAction();
|
|
2273
|
-
const [form, setForm] = useState12({ firstName: "", lastName: "", phone: "", company: ""
|
|
2303
|
+
const [form, setForm] = useState12({ firstName: "", lastName: "", phone: "", company: "" });
|
|
2274
2304
|
const edited = useRef5(false);
|
|
2275
2305
|
useEffect6(() => {
|
|
2276
2306
|
const c = resource.data;
|
|
@@ -2279,8 +2309,7 @@ function ProfilePanel(props) {
|
|
|
2279
2309
|
firstName: c.firstName ?? "",
|
|
2280
2310
|
lastName: c.lastName ?? "",
|
|
2281
2311
|
phone: c.phone ?? "",
|
|
2282
|
-
company: c.company ?? ""
|
|
2283
|
-
acceptsMarketing: Boolean(c.acceptsMarketing)
|
|
2312
|
+
company: c.company ?? ""
|
|
2284
2313
|
});
|
|
2285
2314
|
}, [resource.data]);
|
|
2286
2315
|
if (status === "unauthenticated") return null;
|
|
@@ -2303,8 +2332,7 @@ function ProfilePanel(props) {
|
|
|
2303
2332
|
firstName: form.firstName,
|
|
2304
2333
|
lastName: form.lastName,
|
|
2305
2334
|
phone: form.phone,
|
|
2306
|
-
company: form.company || null
|
|
2307
|
-
acceptsMarketing: form.acceptsMarketing
|
|
2335
|
+
company: form.company || null
|
|
2308
2336
|
});
|
|
2309
2337
|
return t.profile.savedNotice;
|
|
2310
2338
|
});
|
|
@@ -2371,20 +2399,6 @@ function ProfilePanel(props) {
|
|
|
2371
2399
|
}
|
|
2372
2400
|
}
|
|
2373
2401
|
),
|
|
2374
|
-
/* @__PURE__ */ jsxs20("label", { className: "throttle-row", children: [
|
|
2375
|
-
/* @__PURE__ */ jsx29(
|
|
2376
|
-
"input",
|
|
2377
|
-
{
|
|
2378
|
-
type: "checkbox",
|
|
2379
|
-
checked: form.acceptsMarketing,
|
|
2380
|
-
onChange: (e) => {
|
|
2381
|
-
edited.current = true;
|
|
2382
|
-
setForm((f) => ({ ...f, acceptsMarketing: e.target.checked }));
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
),
|
|
2386
|
-
/* @__PURE__ */ jsx29("span", { children: t.profile.acceptsMarketing })
|
|
2387
|
-
] }),
|
|
2388
2402
|
error ? /* @__PURE__ */ jsx29(Alert, { tone: "error", children: error }) : null,
|
|
2389
2403
|
notice ? /* @__PURE__ */ jsx29(Alert, { tone: "success", children: notice }) : null,
|
|
2390
2404
|
/* @__PURE__ */ jsx29(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
@@ -2537,7 +2551,7 @@ function AddressesPanel(props) {
|
|
|
2537
2551
|
})
|
|
2538
2552
|
}
|
|
2539
2553
|
) : /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
2540
|
-
/* @__PURE__ */ jsx31(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }),
|
|
2554
|
+
/* @__PURE__ */ jsx31("div", { children: /* @__PURE__ */ jsx31(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
|
|
2541
2555
|
/* @__PURE__ */ jsx31(
|
|
2542
2556
|
PanelState,
|
|
2543
2557
|
{
|
|
@@ -2644,7 +2658,102 @@ function AddressesPanel(props) {
|
|
|
2644
2658
|
}
|
|
2645
2659
|
|
|
2646
2660
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2661
|
+
import { useState as useState16 } from "react";
|
|
2662
|
+
|
|
2663
|
+
// src/react/components/account/AddCardDialog.tsx
|
|
2664
|
+
import { useEffect as useEffect7, useId as useId4, useRef as useRef6, useState as useState15 } from "react";
|
|
2647
2665
|
import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2666
|
+
function AddCardDialog(props) {
|
|
2667
|
+
const { account } = useAuth();
|
|
2668
|
+
const titleId = useId4();
|
|
2669
|
+
const { t } = useCopy(props.localization);
|
|
2670
|
+
const [src, setSrc] = useState15(null);
|
|
2671
|
+
const [error, setError] = useState15(null);
|
|
2672
|
+
const [busy, setBusy] = useState15(false);
|
|
2673
|
+
const onAdded = useRef6(props.onAdded);
|
|
2674
|
+
const onClose = useRef6(props.onClose);
|
|
2675
|
+
onAdded.current = props.onAdded;
|
|
2676
|
+
onClose.current = props.onClose;
|
|
2677
|
+
useEffect7(() => {
|
|
2678
|
+
if (!props.open) {
|
|
2679
|
+
setSrc(null);
|
|
2680
|
+
setError(null);
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2683
|
+
let live = true;
|
|
2684
|
+
setError(null);
|
|
2685
|
+
account.startCardSetup().then(
|
|
2686
|
+
(session) => {
|
|
2687
|
+
if (!live) return;
|
|
2688
|
+
let url = session.embedUrl;
|
|
2689
|
+
try {
|
|
2690
|
+
const u = new URL(session.embedUrl, window.location.origin);
|
|
2691
|
+
u.searchParams.set("parentOrigin", window.location.origin);
|
|
2692
|
+
url = u.toString();
|
|
2693
|
+
} catch {
|
|
2694
|
+
}
|
|
2695
|
+
setSrc(url);
|
|
2696
|
+
},
|
|
2697
|
+
(err) => {
|
|
2698
|
+
if (live) setError(messageForError(err));
|
|
2699
|
+
}
|
|
2700
|
+
);
|
|
2701
|
+
return () => {
|
|
2702
|
+
live = false;
|
|
2703
|
+
};
|
|
2704
|
+
}, [props.open, account]);
|
|
2705
|
+
useEffect7(() => {
|
|
2706
|
+
if (!src) return;
|
|
2707
|
+
const frameOrigin = (() => {
|
|
2708
|
+
try {
|
|
2709
|
+
return new URL(src).origin;
|
|
2710
|
+
} catch {
|
|
2711
|
+
return null;
|
|
2712
|
+
}
|
|
2713
|
+
})();
|
|
2714
|
+
if (!frameOrigin) return;
|
|
2715
|
+
async function onMessage(event) {
|
|
2716
|
+
if (event.origin !== frameOrigin) return;
|
|
2717
|
+
const data = event.data;
|
|
2718
|
+
if (!data || typeof data.type !== "string") return;
|
|
2719
|
+
if (data.type === "throttle.completed" && data.paymentId) {
|
|
2720
|
+
setBusy(true);
|
|
2721
|
+
try {
|
|
2722
|
+
await account.confirmCardSetup(data.paymentId);
|
|
2723
|
+
onAdded.current();
|
|
2724
|
+
onClose.current();
|
|
2725
|
+
} catch (err) {
|
|
2726
|
+
setError(messageForError(err));
|
|
2727
|
+
} finally {
|
|
2728
|
+
setBusy(false);
|
|
2729
|
+
}
|
|
2730
|
+
} else if (data.type === "throttle.error") {
|
|
2731
|
+
setError(data.message || t.common.somethingWentWrong);
|
|
2732
|
+
} else if (data.type === "throttle.cancelled") {
|
|
2733
|
+
onClose.current();
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
window.addEventListener("message", onMessage);
|
|
2737
|
+
return () => window.removeEventListener("message", onMessage);
|
|
2738
|
+
}, [src, account, t]);
|
|
2739
|
+
if (!props.open) return null;
|
|
2740
|
+
return /* @__PURE__ */ jsxs23(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
|
|
2741
|
+
/* @__PURE__ */ jsx32("h2", { id: titleId, children: t.paymentMethods.addTitle }),
|
|
2742
|
+
error ? /* @__PURE__ */ jsx32(Alert, { tone: "error", children: error }) : null,
|
|
2743
|
+
busy ? /* @__PURE__ */ jsx32("div", { className: "throttle-centre", children: /* @__PURE__ */ jsx32(Spinner, {}) }) : src ? /* @__PURE__ */ jsx32(
|
|
2744
|
+
"iframe",
|
|
2745
|
+
{
|
|
2746
|
+
className: "throttle-cardframe",
|
|
2747
|
+
src,
|
|
2748
|
+
title: t.paymentMethods.addTitle,
|
|
2749
|
+
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
2750
|
+
}
|
|
2751
|
+
) : !error ? /* @__PURE__ */ jsx32("div", { className: "throttle-centre", children: /* @__PURE__ */ jsx32(Spinner, {}) }) : null
|
|
2752
|
+
] });
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2756
|
+
import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2648
2757
|
function PaymentMethodsPanel(props) {
|
|
2649
2758
|
const a = useAppearance(props.appearance);
|
|
2650
2759
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2652,6 +2761,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2652
2761
|
const { emailVerified } = useAuth();
|
|
2653
2762
|
const resource = useSavedCards();
|
|
2654
2763
|
const { submitting, error, run } = useAction();
|
|
2764
|
+
const [adding, setAdding] = useState16(false);
|
|
2655
2765
|
const variant = props.variant ?? "rows";
|
|
2656
2766
|
const rowsVariant = variant === "rows";
|
|
2657
2767
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -2659,9 +2769,21 @@ function PaymentMethodsPanel(props) {
|
|
|
2659
2769
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
2660
2770
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
2661
2771
|
const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
|
|
2662
|
-
return /* @__PURE__ */
|
|
2663
|
-
error ? /* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */
|
|
2772
|
+
return /* @__PURE__ */ jsx33(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx33("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs24("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
|
|
2773
|
+
error ? /* @__PURE__ */ jsx33(Alert, { tone: "error", children: error }) : null,
|
|
2774
|
+
emailVerified ? /* @__PURE__ */ jsx33("div", { children: /* @__PURE__ */ jsx33(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
|
|
2775
|
+
/* @__PURE__ */ jsx33(
|
|
2776
|
+
AddCardDialog,
|
|
2777
|
+
{
|
|
2778
|
+
open: adding,
|
|
2779
|
+
onClose: () => setAdding(false),
|
|
2780
|
+
onAdded: () => {
|
|
2781
|
+
void resource.refetch();
|
|
2782
|
+
},
|
|
2783
|
+
localization: props.localization
|
|
2784
|
+
}
|
|
2785
|
+
),
|
|
2786
|
+
/* @__PURE__ */ jsx33(
|
|
2665
2787
|
PanelState,
|
|
2666
2788
|
{
|
|
2667
2789
|
resource,
|
|
@@ -2670,7 +2792,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2670
2792
|
isEmpty: (rows) => rows.length === 0,
|
|
2671
2793
|
emptyTitle: t.paymentMethods.empty,
|
|
2672
2794
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
2673
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
2795
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx33(
|
|
2674
2796
|
DataTable,
|
|
2675
2797
|
{
|
|
2676
2798
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -2680,9 +2802,9 @@ function PaymentMethodsPanel(props) {
|
|
|
2680
2802
|
columns: [
|
|
2681
2803
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
2682
2804
|
{ key: "expires", label: t.paymentMethods.expires, render: (card) => expiryLabel(card) },
|
|
2683
|
-
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */
|
|
2684
|
-
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */
|
|
2685
|
-
!card.isDefault ? /* @__PURE__ */
|
|
2805
|
+
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ jsx33(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
|
|
2806
|
+
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ jsxs24("div", { className: "throttle-actions", children: [
|
|
2807
|
+
!card.isDefault ? /* @__PURE__ */ jsx33(
|
|
2686
2808
|
Button,
|
|
2687
2809
|
{
|
|
2688
2810
|
variant: "secondary",
|
|
@@ -2692,7 +2814,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2692
2814
|
children: t.paymentMethods.makeDefault
|
|
2693
2815
|
}
|
|
2694
2816
|
) : null,
|
|
2695
|
-
/* @__PURE__ */
|
|
2817
|
+
/* @__PURE__ */ jsx33(
|
|
2696
2818
|
Button,
|
|
2697
2819
|
{
|
|
2698
2820
|
variant: "danger",
|
|
@@ -2708,13 +2830,13 @@ function PaymentMethodsPanel(props) {
|
|
|
2708
2830
|
] }) }
|
|
2709
2831
|
]
|
|
2710
2832
|
}
|
|
2711
|
-
) : /* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2715
|
-
card.isDefault ? /* @__PURE__ */
|
|
2833
|
+
) : /* @__PURE__ */ jsx33("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ jsxs24("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
|
|
2834
|
+
/* @__PURE__ */ jsxs24("div", { children: [
|
|
2835
|
+
/* @__PURE__ */ jsxs24("div", { className: "throttle-row", children: [
|
|
2836
|
+
/* @__PURE__ */ jsx33("strong", { children: cardLabel(card) }),
|
|
2837
|
+
card.isDefault ? /* @__PURE__ */ jsx33(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
|
|
2716
2838
|
] }),
|
|
2717
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */
|
|
2839
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ jsxs24("p", { className: "throttle-muted", children: [
|
|
2718
2840
|
t.paymentMethods.expires,
|
|
2719
2841
|
" ",
|
|
2720
2842
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -2722,8 +2844,8 @@ function PaymentMethodsPanel(props) {
|
|
|
2722
2844
|
card.cardExpYear
|
|
2723
2845
|
] }) : null
|
|
2724
2846
|
] }),
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
!card.isDefault ? /* @__PURE__ */
|
|
2847
|
+
/* @__PURE__ */ jsxs24("div", { className: "throttle-actions", children: [
|
|
2848
|
+
!card.isDefault ? /* @__PURE__ */ jsx33(
|
|
2727
2849
|
Button,
|
|
2728
2850
|
{
|
|
2729
2851
|
variant: actionVariant("secondary"),
|
|
@@ -2733,7 +2855,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2733
2855
|
children: t.paymentMethods.makeDefault
|
|
2734
2856
|
}
|
|
2735
2857
|
) : null,
|
|
2736
|
-
/* @__PURE__ */
|
|
2858
|
+
/* @__PURE__ */ jsx33(
|
|
2737
2859
|
Button,
|
|
2738
2860
|
{
|
|
2739
2861
|
variant: actionVariant("danger"),
|
|
@@ -2754,7 +2876,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2754
2876
|
}
|
|
2755
2877
|
|
|
2756
2878
|
// src/react/components/account/OrdersPanel.tsx
|
|
2757
|
-
import { useState as
|
|
2879
|
+
import { useState as useState17 } from "react";
|
|
2758
2880
|
|
|
2759
2881
|
// src/react/components/format.ts
|
|
2760
2882
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -2786,7 +2908,7 @@ function formatDate(value, locale) {
|
|
|
2786
2908
|
}
|
|
2787
2909
|
|
|
2788
2910
|
// src/react/components/account/OrderStatus.tsx
|
|
2789
|
-
import { Fragment as Fragment6, jsx as
|
|
2911
|
+
import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2790
2912
|
function copyKey(wire) {
|
|
2791
2913
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
2792
2914
|
}
|
|
@@ -2794,25 +2916,25 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
2794
2916
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
2795
2917
|
function StatusBadge(props) {
|
|
2796
2918
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2797
|
-
return /* @__PURE__ */
|
|
2919
|
+
return /* @__PURE__ */ jsx34(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
2798
2920
|
}
|
|
2799
2921
|
function OrderStatus(props) {
|
|
2800
2922
|
const labels = props.t.orders.statusLabels;
|
|
2801
2923
|
const payLabels = props.t.orders.paymentLabels;
|
|
2802
2924
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2803
2925
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
2804
|
-
return /* @__PURE__ */
|
|
2805
|
-
/* @__PURE__ */
|
|
2806
|
-
money ? /* @__PURE__ */
|
|
2926
|
+
return /* @__PURE__ */ jsxs25(Fragment6, { children: [
|
|
2927
|
+
/* @__PURE__ */ jsx34(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
|
|
2928
|
+
money ? /* @__PURE__ */ jsx34(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
|
|
2807
2929
|
] });
|
|
2808
2930
|
}
|
|
2809
2931
|
|
|
2810
2932
|
// src/react/components/account/OrderDetail.tsx
|
|
2811
|
-
import { Fragment as Fragment7, jsx as
|
|
2933
|
+
import { Fragment as Fragment7, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2812
2934
|
function Line(props) {
|
|
2813
|
-
return /* @__PURE__ */
|
|
2814
|
-
/* @__PURE__ */
|
|
2815
|
-
/* @__PURE__ */
|
|
2935
|
+
return /* @__PURE__ */ jsxs26("div", { className: "throttle-row", children: [
|
|
2936
|
+
/* @__PURE__ */ jsx35("span", { className: "throttle-muted", children: props.label }),
|
|
2937
|
+
/* @__PURE__ */ jsx35("span", { children: props.value })
|
|
2816
2938
|
] });
|
|
2817
2939
|
}
|
|
2818
2940
|
function OrderDetail(props) {
|
|
@@ -2820,7 +2942,7 @@ function OrderDetail(props) {
|
|
|
2820
2942
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2821
2943
|
const { t, locale } = useCopy(props.localization);
|
|
2822
2944
|
const resource = useOrder(props.orderId);
|
|
2823
|
-
return /* @__PURE__ */
|
|
2945
|
+
return /* @__PURE__ */ jsx35(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx35("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs26("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
|
|
2824
2946
|
props.onBack ? (
|
|
2825
2947
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
2826
2948
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -2828,27 +2950,27 @@ function OrderDetail(props) {
|
|
|
2828
2950
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
2829
2951
|
// its own width. A CSS fix would need a compound selector, and
|
|
2830
2952
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
2831
|
-
/* @__PURE__ */
|
|
2953
|
+
/* @__PURE__ */ jsx35("div", { children: /* @__PURE__ */ jsx35(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
2832
2954
|
) : null,
|
|
2833
|
-
/* @__PURE__ */
|
|
2955
|
+
/* @__PURE__ */ jsx35(
|
|
2834
2956
|
PanelState,
|
|
2835
2957
|
{
|
|
2836
2958
|
resource,
|
|
2837
2959
|
isEmpty: (o) => o === null,
|
|
2838
2960
|
emptyTitle: t.orders.empty,
|
|
2839
2961
|
skeletonRows: 5,
|
|
2840
|
-
children: (order) => /* @__PURE__ */
|
|
2841
|
-
/* @__PURE__ */
|
|
2842
|
-
/* @__PURE__ */
|
|
2843
|
-
/* @__PURE__ */
|
|
2962
|
+
children: (order) => /* @__PURE__ */ jsxs26(Fragment7, { children: [
|
|
2963
|
+
/* @__PURE__ */ jsxs26("div", { className: "throttle-row", children: [
|
|
2964
|
+
/* @__PURE__ */ jsx35("h3", { children: order.orderNumber }),
|
|
2965
|
+
/* @__PURE__ */ jsx35(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
|
|
2844
2966
|
] }),
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
/* @__PURE__ */
|
|
2847
|
-
item.imageUrl ? /* @__PURE__ */
|
|
2848
|
-
/* @__PURE__ */
|
|
2849
|
-
/* @__PURE__ */
|
|
2850
|
-
item.description ? /* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
2967
|
+
/* @__PURE__ */ jsx35("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
|
|
2968
|
+
/* @__PURE__ */ jsx35("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ jsxs26("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
|
|
2969
|
+
item.imageUrl ? /* @__PURE__ */ jsx35("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
|
|
2970
|
+
/* @__PURE__ */ jsxs26("div", { style: { flex: 1 }, children: [
|
|
2971
|
+
/* @__PURE__ */ jsx35("strong", { children: item.name }),
|
|
2972
|
+
item.description ? /* @__PURE__ */ jsx35("p", { className: "throttle-muted", children: item.description }) : null,
|
|
2973
|
+
/* @__PURE__ */ jsxs26("p", { className: "throttle-muted", children: [
|
|
2852
2974
|
t.orders.quantity,
|
|
2853
2975
|
" ",
|
|
2854
2976
|
item.quantity,
|
|
@@ -2856,16 +2978,16 @@ function OrderDetail(props) {
|
|
|
2856
2978
|
formatMoney(item.unitPrice, order.currency, locale)
|
|
2857
2979
|
] })
|
|
2858
2980
|
] }),
|
|
2859
|
-
/* @__PURE__ */
|
|
2981
|
+
/* @__PURE__ */ jsx35("span", { children: formatMoney(item.total, order.currency, locale) })
|
|
2860
2982
|
] }, item.id)) }),
|
|
2861
|
-
/* @__PURE__ */
|
|
2862
|
-
/* @__PURE__ */
|
|
2863
|
-
order.discountTotal ? /* @__PURE__ */
|
|
2864
|
-
/* @__PURE__ */
|
|
2865
|
-
/* @__PURE__ */
|
|
2866
|
-
/* @__PURE__ */
|
|
2983
|
+
/* @__PURE__ */ jsxs26("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
|
|
2984
|
+
/* @__PURE__ */ jsx35(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
|
|
2985
|
+
order.discountTotal ? /* @__PURE__ */ jsx35(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
|
|
2986
|
+
/* @__PURE__ */ jsx35(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
|
|
2987
|
+
/* @__PURE__ */ jsx35(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
|
|
2988
|
+
/* @__PURE__ */ jsx35(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
|
|
2867
2989
|
] }),
|
|
2868
|
-
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */
|
|
2990
|
+
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ jsx35(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
|
|
2869
2991
|
] })
|
|
2870
2992
|
}
|
|
2871
2993
|
)
|
|
@@ -2873,20 +2995,20 @@ function OrderDetail(props) {
|
|
|
2873
2995
|
}
|
|
2874
2996
|
|
|
2875
2997
|
// src/react/components/account/OrdersPanel.tsx
|
|
2876
|
-
import { jsx as
|
|
2998
|
+
import { jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2877
2999
|
function OrdersPanel(props) {
|
|
2878
3000
|
const a = useAppearance(props.appearance);
|
|
2879
3001
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2880
3002
|
const { t, locale } = useCopy(props.localization);
|
|
2881
3003
|
const { emailVerified } = useAuth();
|
|
2882
3004
|
const resource = useOrders();
|
|
2883
|
-
const [openId, setOpenId] =
|
|
3005
|
+
const [openId, setOpenId] = useState17(null);
|
|
2884
3006
|
const variant = props.variant ?? "table";
|
|
2885
3007
|
const rowsVariant = variant === "rows";
|
|
2886
3008
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
2887
3009
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
2888
3010
|
if (openId) {
|
|
2889
|
-
return /* @__PURE__ */
|
|
3011
|
+
return /* @__PURE__ */ jsx36(
|
|
2890
3012
|
OrderDetail,
|
|
2891
3013
|
{
|
|
2892
3014
|
orderId: openId,
|
|
@@ -2897,7 +3019,7 @@ function OrdersPanel(props) {
|
|
|
2897
3019
|
}
|
|
2898
3020
|
);
|
|
2899
3021
|
}
|
|
2900
|
-
return /* @__PURE__ */
|
|
3022
|
+
return /* @__PURE__ */ jsx36(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx36("div", { ...a.rootProps, children: /* @__PURE__ */ jsx36("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ jsx36(
|
|
2901
3023
|
PanelState,
|
|
2902
3024
|
{
|
|
2903
3025
|
resource,
|
|
@@ -2906,7 +3028,7 @@ function OrdersPanel(props) {
|
|
|
2906
3028
|
isEmpty: (rows) => rows.length === 0,
|
|
2907
3029
|
emptyTitle: t.orders.empty,
|
|
2908
3030
|
emptyDescription: t.orders.emptyDescription,
|
|
2909
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3031
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx36(
|
|
2910
3032
|
DataTable,
|
|
2911
3033
|
{
|
|
2912
3034
|
tableKey: "ordersPanel.table",
|
|
@@ -2920,25 +3042,25 @@ function OrdersPanel(props) {
|
|
|
2920
3042
|
{
|
|
2921
3043
|
key: "status",
|
|
2922
3044
|
label: t.orders.status,
|
|
2923
|
-
render: (o) => /* @__PURE__ */
|
|
3045
|
+
render: (o) => /* @__PURE__ */ jsx36(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
2924
3046
|
},
|
|
2925
3047
|
{
|
|
2926
3048
|
key: "total",
|
|
2927
3049
|
label: t.orders.total,
|
|
2928
|
-
render: (o) => /* @__PURE__ */
|
|
3050
|
+
render: (o) => /* @__PURE__ */ jsx36("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
2929
3051
|
}
|
|
2930
3052
|
]
|
|
2931
3053
|
}
|
|
2932
|
-
) : /* @__PURE__ */
|
|
2933
|
-
/* @__PURE__ */
|
|
2934
|
-
/* @__PURE__ */
|
|
2935
|
-
/* @__PURE__ */
|
|
2936
|
-
/* @__PURE__ */
|
|
3054
|
+
) : /* @__PURE__ */ jsx36("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ jsxs27("div", { ...a.el("ordersPanel.item", itemBase), children: [
|
|
3055
|
+
/* @__PURE__ */ jsxs27("div", { children: [
|
|
3056
|
+
/* @__PURE__ */ jsxs27("div", { className: "throttle-row", children: [
|
|
3057
|
+
/* @__PURE__ */ jsx36("strong", { children: o.orderNumber }),
|
|
3058
|
+
/* @__PURE__ */ jsx36(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
2937
3059
|
] }),
|
|
2938
|
-
/* @__PURE__ */
|
|
2939
|
-
/* @__PURE__ */
|
|
3060
|
+
/* @__PURE__ */ jsx36("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
|
|
3061
|
+
/* @__PURE__ */ jsx36("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
|
|
2940
3062
|
] }),
|
|
2941
|
-
/* @__PURE__ */
|
|
3063
|
+
/* @__PURE__ */ jsx36("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx36(
|
|
2942
3064
|
Button,
|
|
2943
3065
|
{
|
|
2944
3066
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -2953,14 +3075,14 @@ function OrdersPanel(props) {
|
|
|
2953
3075
|
}
|
|
2954
3076
|
|
|
2955
3077
|
// src/react/components/account/InvoicesPanel.tsx
|
|
2956
|
-
import { useState as
|
|
3078
|
+
import { useState as useState18 } from "react";
|
|
2957
3079
|
|
|
2958
3080
|
// src/react/components/account/InvoiceDetail.tsx
|
|
2959
|
-
import { Fragment as Fragment8, jsx as
|
|
3081
|
+
import { Fragment as Fragment8, jsx as jsx37, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
2960
3082
|
function Line2(props) {
|
|
2961
|
-
return /* @__PURE__ */
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
3083
|
+
return /* @__PURE__ */ jsxs28("div", { className: "throttle-row", children: [
|
|
3084
|
+
/* @__PURE__ */ jsx37("span", { className: "throttle-muted", children: props.label }),
|
|
3085
|
+
/* @__PURE__ */ jsx37("span", { children: props.value })
|
|
2964
3086
|
] });
|
|
2965
3087
|
}
|
|
2966
3088
|
function InvoiceDetail(props) {
|
|
@@ -2970,7 +3092,7 @@ function InvoiceDetail(props) {
|
|
|
2970
3092
|
const { account } = useAuth();
|
|
2971
3093
|
const resource = useInvoice(props.invoiceId);
|
|
2972
3094
|
const { submitting, error, run } = useAction();
|
|
2973
|
-
return /* @__PURE__ */
|
|
3095
|
+
return /* @__PURE__ */ jsx37(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx37("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs28("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
|
|
2974
3096
|
props.onBack ? (
|
|
2975
3097
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
2976
3098
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -2978,25 +3100,25 @@ function InvoiceDetail(props) {
|
|
|
2978
3100
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
2979
3101
|
// its own width. A CSS fix would need a compound selector, and
|
|
2980
3102
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
2981
|
-
/* @__PURE__ */
|
|
3103
|
+
/* @__PURE__ */ jsx37("div", { children: /* @__PURE__ */ jsx37(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
2982
3104
|
) : null,
|
|
2983
|
-
/* @__PURE__ */
|
|
2984
|
-
/* @__PURE__ */
|
|
2985
|
-
/* @__PURE__ */
|
|
2986
|
-
/* @__PURE__ */
|
|
3105
|
+
/* @__PURE__ */ jsx37(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
3106
|
+
/* @__PURE__ */ jsxs28("div", { className: "throttle-row", children: [
|
|
3107
|
+
/* @__PURE__ */ jsx37("h3", { children: invoice.number }),
|
|
3108
|
+
/* @__PURE__ */ jsx37(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
|
|
2987
3109
|
] }),
|
|
2988
|
-
/* @__PURE__ */
|
|
2989
|
-
/* @__PURE__ */
|
|
2990
|
-
invoice.dueAt ? /* @__PURE__ */
|
|
2991
|
-
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */
|
|
3110
|
+
/* @__PURE__ */ jsxs28("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
|
|
3111
|
+
/* @__PURE__ */ jsx37(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
|
|
3112
|
+
invoice.dueAt ? /* @__PURE__ */ jsx37(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
|
|
3113
|
+
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ jsx37(
|
|
2992
3114
|
Line2,
|
|
2993
3115
|
{
|
|
2994
3116
|
label: t.invoices.period,
|
|
2995
3117
|
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
2996
3118
|
}
|
|
2997
3119
|
) : null,
|
|
2998
|
-
/* @__PURE__ */
|
|
2999
|
-
invoice.amountRefunded ? /* @__PURE__ */
|
|
3120
|
+
/* @__PURE__ */ jsx37(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
|
|
3121
|
+
invoice.amountRefunded ? /* @__PURE__ */ jsx37(
|
|
3000
3122
|
Line2,
|
|
3001
3123
|
{
|
|
3002
3124
|
label: t.invoices.refunded,
|
|
@@ -3004,8 +3126,8 @@ function InvoiceDetail(props) {
|
|
|
3004
3126
|
}
|
|
3005
3127
|
) : null
|
|
3006
3128
|
] }),
|
|
3007
|
-
error ? /* @__PURE__ */
|
|
3008
|
-
/* @__PURE__ */
|
|
3129
|
+
error ? /* @__PURE__ */ jsx37(Alert, { tone: "error", children: error }) : null,
|
|
3130
|
+
/* @__PURE__ */ jsx37(
|
|
3009
3131
|
Button,
|
|
3010
3132
|
{
|
|
3011
3133
|
variant: "secondary",
|
|
@@ -3024,20 +3146,20 @@ function InvoiceDetail(props) {
|
|
|
3024
3146
|
}
|
|
3025
3147
|
|
|
3026
3148
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3027
|
-
import { jsx as
|
|
3149
|
+
import { jsx as jsx38, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
3028
3150
|
function InvoicesPanel(props) {
|
|
3029
3151
|
const a = useAppearance(props.appearance);
|
|
3030
3152
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3031
3153
|
const { t, locale } = useCopy(props.localization);
|
|
3032
3154
|
const { emailVerified } = useAuth();
|
|
3033
3155
|
const resource = useInvoices();
|
|
3034
|
-
const [openId, setOpenId] =
|
|
3156
|
+
const [openId, setOpenId] = useState18(null);
|
|
3035
3157
|
const variant = props.variant ?? "table";
|
|
3036
3158
|
const rowsVariant = variant === "rows";
|
|
3037
3159
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3038
3160
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3039
3161
|
if (openId) {
|
|
3040
|
-
return /* @__PURE__ */
|
|
3162
|
+
return /* @__PURE__ */ jsx38(
|
|
3041
3163
|
InvoiceDetail,
|
|
3042
3164
|
{
|
|
3043
3165
|
invoiceId: openId,
|
|
@@ -3047,7 +3169,7 @@ function InvoicesPanel(props) {
|
|
|
3047
3169
|
}
|
|
3048
3170
|
);
|
|
3049
3171
|
}
|
|
3050
|
-
return /* @__PURE__ */
|
|
3172
|
+
return /* @__PURE__ */ jsx38(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx38("div", { ...a.rootProps, children: /* @__PURE__ */ jsx38("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ jsx38(
|
|
3051
3173
|
PanelState,
|
|
3052
3174
|
{
|
|
3053
3175
|
resource,
|
|
@@ -3056,7 +3178,7 @@ function InvoicesPanel(props) {
|
|
|
3056
3178
|
isEmpty: (rows) => rows.length === 0,
|
|
3057
3179
|
emptyTitle: t.invoices.empty,
|
|
3058
3180
|
emptyDescription: t.invoices.emptyDescription,
|
|
3059
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3181
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx38(
|
|
3060
3182
|
DataTable,
|
|
3061
3183
|
{
|
|
3062
3184
|
tableKey: "invoicesPanel.table",
|
|
@@ -3067,24 +3189,24 @@ function InvoicesPanel(props) {
|
|
|
3067
3189
|
columns: [
|
|
3068
3190
|
{ key: "number", label: t.invoices.number },
|
|
3069
3191
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
3070
|
-
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */
|
|
3192
|
+
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ jsx38(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
|
|
3071
3193
|
{
|
|
3072
3194
|
key: "total",
|
|
3073
3195
|
label: t.invoices.total,
|
|
3074
|
-
render: (i) => /* @__PURE__ */
|
|
3196
|
+
render: (i) => /* @__PURE__ */ jsx38("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
3075
3197
|
}
|
|
3076
3198
|
]
|
|
3077
3199
|
}
|
|
3078
|
-
) : /* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
/* @__PURE__ */
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
/* @__PURE__ */
|
|
3200
|
+
) : /* @__PURE__ */ jsx38("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ jsxs29("div", { ...a.el("invoicesPanel.item", itemBase), children: [
|
|
3201
|
+
/* @__PURE__ */ jsxs29("div", { children: [
|
|
3202
|
+
/* @__PURE__ */ jsxs29("div", { className: "throttle-row", children: [
|
|
3203
|
+
/* @__PURE__ */ jsx38("strong", { children: i.number }),
|
|
3204
|
+
/* @__PURE__ */ jsx38(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
|
|
3083
3205
|
] }),
|
|
3084
|
-
/* @__PURE__ */
|
|
3085
|
-
/* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ jsx38("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
|
|
3207
|
+
/* @__PURE__ */ jsx38("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
|
|
3086
3208
|
] }),
|
|
3087
|
-
/* @__PURE__ */
|
|
3209
|
+
/* @__PURE__ */ jsx38("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx38(
|
|
3088
3210
|
Button,
|
|
3089
3211
|
{
|
|
3090
3212
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3099,7 +3221,7 @@ function InvoicesPanel(props) {
|
|
|
3099
3221
|
}
|
|
3100
3222
|
|
|
3101
3223
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3102
|
-
import { jsx as
|
|
3224
|
+
import { jsx as jsx39, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
3103
3225
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
3104
3226
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
3105
3227
|
var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
@@ -3121,8 +3243,8 @@ function SubscriptionsPanel(props) {
|
|
|
3121
3243
|
};
|
|
3122
3244
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3123
3245
|
const renewsLabel = (sub) => formatDate(sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd, locale);
|
|
3124
|
-
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */
|
|
3125
|
-
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */
|
|
3246
|
+
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ jsxs30("div", { className: "throttle-actions", children: [
|
|
3247
|
+
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ jsx39(
|
|
3126
3248
|
Button,
|
|
3127
3249
|
{
|
|
3128
3250
|
variant: variantFor("secondary"),
|
|
@@ -3132,7 +3254,7 @@ function SubscriptionsPanel(props) {
|
|
|
3132
3254
|
children: t.subscriptions.pauseButton
|
|
3133
3255
|
}
|
|
3134
3256
|
) : null,
|
|
3135
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */
|
|
3257
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ jsx39(
|
|
3136
3258
|
Button,
|
|
3137
3259
|
{
|
|
3138
3260
|
variant: variantFor("secondary"),
|
|
@@ -3142,7 +3264,7 @@ function SubscriptionsPanel(props) {
|
|
|
3142
3264
|
children: t.subscriptions.resumeButton
|
|
3143
3265
|
}
|
|
3144
3266
|
) : null,
|
|
3145
|
-
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3267
|
+
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx39(
|
|
3146
3268
|
Button,
|
|
3147
3269
|
{
|
|
3148
3270
|
variant: variantFor("secondary"),
|
|
@@ -3152,7 +3274,7 @@ function SubscriptionsPanel(props) {
|
|
|
3152
3274
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
3153
3275
|
}
|
|
3154
3276
|
) : null,
|
|
3155
|
-
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */
|
|
3277
|
+
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ jsx39(
|
|
3156
3278
|
Button,
|
|
3157
3279
|
{
|
|
3158
3280
|
variant: variantFor("danger"),
|
|
@@ -3163,9 +3285,9 @@ function SubscriptionsPanel(props) {
|
|
|
3163
3285
|
}
|
|
3164
3286
|
) : null
|
|
3165
3287
|
] });
|
|
3166
|
-
return /* @__PURE__ */
|
|
3167
|
-
error ? /* @__PURE__ */
|
|
3168
|
-
/* @__PURE__ */
|
|
3288
|
+
return /* @__PURE__ */ jsx39(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx39("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs30("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
|
|
3289
|
+
error ? /* @__PURE__ */ jsx39(Alert, { tone: "error", children: error }) : null,
|
|
3290
|
+
/* @__PURE__ */ jsx39(
|
|
3169
3291
|
PanelState,
|
|
3170
3292
|
{
|
|
3171
3293
|
resource,
|
|
@@ -3174,7 +3296,7 @@ function SubscriptionsPanel(props) {
|
|
|
3174
3296
|
isEmpty: (rows) => rows.length === 0,
|
|
3175
3297
|
emptyTitle: t.subscriptions.empty,
|
|
3176
3298
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
3177
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3299
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx39(
|
|
3178
3300
|
DataTable,
|
|
3179
3301
|
{
|
|
3180
3302
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -3183,42 +3305,42 @@ function SubscriptionsPanel(props) {
|
|
|
3183
3305
|
rows,
|
|
3184
3306
|
columns: [
|
|
3185
3307
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
3186
|
-
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */
|
|
3308
|
+
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ jsx39("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
3187
3309
|
{ key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
|
|
3188
|
-
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */
|
|
3189
|
-
/* @__PURE__ */
|
|
3190
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3310
|
+
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ jsxs30("div", { className: "throttle-row", children: [
|
|
3311
|
+
/* @__PURE__ */ jsx39(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
|
|
3312
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx39(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3191
3313
|
] }) },
|
|
3192
3314
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
3193
3315
|
]
|
|
3194
3316
|
}
|
|
3195
|
-
) : /* @__PURE__ */
|
|
3196
|
-
/* @__PURE__ */
|
|
3197
|
-
/* @__PURE__ */
|
|
3198
|
-
/* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */
|
|
3317
|
+
) : /* @__PURE__ */ jsx39("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ jsxs30("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
|
|
3318
|
+
/* @__PURE__ */ jsxs30("div", { children: [
|
|
3319
|
+
/* @__PURE__ */ jsxs30("div", { className: "throttle-row", children: [
|
|
3320
|
+
/* @__PURE__ */ jsx39("strong", { children: sub.planName ?? sub.planReference }),
|
|
3321
|
+
/* @__PURE__ */ jsx39(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
3200
3322
|
] }),
|
|
3201
|
-
/* @__PURE__ */
|
|
3323
|
+
/* @__PURE__ */ jsxs30("p", { className: "throttle-muted", children: [
|
|
3202
3324
|
formatMoney(sub.amount, sub.currency, locale),
|
|
3203
3325
|
" / ",
|
|
3204
3326
|
sub.interval,
|
|
3205
3327
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3206
3328
|
] }),
|
|
3207
|
-
sub.status === "cancelled" ? /* @__PURE__ */
|
|
3329
|
+
sub.status === "cancelled" ? /* @__PURE__ */ jsxs30("p", { className: "throttle-muted", children: [
|
|
3208
3330
|
t.subscriptions.cancelledOn,
|
|
3209
3331
|
" ",
|
|
3210
3332
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
3211
|
-
] }) : /* @__PURE__ */
|
|
3333
|
+
] }) : /* @__PURE__ */ jsxs30("p", { className: "throttle-muted", children: [
|
|
3212
3334
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
3213
3335
|
" ",
|
|
3214
3336
|
formatDate(sub.currentPeriodEnd, locale)
|
|
3215
3337
|
] }),
|
|
3216
|
-
sub.trialEnd ? /* @__PURE__ */
|
|
3338
|
+
sub.trialEnd ? /* @__PURE__ */ jsxs30("p", { className: "throttle-muted", children: [
|
|
3217
3339
|
t.subscriptions.trialEnds,
|
|
3218
3340
|
" ",
|
|
3219
3341
|
formatDate(sub.trialEnd, locale)
|
|
3220
3342
|
] }) : null,
|
|
3221
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3343
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx39(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3222
3344
|
] }),
|
|
3223
3345
|
lifecycleActions(sub, actionVariant)
|
|
3224
3346
|
] }, sub.id)) })
|
|
@@ -3228,7 +3350,7 @@ function SubscriptionsPanel(props) {
|
|
|
3228
3350
|
}
|
|
3229
3351
|
|
|
3230
3352
|
// src/react/components/account/SecurityPanel.tsx
|
|
3231
|
-
import { useCallback as useCallback2, useEffect as
|
|
3353
|
+
import { useCallback as useCallback2, useEffect as useEffect8, useRef as useRef7, useState as useState19 } from "react";
|
|
3232
3354
|
|
|
3233
3355
|
// src/react/components/account/device.ts
|
|
3234
3356
|
var BROWSERS = [
|
|
@@ -3261,7 +3383,7 @@ function describeDevice(userAgent) {
|
|
|
3261
3383
|
}
|
|
3262
3384
|
|
|
3263
3385
|
// src/react/components/account/SecurityPanel.tsx
|
|
3264
|
-
import { Fragment as Fragment9, jsx as
|
|
3386
|
+
import { Fragment as Fragment9, jsx as jsx40, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3265
3387
|
function SecurityPanel(props) {
|
|
3266
3388
|
const a = useAppearance(props.appearance);
|
|
3267
3389
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3271,13 +3393,13 @@ function SecurityPanel(props) {
|
|
|
3271
3393
|
const rowsVariant = variant === "rows";
|
|
3272
3394
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3273
3395
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
3274
|
-
const [password, setPassword] =
|
|
3396
|
+
const [password, setPassword] = useState19("");
|
|
3275
3397
|
const passwordAction = useAction();
|
|
3276
3398
|
const sessionAction = useAction();
|
|
3277
|
-
const [sessions, setSessions] =
|
|
3278
|
-
const [listError, setListError] =
|
|
3279
|
-
const errorMessageRef =
|
|
3280
|
-
|
|
3399
|
+
const [sessions, setSessions] = useState19(null);
|
|
3400
|
+
const [listError, setListError] = useState19(null);
|
|
3401
|
+
const errorMessageRef = useRef7(errorMessage);
|
|
3402
|
+
useEffect8(() => {
|
|
3281
3403
|
errorMessageRef.current = errorMessage;
|
|
3282
3404
|
});
|
|
3283
3405
|
const load = useCallback2(async () => {
|
|
@@ -3288,12 +3410,12 @@ function SecurityPanel(props) {
|
|
|
3288
3410
|
setListError(errorMessageRef.current(err));
|
|
3289
3411
|
}
|
|
3290
3412
|
}, [auth]);
|
|
3291
|
-
|
|
3413
|
+
useEffect8(() => {
|
|
3292
3414
|
void load();
|
|
3293
3415
|
}, [load]);
|
|
3294
3416
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
3295
|
-
return /* @__PURE__ */
|
|
3296
|
-
/* @__PURE__ */
|
|
3417
|
+
return /* @__PURE__ */ jsx40(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx40("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs31("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
|
|
3418
|
+
/* @__PURE__ */ jsxs31(
|
|
3297
3419
|
"form",
|
|
3298
3420
|
{
|
|
3299
3421
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -3306,8 +3428,8 @@ function SecurityPanel(props) {
|
|
|
3306
3428
|
});
|
|
3307
3429
|
},
|
|
3308
3430
|
children: [
|
|
3309
|
-
/* @__PURE__ */
|
|
3310
|
-
/* @__PURE__ */
|
|
3431
|
+
/* @__PURE__ */ jsx40("h3", { children: t.security.passwordTitle }),
|
|
3432
|
+
/* @__PURE__ */ jsx40(
|
|
3311
3433
|
Field,
|
|
3312
3434
|
{
|
|
3313
3435
|
label: t.security.newPassword,
|
|
@@ -3318,21 +3440,21 @@ function SecurityPanel(props) {
|
|
|
3318
3440
|
onChange: setPassword
|
|
3319
3441
|
}
|
|
3320
3442
|
),
|
|
3321
|
-
passwordAction.error ? /* @__PURE__ */
|
|
3322
|
-
passwordAction.notice ? /* @__PURE__ */
|
|
3323
|
-
/* @__PURE__ */
|
|
3443
|
+
passwordAction.error ? /* @__PURE__ */ jsx40(Alert, { tone: "error", children: passwordAction.error }) : null,
|
|
3444
|
+
passwordAction.notice ? /* @__PURE__ */ jsx40(Alert, { tone: "success", children: passwordAction.notice }) : null,
|
|
3445
|
+
/* @__PURE__ */ jsx40(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
|
|
3324
3446
|
]
|
|
3325
3447
|
}
|
|
3326
3448
|
),
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3329
|
-
listError ? /* @__PURE__ */
|
|
3330
|
-
/* @__PURE__ */
|
|
3331
|
-
/* @__PURE__ */
|
|
3449
|
+
/* @__PURE__ */ jsxs31("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
|
|
3450
|
+
/* @__PURE__ */ jsx40("h3", { children: t.security.sessionsTitle }),
|
|
3451
|
+
listError ? /* @__PURE__ */ jsxs31(Fragment9, { children: [
|
|
3452
|
+
/* @__PURE__ */ jsx40(Alert, { tone: "error", children: listError }),
|
|
3453
|
+
/* @__PURE__ */ jsx40(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
|
|
3332
3454
|
] }) : null,
|
|
3333
|
-
sessionAction.error ? /* @__PURE__ */
|
|
3334
|
-
sessions === null && !listError ? /* @__PURE__ */
|
|
3335
|
-
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */
|
|
3455
|
+
sessionAction.error ? /* @__PURE__ */ jsx40(Alert, { tone: "error", children: sessionAction.error }) : null,
|
|
3456
|
+
sessions === null && !listError ? /* @__PURE__ */ jsx40(Skeleton, { count: 2 }) : null,
|
|
3457
|
+
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ jsx40(
|
|
3336
3458
|
DataTable,
|
|
3337
3459
|
{
|
|
3338
3460
|
tableKey: "securityPanel.table",
|
|
@@ -3340,12 +3462,12 @@ function SecurityPanel(props) {
|
|
|
3340
3462
|
rowKey: (session) => session.id,
|
|
3341
3463
|
rows: sessions,
|
|
3342
3464
|
columns: [
|
|
3343
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */
|
|
3344
|
-
/* @__PURE__ */
|
|
3345
|
-
session.current ? /* @__PURE__ */
|
|
3465
|
+
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ jsxs31("div", { className: "throttle-row", children: [
|
|
3466
|
+
/* @__PURE__ */ jsx40("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
3467
|
+
session.current ? /* @__PURE__ */ jsx40(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3346
3468
|
] }) },
|
|
3347
3469
|
{ key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
|
|
3348
|
-
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */
|
|
3470
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ jsx40(
|
|
3349
3471
|
Button,
|
|
3350
3472
|
{
|
|
3351
3473
|
variant: "danger",
|
|
@@ -3360,19 +3482,19 @@ function SecurityPanel(props) {
|
|
|
3360
3482
|
) : null }
|
|
3361
3483
|
]
|
|
3362
3484
|
}
|
|
3363
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */
|
|
3364
|
-
/* @__PURE__ */
|
|
3365
|
-
/* @__PURE__ */
|
|
3366
|
-
/* @__PURE__ */
|
|
3367
|
-
session.current ? /* @__PURE__ */
|
|
3485
|
+
) : (sessions ?? []).map((session) => /* @__PURE__ */ jsxs31("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
|
|
3486
|
+
/* @__PURE__ */ jsxs31("div", { children: [
|
|
3487
|
+
/* @__PURE__ */ jsxs31("div", { className: "throttle-row", children: [
|
|
3488
|
+
/* @__PURE__ */ jsx40("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
3489
|
+
session.current ? /* @__PURE__ */ jsx40(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3368
3490
|
] }),
|
|
3369
|
-
/* @__PURE__ */
|
|
3491
|
+
/* @__PURE__ */ jsxs31("p", { className: "throttle-muted", children: [
|
|
3370
3492
|
t.security.lastActive,
|
|
3371
3493
|
" ",
|
|
3372
3494
|
formatDate(session.lastUsedAt, locale)
|
|
3373
3495
|
] })
|
|
3374
3496
|
] }),
|
|
3375
|
-
!session.current ? /* @__PURE__ */
|
|
3497
|
+
!session.current ? /* @__PURE__ */ jsx40(
|
|
3376
3498
|
Button,
|
|
3377
3499
|
{
|
|
3378
3500
|
variant: revokeVariant,
|
|
@@ -3386,8 +3508,8 @@ function SecurityPanel(props) {
|
|
|
3386
3508
|
}
|
|
3387
3509
|
) : null
|
|
3388
3510
|
] }, session.id)),
|
|
3389
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */
|
|
3390
|
-
others.length > 0 ? /* @__PURE__ */
|
|
3511
|
+
sessions !== null && others.length === 0 ? /* @__PURE__ */ jsx40("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
|
|
3512
|
+
others.length > 0 ? /* @__PURE__ */ jsx40(
|
|
3391
3513
|
Button,
|
|
3392
3514
|
{
|
|
3393
3515
|
variant: "danger",
|
|
@@ -3407,7 +3529,7 @@ function SecurityPanel(props) {
|
|
|
3407
3529
|
}
|
|
3408
3530
|
|
|
3409
3531
|
// src/react/components/account/AccountDashboard.tsx
|
|
3410
|
-
import { Fragment as Fragment10, jsx as
|
|
3532
|
+
import { Fragment as Fragment10, jsx as jsx41, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3411
3533
|
var ACCOUNT_TABS = [
|
|
3412
3534
|
"profile",
|
|
3413
3535
|
"addresses",
|
|
@@ -3436,9 +3558,9 @@ function AccountDashboard(props) {
|
|
|
3436
3558
|
const { status } = useAuth();
|
|
3437
3559
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
3438
3560
|
const controlled = props.tab !== void 0;
|
|
3439
|
-
const [internal, setInternal] =
|
|
3440
|
-
const idBase =
|
|
3441
|
-
|
|
3561
|
+
const [internal, setInternal] = useState20(shown[0] ?? "profile");
|
|
3562
|
+
const idBase = useId5();
|
|
3563
|
+
useEffect9(() => {
|
|
3442
3564
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
3443
3565
|
const apply = () => {
|
|
3444
3566
|
const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
|
|
@@ -3459,7 +3581,7 @@ function AccountDashboard(props) {
|
|
|
3459
3581
|
};
|
|
3460
3582
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
3461
3583
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
3462
|
-
const nav = /* @__PURE__ */
|
|
3584
|
+
const nav = /* @__PURE__ */ jsx41(
|
|
3463
3585
|
Tabs,
|
|
3464
3586
|
{
|
|
3465
3587
|
idBase,
|
|
@@ -3475,7 +3597,7 @@ function AccountDashboard(props) {
|
|
|
3475
3597
|
}))
|
|
3476
3598
|
}
|
|
3477
3599
|
);
|
|
3478
|
-
const panel = /* @__PURE__ */
|
|
3600
|
+
const panel = /* @__PURE__ */ jsxs32(
|
|
3479
3601
|
"div",
|
|
3480
3602
|
{
|
|
3481
3603
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -3484,36 +3606,36 @@ function AccountDashboard(props) {
|
|
|
3484
3606
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
3485
3607
|
tabIndex: 0,
|
|
3486
3608
|
children: [
|
|
3487
|
-
active === "profile" ? /* @__PURE__ */
|
|
3488
|
-
active === "addresses" ? /* @__PURE__ */
|
|
3489
|
-
active === "paymentMethods" ? /* @__PURE__ */
|
|
3490
|
-
active === "orders" ? /* @__PURE__ */
|
|
3491
|
-
active === "invoices" ? /* @__PURE__ */
|
|
3492
|
-
active === "subscriptions" ? /* @__PURE__ */
|
|
3493
|
-
active === "security" ? /* @__PURE__ */
|
|
3609
|
+
active === "profile" ? /* @__PURE__ */ jsx41(ProfilePanel, { ...shared }) : null,
|
|
3610
|
+
active === "addresses" ? /* @__PURE__ */ jsx41(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3611
|
+
active === "paymentMethods" ? /* @__PURE__ */ jsx41(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3612
|
+
active === "orders" ? /* @__PURE__ */ jsx41(OrdersPanel, { ...shared, variant: props.panelVariant, onViewSubscription: () => go("subscriptions") }) : null,
|
|
3613
|
+
active === "invoices" ? /* @__PURE__ */ jsx41(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3614
|
+
active === "subscriptions" ? /* @__PURE__ */ jsx41(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3615
|
+
active === "security" ? /* @__PURE__ */ jsx41(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
|
|
3494
3616
|
]
|
|
3495
3617
|
}
|
|
3496
3618
|
);
|
|
3497
|
-
return /* @__PURE__ */
|
|
3498
|
-
/* @__PURE__ */
|
|
3499
|
-
sidebar ? /* @__PURE__ */
|
|
3500
|
-
/* @__PURE__ */
|
|
3619
|
+
return /* @__PURE__ */ jsx41(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx41("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs32("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
|
|
3620
|
+
/* @__PURE__ */ jsx41(VerifyEmailBanner, { ...shared }),
|
|
3621
|
+
sidebar ? /* @__PURE__ */ jsxs32("div", { className: "throttle-account", children: [
|
|
3622
|
+
/* @__PURE__ */ jsx41("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
|
|
3501
3623
|
panel
|
|
3502
|
-
] }) : /* @__PURE__ */
|
|
3503
|
-
/* @__PURE__ */
|
|
3624
|
+
] }) : /* @__PURE__ */ jsxs32(Fragment10, { children: [
|
|
3625
|
+
/* @__PURE__ */ jsx41("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
3504
3626
|
panel
|
|
3505
3627
|
] })
|
|
3506
3628
|
] }) }) });
|
|
3507
3629
|
}
|
|
3508
3630
|
|
|
3509
3631
|
// src/react/components/account/AccountModal.tsx
|
|
3510
|
-
import { jsx as
|
|
3632
|
+
import { jsx as jsx42, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
3511
3633
|
function AccountModal(props) {
|
|
3512
3634
|
const a = useAppearance(props.appearance);
|
|
3513
3635
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3514
3636
|
const { t } = useCopy(props.localization);
|
|
3515
|
-
const titleId =
|
|
3516
|
-
return /* @__PURE__ */
|
|
3637
|
+
const titleId = useId6();
|
|
3638
|
+
return /* @__PURE__ */ jsx42(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsxs33(
|
|
3517
3639
|
Modal,
|
|
3518
3640
|
{
|
|
3519
3641
|
open: props.open,
|
|
@@ -3523,15 +3645,15 @@ function AccountModal(props) {
|
|
|
3523
3645
|
overlayKey: "accountModal.overlay",
|
|
3524
3646
|
containerKey: "accountModal.container",
|
|
3525
3647
|
children: [
|
|
3526
|
-
/* @__PURE__ */
|
|
3527
|
-
/* @__PURE__ */
|
|
3648
|
+
/* @__PURE__ */ jsx42("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ jsx42("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
|
|
3649
|
+
/* @__PURE__ */ jsx42("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ jsx42(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
|
|
3528
3650
|
]
|
|
3529
3651
|
}
|
|
3530
3652
|
) });
|
|
3531
3653
|
}
|
|
3532
3654
|
|
|
3533
3655
|
// src/react/components/provider.tsx
|
|
3534
|
-
import { jsx as
|
|
3656
|
+
import { jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3535
3657
|
var warned = /* @__PURE__ */ new Set();
|
|
3536
3658
|
function warnOnce(key, message) {
|
|
3537
3659
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -3576,14 +3698,14 @@ function ThrottleProvider(props) {
|
|
|
3576
3698
|
__captureStepUp
|
|
3577
3699
|
} = props;
|
|
3578
3700
|
useInjectStyles(injectStyles);
|
|
3579
|
-
const [stepUpOpen, setStepUpOpen] =
|
|
3580
|
-
const resolveStepUp =
|
|
3581
|
-
const claimRef =
|
|
3701
|
+
const [stepUpOpen, setStepUpOpen] = useState21(false);
|
|
3702
|
+
const resolveStepUp = useRef8(null);
|
|
3703
|
+
const claimRef = useRef8(claimCartOnSignIn);
|
|
3582
3704
|
claimRef.current = claimCartOnSignIn;
|
|
3583
|
-
const [overlay, setOverlay] =
|
|
3584
|
-
const overlayRestoreFocus =
|
|
3585
|
-
const [accountTabs, setAccountTabs] =
|
|
3586
|
-
const onOverlaySuccess =
|
|
3705
|
+
const [overlay, setOverlay] = useState21(null);
|
|
3706
|
+
const overlayRestoreFocus = useRef8(null);
|
|
3707
|
+
const [accountTabs, setAccountTabs] = useState21(void 0);
|
|
3708
|
+
const onOverlaySuccess = useRef8(null);
|
|
3587
3709
|
const openSignIn = useCallback3((onSuccess) => {
|
|
3588
3710
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
3589
3711
|
setOverlay("signIn");
|
|
@@ -3653,10 +3775,10 @@ function ThrottleProvider(props) {
|
|
|
3653
3775
|
resolve?.(password);
|
|
3654
3776
|
};
|
|
3655
3777
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
3656
|
-
return /* @__PURE__ */
|
|
3778
|
+
return /* @__PURE__ */ jsx43(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ jsx43(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ jsx43(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ jsx43(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ jsxs34(ThrottleUIContext.Provider, { value: ui, children: [
|
|
3657
3779
|
children,
|
|
3658
|
-
/* @__PURE__ */
|
|
3659
|
-
/* @__PURE__ */
|
|
3780
|
+
/* @__PURE__ */ jsx43(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
|
|
3781
|
+
/* @__PURE__ */ jsx43(
|
|
3660
3782
|
AuthModal,
|
|
3661
3783
|
{
|
|
3662
3784
|
open: authOverlayOpen,
|
|
@@ -3667,23 +3789,23 @@ function ThrottleProvider(props) {
|
|
|
3667
3789
|
},
|
|
3668
3790
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
3669
3791
|
),
|
|
3670
|
-
/* @__PURE__ */
|
|
3792
|
+
/* @__PURE__ */ jsx43(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
3671
3793
|
] }) }) }) }) });
|
|
3672
3794
|
}
|
|
3673
3795
|
|
|
3674
3796
|
// src/react/components/auth/SignInButton.tsx
|
|
3675
|
-
import { cloneElement, isValidElement, useContext as useContext6, useState as
|
|
3676
|
-
import { jsx as
|
|
3797
|
+
import { cloneElement, isValidElement, useContext as useContext6, useState as useState22 } from "react";
|
|
3798
|
+
import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3677
3799
|
function SignInButton(props) {
|
|
3678
3800
|
const a = useAppearance(props.appearance);
|
|
3679
3801
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3680
3802
|
const { t } = useCopy(props.localization);
|
|
3681
3803
|
const ui = useContext6(ThrottleUIContext);
|
|
3682
|
-
const [localOpen, setLocalOpen] =
|
|
3804
|
+
const [localOpen, setLocalOpen] = useState22(false);
|
|
3683
3805
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3684
3806
|
const label = props.children ?? t.signIn.submitButton;
|
|
3685
3807
|
if (props.mode === "redirect") {
|
|
3686
|
-
return /* @__PURE__ */
|
|
3808
|
+
return /* @__PURE__ */ jsx44(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx44("span", { ...a.rootProps, children: /* @__PURE__ */ jsx44("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
3687
3809
|
}
|
|
3688
3810
|
const openModal = () => {
|
|
3689
3811
|
if (useShared) ui.openSignIn(props.afterSignIn);
|
|
@@ -3693,10 +3815,10 @@ function SignInButton(props) {
|
|
|
3693
3815
|
if (useShared) ui.close();
|
|
3694
3816
|
else setLocalOpen(false);
|
|
3695
3817
|
};
|
|
3696
|
-
const trigger = props.asChild && isValidElement(props.children) ? cloneElement(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3697
|
-
return /* @__PURE__ */
|
|
3698
|
-
/* @__PURE__ */
|
|
3699
|
-
!useShared ? /* @__PURE__ */
|
|
3818
|
+
const trigger = props.asChild && isValidElement(props.children) ? cloneElement(props.children, { onClick: openModal }) : /* @__PURE__ */ jsx44(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
|
|
3819
|
+
return /* @__PURE__ */ jsxs35(AppearanceProvider, { value: scoped, children: [
|
|
3820
|
+
/* @__PURE__ */ jsx44("span", { ...a.rootProps, children: trigger }),
|
|
3821
|
+
!useShared ? /* @__PURE__ */ jsx44(
|
|
3700
3822
|
AuthModal,
|
|
3701
3823
|
{
|
|
3702
3824
|
open: localOpen,
|
|
@@ -3714,18 +3836,18 @@ function SignInButton(props) {
|
|
|
3714
3836
|
}
|
|
3715
3837
|
|
|
3716
3838
|
// src/react/components/auth/SignUpButton.tsx
|
|
3717
|
-
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useContext as useContext7, useState as
|
|
3718
|
-
import { jsx as
|
|
3839
|
+
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useContext as useContext7, useState as useState23 } from "react";
|
|
3840
|
+
import { jsx as jsx45, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
3719
3841
|
function SignUpButton(props) {
|
|
3720
3842
|
const a = useAppearance(props.appearance);
|
|
3721
3843
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3722
3844
|
const { t } = useCopy(props.localization);
|
|
3723
3845
|
const ui = useContext7(ThrottleUIContext);
|
|
3724
|
-
const [localOpen, setLocalOpen] =
|
|
3846
|
+
const [localOpen, setLocalOpen] = useState23(false);
|
|
3725
3847
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3726
3848
|
const label = props.children ?? t.signUp.submitButton;
|
|
3727
3849
|
if (props.mode === "redirect") {
|
|
3728
|
-
return /* @__PURE__ */
|
|
3850
|
+
return /* @__PURE__ */ jsx45(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx45("span", { ...a.rootProps, children: /* @__PURE__ */ jsx45("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
3729
3851
|
}
|
|
3730
3852
|
const openModal = () => {
|
|
3731
3853
|
if (useShared) ui.openSignUp(props.afterSignUp);
|
|
@@ -3735,10 +3857,10 @@ function SignUpButton(props) {
|
|
|
3735
3857
|
if (useShared) ui.close();
|
|
3736
3858
|
else setLocalOpen(false);
|
|
3737
3859
|
};
|
|
3738
|
-
const trigger = props.asChild && isValidElement2(props.children) ? cloneElement2(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3739
|
-
return /* @__PURE__ */
|
|
3740
|
-
/* @__PURE__ */
|
|
3741
|
-
!useShared ? /* @__PURE__ */
|
|
3860
|
+
const trigger = props.asChild && isValidElement2(props.children) ? cloneElement2(props.children, { onClick: openModal }) : /* @__PURE__ */ jsx45(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
|
|
3861
|
+
return /* @__PURE__ */ jsxs36(AppearanceProvider, { value: scoped, children: [
|
|
3862
|
+
/* @__PURE__ */ jsx45("span", { ...a.rootProps, children: trigger }),
|
|
3863
|
+
!useShared ? /* @__PURE__ */ jsx45(
|
|
3742
3864
|
AuthModal,
|
|
3743
3865
|
{
|
|
3744
3866
|
open: localOpen,
|
|
@@ -3756,14 +3878,14 @@ function SignUpButton(props) {
|
|
|
3756
3878
|
}
|
|
3757
3879
|
|
|
3758
3880
|
// src/react/components/auth/SignOutButton.tsx
|
|
3759
|
-
import { jsx as
|
|
3881
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
3760
3882
|
function SignOutButton(props) {
|
|
3761
3883
|
const a = useAppearance();
|
|
3762
3884
|
const { auth } = useAuth();
|
|
3763
3885
|
const { t } = useCopy(props.localization);
|
|
3764
3886
|
const { submitting, run } = useAction();
|
|
3765
3887
|
const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
|
|
3766
|
-
return /* @__PURE__ */
|
|
3888
|
+
return /* @__PURE__ */ jsx46("span", { ...a.rootProps, children: /* @__PURE__ */ jsx46(
|
|
3767
3889
|
Button,
|
|
3768
3890
|
{
|
|
3769
3891
|
variant: "secondary",
|
|
@@ -3780,13 +3902,13 @@ function SignOutButton(props) {
|
|
|
3780
3902
|
}
|
|
3781
3903
|
|
|
3782
3904
|
// src/react/components/auth/SignInPage.tsx
|
|
3783
|
-
import { jsx as
|
|
3905
|
+
import { jsx as jsx47, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
3784
3906
|
function SignInPage(props) {
|
|
3785
3907
|
const a = useAppearance(props.appearance);
|
|
3786
3908
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3787
|
-
return /* @__PURE__ */
|
|
3788
|
-
props.logo ? /* @__PURE__ */
|
|
3789
|
-
/* @__PURE__ */
|
|
3909
|
+
return /* @__PURE__ */ jsx47(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx47("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs37("div", { ...a.el("signInPage.root", "throttle-page"), children: [
|
|
3910
|
+
props.logo ? /* @__PURE__ */ jsx47("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
3911
|
+
/* @__PURE__ */ jsx47(
|
|
3790
3912
|
SignIn,
|
|
3791
3913
|
{
|
|
3792
3914
|
onSuccess: props.onSuccess,
|
|
@@ -3796,18 +3918,18 @@ function SignInPage(props) {
|
|
|
3796
3918
|
localization: props.localization
|
|
3797
3919
|
}
|
|
3798
3920
|
),
|
|
3799
|
-
props.footer ? /* @__PURE__ */
|
|
3921
|
+
props.footer ? /* @__PURE__ */ jsx47("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3800
3922
|
] }) }) });
|
|
3801
3923
|
}
|
|
3802
3924
|
|
|
3803
3925
|
// src/react/components/auth/SignUpPage.tsx
|
|
3804
|
-
import { jsx as
|
|
3926
|
+
import { jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
3805
3927
|
function SignUpPage(props) {
|
|
3806
3928
|
const a = useAppearance(props.appearance);
|
|
3807
3929
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3808
|
-
return /* @__PURE__ */
|
|
3809
|
-
props.logo ? /* @__PURE__ */
|
|
3810
|
-
/* @__PURE__ */
|
|
3930
|
+
return /* @__PURE__ */ jsx48(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx48("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs38("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
|
|
3931
|
+
props.logo ? /* @__PURE__ */ jsx48("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
3932
|
+
/* @__PURE__ */ jsx48(
|
|
3811
3933
|
SignUp,
|
|
3812
3934
|
{
|
|
3813
3935
|
onSuccess: props.onSuccess,
|
|
@@ -3816,42 +3938,42 @@ function SignUpPage(props) {
|
|
|
3816
3938
|
localization: props.localization
|
|
3817
3939
|
}
|
|
3818
3940
|
),
|
|
3819
|
-
props.footer ? /* @__PURE__ */
|
|
3941
|
+
props.footer ? /* @__PURE__ */ jsx48("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3820
3942
|
] }) }) });
|
|
3821
3943
|
}
|
|
3822
3944
|
|
|
3823
3945
|
// src/react/components/guards.tsx
|
|
3824
|
-
import { Fragment as Fragment11, jsx as
|
|
3946
|
+
import { Fragment as Fragment11, jsx as jsx49 } from "react/jsx-runtime";
|
|
3825
3947
|
function SignedIn(props) {
|
|
3826
3948
|
const { status } = useAuth();
|
|
3827
|
-
return status === "authenticated" ? /* @__PURE__ */
|
|
3949
|
+
return status === "authenticated" ? /* @__PURE__ */ jsx49(Fragment11, { children: props.children }) : null;
|
|
3828
3950
|
}
|
|
3829
3951
|
function SignedOut(props) {
|
|
3830
3952
|
const { status } = useAuth();
|
|
3831
|
-
return status === "unauthenticated" ? /* @__PURE__ */
|
|
3953
|
+
return status === "unauthenticated" ? /* @__PURE__ */ jsx49(Fragment11, { children: props.children }) : null;
|
|
3832
3954
|
}
|
|
3833
3955
|
function Protect(props) {
|
|
3834
3956
|
const { status, emailVerified } = useAuth();
|
|
3835
3957
|
if (status === "loading") return null;
|
|
3836
|
-
if (status !== "authenticated") return /* @__PURE__ */
|
|
3837
|
-
if (props.requireVerified && !emailVerified) return /* @__PURE__ */
|
|
3838
|
-
return /* @__PURE__ */
|
|
3958
|
+
if (status !== "authenticated") return /* @__PURE__ */ jsx49(Fragment11, { children: props.fallback ?? null });
|
|
3959
|
+
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ jsx49(Fragment11, { children: props.fallback ?? null });
|
|
3960
|
+
return /* @__PURE__ */ jsx49(Fragment11, { children: props.children });
|
|
3839
3961
|
}
|
|
3840
3962
|
|
|
3841
3963
|
// src/react/components/UserButton.tsx
|
|
3842
|
-
import { useContext as useContext8, useId as
|
|
3843
|
-
import { jsx as
|
|
3964
|
+
import { useContext as useContext8, useId as useId7, useRef as useRef9, useState as useState24 } from "react";
|
|
3965
|
+
import { jsx as jsx50, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
3844
3966
|
function UserButtonRoot(props) {
|
|
3845
3967
|
const a = useAppearance(props.appearance);
|
|
3846
3968
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3847
3969
|
const { t } = useCopy(props.localization);
|
|
3848
3970
|
const { auth, status, customer, emailVerified } = useAuth();
|
|
3849
3971
|
const ui = useContext8(ThrottleUIContext);
|
|
3850
|
-
const [localOpen, setLocalOpen] =
|
|
3972
|
+
const [localOpen, setLocalOpen] = useState24(false);
|
|
3851
3973
|
const accountOpen = ui ? false : localOpen;
|
|
3852
|
-
const titleId =
|
|
3853
|
-
const rootRef =
|
|
3854
|
-
const openerRef =
|
|
3974
|
+
const titleId = useId7();
|
|
3975
|
+
const rootRef = useRef9(null);
|
|
3976
|
+
const openerRef = useRef9(null);
|
|
3855
3977
|
const openAccount = () => {
|
|
3856
3978
|
const opener = rootRef.current?.querySelector('button[aria-haspopup="menu"]') ?? null;
|
|
3857
3979
|
openerRef.current = opener;
|
|
@@ -3860,25 +3982,25 @@ function UserButtonRoot(props) {
|
|
|
3860
3982
|
};
|
|
3861
3983
|
if (status !== "authenticated" || !customer) return null;
|
|
3862
3984
|
const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
|
|
3863
|
-
return /* @__PURE__ */
|
|
3864
|
-
/* @__PURE__ */
|
|
3985
|
+
return /* @__PURE__ */ jsx50(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx50("span", { ...a.rootProps, children: /* @__PURE__ */ jsxs39("span", { ref: rootRef, ...a.el("userButton.root"), children: [
|
|
3986
|
+
/* @__PURE__ */ jsxs39(
|
|
3865
3987
|
Dropdown,
|
|
3866
3988
|
{
|
|
3867
3989
|
label: t.userButton.openMenu,
|
|
3868
3990
|
triggerKey: "userButton.trigger",
|
|
3869
3991
|
menuKey: "userButton.menu",
|
|
3870
|
-
trigger: /* @__PURE__ */
|
|
3992
|
+
trigger: /* @__PURE__ */ jsx50(Avatar, { name, email: customer.email }),
|
|
3871
3993
|
children: [
|
|
3872
|
-
/* @__PURE__ */
|
|
3873
|
-
/* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */
|
|
3875
|
-
/* @__PURE__ */
|
|
3994
|
+
/* @__PURE__ */ jsx50("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ jsxs39("span", { children: [
|
|
3995
|
+
/* @__PURE__ */ jsx50("span", { ...a.el("userButton.email"), children: customer.email }),
|
|
3996
|
+
/* @__PURE__ */ jsx50("br", {}),
|
|
3997
|
+
/* @__PURE__ */ jsx50(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
|
|
3876
3998
|
] }) }),
|
|
3877
|
-
/* @__PURE__ */
|
|
3878
|
-
props.mode === "navigate" ? /* @__PURE__ */
|
|
3999
|
+
/* @__PURE__ */ jsx50(DropdownSeparator, {}),
|
|
4000
|
+
props.mode === "navigate" ? /* @__PURE__ */ jsx50(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ jsx50(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
|
|
3879
4001
|
props.children,
|
|
3880
|
-
/* @__PURE__ */
|
|
3881
|
-
/* @__PURE__ */
|
|
4002
|
+
/* @__PURE__ */ jsx50(DropdownSeparator, {}),
|
|
4003
|
+
/* @__PURE__ */ jsx50(
|
|
3882
4004
|
DropdownItem,
|
|
3883
4005
|
{
|
|
3884
4006
|
itemKey: "userButton.signOutButton",
|
|
@@ -3886,7 +4008,7 @@ function UserButtonRoot(props) {
|
|
|
3886
4008
|
children: t.userButton.signOut
|
|
3887
4009
|
}
|
|
3888
4010
|
),
|
|
3889
|
-
/* @__PURE__ */
|
|
4011
|
+
/* @__PURE__ */ jsx50(
|
|
3890
4012
|
DropdownItem,
|
|
3891
4013
|
{
|
|
3892
4014
|
itemKey: "userButton.signOutAllButton",
|
|
@@ -3897,7 +4019,7 @@ function UserButtonRoot(props) {
|
|
|
3897
4019
|
]
|
|
3898
4020
|
}
|
|
3899
4021
|
),
|
|
3900
|
-
props.mode !== "navigate" && !ui ? /* @__PURE__ */
|
|
4022
|
+
props.mode !== "navigate" && !ui ? /* @__PURE__ */ jsxs39(
|
|
3901
4023
|
Modal,
|
|
3902
4024
|
{
|
|
3903
4025
|
open: accountOpen,
|
|
@@ -3905,8 +4027,8 @@ function UserButtonRoot(props) {
|
|
|
3905
4027
|
labelledBy: titleId,
|
|
3906
4028
|
restoreFocusTo: openerRef.current,
|
|
3907
4029
|
children: [
|
|
3908
|
-
/* @__PURE__ */
|
|
3909
|
-
/* @__PURE__ */
|
|
4030
|
+
/* @__PURE__ */ jsx50("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
|
|
4031
|
+
/* @__PURE__ */ jsx50("div", { style: { padding: 16 }, children: /* @__PURE__ */ jsx50(
|
|
3910
4032
|
AccountDashboard,
|
|
3911
4033
|
{
|
|
3912
4034
|
tabs: props.tabs,
|
|
@@ -3920,13 +4042,13 @@ function UserButtonRoot(props) {
|
|
|
3920
4042
|
] }) }) });
|
|
3921
4043
|
}
|
|
3922
4044
|
function UserButtonLink(props) {
|
|
3923
|
-
return /* @__PURE__ */
|
|
4045
|
+
return /* @__PURE__ */ jsxs39(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
|
|
3924
4046
|
props.icon,
|
|
3925
4047
|
props.label
|
|
3926
4048
|
] });
|
|
3927
4049
|
}
|
|
3928
4050
|
function UserButtonAction(props) {
|
|
3929
|
-
return /* @__PURE__ */
|
|
4051
|
+
return /* @__PURE__ */ jsxs39(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
|
|
3930
4052
|
props.icon,
|
|
3931
4053
|
props.label
|
|
3932
4054
|
] });
|
|
@@ -3939,6 +4061,7 @@ export {
|
|
|
3939
4061
|
ACCOUNT_TABS,
|
|
3940
4062
|
AccountDashboard,
|
|
3941
4063
|
AccountModal,
|
|
4064
|
+
AddCardDialog,
|
|
3942
4065
|
AddressesPanel,
|
|
3943
4066
|
AuthFlow,
|
|
3944
4067
|
AuthModal,
|