@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
|
@@ -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
|
|
27
|
+
import { createContext as createContext6, useCallback as useCallback4, useContext as useContext6, useMemo as useMemo4, useRef as useRef9, useState as useState22 } from "react";
|
|
28
28
|
|
|
29
29
|
// src/react/components/appearance.tsx
|
|
30
30
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -140,6 +140,16 @@ 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
|
+
// How wide the auth card (sign-in, sign-up, forgot-password) is allowed
|
|
148
|
+
// to grow. It was pinned at 400px, which is narrow for a page that is
|
|
149
|
+
// nothing but that card.
|
|
150
|
+
cardWidth: "--throttle-card-width",
|
|
151
|
+
accountSurface: "--throttle-color-account-surface",
|
|
152
|
+
accountPadding: "--throttle-account-padding",
|
|
143
153
|
shadowCard: "--throttle-shadow-card",
|
|
144
154
|
shadowPopover: "--throttle-shadow-popover",
|
|
145
155
|
transition: "--throttle-transition",
|
|
@@ -274,6 +284,20 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
274
284
|
"paymentMethodsPanel.item",
|
|
275
285
|
"paymentMethodsPanel.defaultButton",
|
|
276
286
|
"paymentMethodsPanel.deleteButton",
|
|
287
|
+
"paymentMethodsPanel.addButton",
|
|
288
|
+
"paymentMethodsPanel.addDialog",
|
|
289
|
+
"orderDetail.addresses",
|
|
290
|
+
"orderDetail.shippingAddress",
|
|
291
|
+
"orderDetail.billingAddress",
|
|
292
|
+
"orderDetail.timeline",
|
|
293
|
+
"orderDetail.payButton",
|
|
294
|
+
"orderDetail.trackButton",
|
|
295
|
+
"orderDetail.reorderButton",
|
|
296
|
+
"confirm.header",
|
|
297
|
+
"confirm.title",
|
|
298
|
+
"confirm.body",
|
|
299
|
+
"confirm.confirmButton",
|
|
300
|
+
"confirm.cancelButton",
|
|
277
301
|
"paymentMethodsPanel.table",
|
|
278
302
|
"paymentMethodsPanel.row",
|
|
279
303
|
"ordersPanel.root",
|
|
@@ -387,6 +411,9 @@ var enUS = {
|
|
|
387
411
|
loading: "Loading\u2026",
|
|
388
412
|
close: "Close",
|
|
389
413
|
confirm: "Are you sure?",
|
|
414
|
+
// The dismissive half of a confirmation. "Cancel" is ambiguous next to
|
|
415
|
+
// "Cancel subscription" — one dismisses the dialog, the other ends the plan.
|
|
416
|
+
keepIt: "Keep it",
|
|
390
417
|
somethingWentWrong: "Something went wrong.",
|
|
391
418
|
actions: "Actions",
|
|
392
419
|
view: "View"
|
|
@@ -484,6 +511,7 @@ var enUS = {
|
|
|
484
511
|
addButton: "Add address",
|
|
485
512
|
defaultBadge: "Default",
|
|
486
513
|
makeDefault: "Make default",
|
|
514
|
+
deleteConfirmAction: "Delete address",
|
|
487
515
|
empty: "No saved addresses",
|
|
488
516
|
emptyDescription: "Addresses you use at checkout can be saved here.",
|
|
489
517
|
label: "Label",
|
|
@@ -502,8 +530,9 @@ var enUS = {
|
|
|
502
530
|
},
|
|
503
531
|
paymentMethods: {
|
|
504
532
|
empty: "No saved cards",
|
|
505
|
-
|
|
506
|
-
|
|
533
|
+
emptyDescription: "Add a card here, or one will be saved when you check out.",
|
|
534
|
+
addButton: "Add card",
|
|
535
|
+
addTitle: "Add a card",
|
|
507
536
|
// Shown whenever the panel is empty with no error and the buyer is not
|
|
508
537
|
// verified — including simply being signed out — matching the copy
|
|
509
538
|
// orders/invoices/subscriptions already show in that state.
|
|
@@ -512,9 +541,20 @@ var enUS = {
|
|
|
512
541
|
makeDefault: "Make default",
|
|
513
542
|
expires: "Expires",
|
|
514
543
|
deleteConfirm: "Remove this card?",
|
|
544
|
+
deleteConfirmAction: "Remove card",
|
|
515
545
|
columnCard: "Card"
|
|
516
546
|
},
|
|
517
547
|
orders: {
|
|
548
|
+
shipTo: "Ship to",
|
|
549
|
+
billTo: "Bill to",
|
|
550
|
+
history: "History",
|
|
551
|
+
placed: "Order placed",
|
|
552
|
+
completed: "Completed",
|
|
553
|
+
cancelledAt: "Cancelled",
|
|
554
|
+
closedAt: "Closed",
|
|
555
|
+
payNow: "Pay now",
|
|
556
|
+
track: "Track shipment",
|
|
557
|
+
reorder: "Order again",
|
|
518
558
|
empty: "No orders yet",
|
|
519
559
|
emptyDescription: "Orders you place will appear here.",
|
|
520
560
|
gatedDescription: "Verify your email to see your order history.",
|
|
@@ -583,6 +623,12 @@ var enUS = {
|
|
|
583
623
|
downloadUnavailable: "This invoice is not available to download right now."
|
|
584
624
|
},
|
|
585
625
|
subscriptions: {
|
|
626
|
+
cancelConfirmAction: "Cancel plan",
|
|
627
|
+
pauseConfirm: "Pause this subscription?",
|
|
628
|
+
resumeConfirm: "Resume this subscription?",
|
|
629
|
+
// Distinct from cancelConfirm: ending it now is not the same promise as
|
|
630
|
+
// letting it run to the end of a period the buyer already paid for.
|
|
631
|
+
cancelNowConfirm: "End this subscription immediately?",
|
|
586
632
|
empty: "No subscriptions",
|
|
587
633
|
emptyDescription: "Subscriptions will appear here.",
|
|
588
634
|
gatedDescription: "Verify your email to see your subscriptions.",
|
|
@@ -700,6 +746,13 @@ var THROTTLE_STYLES = `
|
|
|
700
746
|
edges, table rules, dividers) keep --throttle-color-border: they do not
|
|
701
747
|
identify a control, so the requirement does not apply and darkening
|
|
702
748
|
them would only add noise. */
|
|
749
|
+
/* The account dashboard paints nothing by default so it can drop into a
|
|
750
|
+
merchant's page without fighting their background. The accountSurface and
|
|
751
|
+
accountPadding appearance variables opt back into a card.
|
|
752
|
+
No backticks in this comment: the sheet is a TS template literal. */
|
|
753
|
+
--throttle-card-width: 400px;
|
|
754
|
+
--throttle-color-account-surface: transparent;
|
|
755
|
+
--throttle-account-padding: 0;
|
|
703
756
|
--throttle-color-border-control: #8b93a1;
|
|
704
757
|
--throttle-color-danger: #c2321f;
|
|
705
758
|
--throttle-color-danger-surface: #fef2f2;
|
|
@@ -798,7 +851,7 @@ var THROTTLE_STYLES = `
|
|
|
798
851
|
box-shadow: var(--throttle-shadow-card);
|
|
799
852
|
padding: var(--throttle-space-5);
|
|
800
853
|
width: 100%;
|
|
801
|
-
max-width:
|
|
854
|
+
max-width: var(--throttle-card-width);
|
|
802
855
|
margin-inline: auto;
|
|
803
856
|
}
|
|
804
857
|
/* Inside a Modal the dialog already provides the surface \u2014 background, radius
|
|
@@ -848,7 +901,13 @@ var THROTTLE_STYLES = `
|
|
|
848
901
|
/* Always mounted, so it reserves its line whether or not there is an error:
|
|
849
902
|
an error appearing on submit must not push the submit button out from
|
|
850
903
|
under the buyer's pointer. */
|
|
851
|
-
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs);
|
|
904
|
+
.throttle-field__error { color: var(--throttle-color-danger); font-size: var(--throttle-font-size-xs); line-height: 1rem; }
|
|
905
|
+
/* Reserved a full line under EVERY input even with nothing to say, which
|
|
906
|
+
with the stack gap put 28px of dead space beneath each field, on every
|
|
907
|
+
form and all seven account panels. The element stays mounted when empty
|
|
908
|
+
because role=alert only announces changes to a live region that was
|
|
909
|
+
already there; it just stops occupying a line. */
|
|
910
|
+
.throttle-field__error:empty { display: none; }
|
|
852
911
|
|
|
853
912
|
.throttle-field-group {
|
|
854
913
|
display: flex;
|
|
@@ -907,6 +966,11 @@ var THROTTLE_STYLES = `
|
|
|
907
966
|
animation: throttle-spin 700ms linear infinite;
|
|
908
967
|
}
|
|
909
968
|
@keyframes throttle-spin { to { transform: rotate(360deg); } }
|
|
969
|
+
.throttle-button--loading { position: relative; }
|
|
970
|
+
.throttle-button__label { display: inline-flex; align-items: center; justify-content: center; gap: var(--throttle-space-2); }
|
|
971
|
+
.throttle-button__label--hidden { visibility: hidden; }
|
|
972
|
+
.throttle-spinner--centred { position: absolute; top: 50%; left: 50%; margin: -0.5em 0 0 -0.5em; }
|
|
973
|
+
|
|
910
974
|
@media (prefers-reduced-motion: reduce) { .throttle-spinner { animation-duration: 2.4s; } }
|
|
911
975
|
|
|
912
976
|
.throttle-skeleton {
|
|
@@ -989,7 +1053,16 @@ var THROTTLE_STYLES = `
|
|
|
989
1053
|
/* Paints its own ground. A UserButton in a navbar should stay transparent, but
|
|
990
1054
|
the dashboard is a large surface of themed text: in dark theme its foreground
|
|
991
1055
|
is near-white, so on a light host page it was rendering white-on-white. */
|
|
992
|
-
.throttle-
|
|
1056
|
+
.throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
|
|
1057
|
+
.throttle-centre { display: flex; align-items: center; justify-content: center; min-height: 160px; }
|
|
1058
|
+
.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; }
|
|
1059
|
+
.throttle-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: var(--throttle-space-5); }
|
|
1060
|
+
.throttle-addressblock__line { margin: 0 0 2px; }
|
|
1061
|
+
.throttle-timeline { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
|
|
1062
|
+
.throttle-timeline__row { display: flex; align-items: center; gap: var(--throttle-space-2); }
|
|
1063
|
+
.throttle-timeline__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--throttle-color-border-control); flex: none; }
|
|
1064
|
+
.throttle-timeline__label { flex: 1; }
|
|
1065
|
+
.throttle-account-root { container-type: inline-size; background: var(--throttle-color-account-surface); color: var(--throttle-color-foreground); padding: var(--throttle-account-padding); }
|
|
993
1066
|
.throttle-account { display: flex; gap: var(--throttle-space-5); align-items: flex-start; }
|
|
994
1067
|
.throttle-account__content { flex: 1; min-width: 0; }
|
|
995
1068
|
.throttle-tabs__rail { flex: none; width: 220px; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -1026,6 +1099,7 @@ var THROTTLE_STYLES = `
|
|
|
1026
1099
|
it shrinks the rail to its content width, so width:100% alone cannot make
|
|
1027
1100
|
it span. Stretch it explicitly when stacked. */
|
|
1028
1101
|
.throttle-account { flex-direction: column; align-items: stretch; gap: var(--throttle-space-4); }
|
|
1102
|
+
.throttle-addresses { grid-template-columns: 1fr; }
|
|
1029
1103
|
.throttle-tabs__rail { width: 100%; }
|
|
1030
1104
|
}
|
|
1031
1105
|
|
|
@@ -1128,61 +1202,45 @@ function useInjectStyles(enabled) {
|
|
|
1128
1202
|
}, [enabled]);
|
|
1129
1203
|
}
|
|
1130
1204
|
|
|
1131
|
-
// src/react/components/auth/StepUpDialog.tsx
|
|
1132
|
-
import { useEffect as useEffect3, useId as useId2, useState as useState3 } from "react";
|
|
1133
|
-
|
|
1134
|
-
// src/react/components/surface.tsx
|
|
1135
|
-
import { createContext as createContext4, useContext as useContext4 } from "react";
|
|
1136
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1137
|
-
var Ctx4 = createContext4("standalone");
|
|
1138
|
-
function SurfaceProvider(props) {
|
|
1139
|
-
return /* @__PURE__ */ jsx4(Ctx4.Provider, { value: props.value, children: props.children });
|
|
1140
|
-
}
|
|
1141
|
-
function useSurface() {
|
|
1142
|
-
return useContext4(Ctx4);
|
|
1143
|
-
}
|
|
1144
|
-
function useCardClass() {
|
|
1145
|
-
return useSurface() === "modal" ? "throttle-card throttle-card--bare" : "throttle-card";
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
1205
|
// src/react/components/primitives/Card.tsx
|
|
1149
|
-
import { jsx as
|
|
1206
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1150
1207
|
function CardHeader(props) {
|
|
1151
1208
|
const a = useAppearance();
|
|
1152
1209
|
const headerClass = `throttle-card__header${props.branded ? " throttle-card__header--branded" : ""}`;
|
|
1153
1210
|
const titleClass = `throttle-card__title${props.branded ? " throttle-card__title--branded" : ""}`;
|
|
1154
1211
|
return /* @__PURE__ */ jsxs("div", { ...a.el("card.header", headerClass), children: [
|
|
1155
|
-
props.logo ? /* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
props.description ? /* @__PURE__ */
|
|
1212
|
+
props.logo ? /* @__PURE__ */ jsx4("div", { ...a.el(props.logoKey ?? "card.logo", "throttle-card__logo"), children: props.logo }) : null,
|
|
1213
|
+
/* @__PURE__ */ jsx4("h2", { ...a.el(props.titleKey ?? "card.title", titleClass), children: props.title }),
|
|
1214
|
+
props.description ? /* @__PURE__ */ jsx4("p", { ...a.el("card.description", "throttle-card__description"), children: props.description }) : null
|
|
1158
1215
|
] });
|
|
1159
1216
|
}
|
|
1160
1217
|
function CardBody(props) {
|
|
1161
1218
|
const a = useAppearance();
|
|
1162
|
-
return /* @__PURE__ */
|
|
1219
|
+
return /* @__PURE__ */ jsx4("div", { ...a.el("card.body", "throttle-card__body"), children: props.children });
|
|
1163
1220
|
}
|
|
1164
1221
|
function CardFooter(props) {
|
|
1165
1222
|
const a = useAppearance();
|
|
1166
1223
|
const className = `throttle-card__footer${props.ruled ? " throttle-card__footer--ruled" : ""}`;
|
|
1167
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx4("div", { ...a.el("card.footer", className), children: props.children });
|
|
1168
1225
|
}
|
|
1169
1226
|
|
|
1170
1227
|
// src/react/components/primitives/Spinner.tsx
|
|
1171
|
-
import { jsx as
|
|
1172
|
-
function Spinner() {
|
|
1228
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1229
|
+
function Spinner({ centred } = {}) {
|
|
1173
1230
|
const a = useAppearance();
|
|
1174
1231
|
const Slot = a.slots.Spinner;
|
|
1175
|
-
if (Slot) return /* @__PURE__ */
|
|
1176
|
-
|
|
1232
|
+
if (Slot) return /* @__PURE__ */ jsx5(Slot, {});
|
|
1233
|
+
const cls = `throttle-spinner${centred ? " throttle-spinner--centred" : ""}`;
|
|
1234
|
+
return /* @__PURE__ */ jsx5("span", { ...a.el("spinner", cls), "aria-hidden": "true" });
|
|
1177
1235
|
}
|
|
1178
1236
|
|
|
1179
1237
|
// src/react/components/primitives/Button.tsx
|
|
1180
|
-
import { jsx as
|
|
1238
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1181
1239
|
function Button({ variant = "primary", size = "default", elementKey, loading, children, ...rest }) {
|
|
1182
1240
|
const a = useAppearance();
|
|
1183
1241
|
const Slot = a.slots.Button;
|
|
1184
|
-
if (Slot) return /* @__PURE__ */
|
|
1185
|
-
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}`;
|
|
1242
|
+
if (Slot) return /* @__PURE__ */ jsx6(Slot, { variant, loading, ...rest, children });
|
|
1243
|
+
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}${loading ? " throttle-button--loading" : ""}`;
|
|
1186
1244
|
return /* @__PURE__ */ jsxs2(
|
|
1187
1245
|
"button",
|
|
1188
1246
|
{
|
|
@@ -1190,9 +1248,10 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1190
1248
|
...rest,
|
|
1191
1249
|
...a.el(elementKey ?? "button", base),
|
|
1192
1250
|
disabled: rest.disabled || loading,
|
|
1251
|
+
"aria-busy": loading ? true : void 0,
|
|
1193
1252
|
children: [
|
|
1194
|
-
loading ? /* @__PURE__ */
|
|
1195
|
-
children
|
|
1253
|
+
loading ? /* @__PURE__ */ jsx6(Spinner, { centred: true }) : null,
|
|
1254
|
+
/* @__PURE__ */ jsx6("span", { className: `throttle-button__label${loading ? " throttle-button__label--hidden" : ""}`, children })
|
|
1196
1255
|
]
|
|
1197
1256
|
}
|
|
1198
1257
|
);
|
|
@@ -1200,7 +1259,7 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1200
1259
|
|
|
1201
1260
|
// src/react/components/primitives/Field.tsx
|
|
1202
1261
|
import { Children, Fragment, useId } from "react";
|
|
1203
|
-
import { jsx as
|
|
1262
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1204
1263
|
function Field(props) {
|
|
1205
1264
|
const a = useAppearance();
|
|
1206
1265
|
const base = useId();
|
|
@@ -1208,13 +1267,13 @@ function Field(props) {
|
|
|
1208
1267
|
const hintId = `${base}-hint`;
|
|
1209
1268
|
const errorId = `${base}-error`;
|
|
1210
1269
|
const describedBy = [props.hint ? hintId : null, props.error ? errorId : null].filter(Boolean).join(" ");
|
|
1211
|
-
const label = /* @__PURE__ */
|
|
1270
|
+
const label = /* @__PURE__ */ jsx7("label", { ...a.el("field.label", "throttle-field__label"), htmlFor: inputId, children: props.label });
|
|
1212
1271
|
return /* @__PURE__ */ jsxs3("div", { ...a.el(props.elementKey ?? "field", "throttle-field"), children: [
|
|
1213
1272
|
props.labelExtra ? /* @__PURE__ */ jsxs3("div", { className: "throttle-field__labelrow", children: [
|
|
1214
1273
|
label,
|
|
1215
1274
|
props.labelExtra
|
|
1216
1275
|
] }) : label,
|
|
1217
|
-
/* @__PURE__ */
|
|
1276
|
+
/* @__PURE__ */ jsx7(
|
|
1218
1277
|
"input",
|
|
1219
1278
|
{
|
|
1220
1279
|
...a.el("field.input", `throttle-field__input${props.grouped ? " throttle-field__input--grouped" : ""}`),
|
|
@@ -1230,26 +1289,26 @@ function Field(props) {
|
|
|
1230
1289
|
onChange: (e) => props.onChange(e.target.value)
|
|
1231
1290
|
}
|
|
1232
1291
|
),
|
|
1233
|
-
props.hint ? /* @__PURE__ */
|
|
1234
|
-
/* @__PURE__ */
|
|
1292
|
+
props.hint ? /* @__PURE__ */ jsx7("span", { ...a.el("field.hint", "throttle-field__hint"), id: hintId, children: props.hint }) : null,
|
|
1293
|
+
/* @__PURE__ */ jsx7("span", { ...a.el("field.error", "throttle-field__error"), id: errorId, role: "alert", children: props.error ?? "" })
|
|
1235
1294
|
] });
|
|
1236
1295
|
}
|
|
1237
1296
|
function FieldGroup(props) {
|
|
1238
1297
|
const a = useAppearance();
|
|
1239
1298
|
const items = Children.toArray(props.children).filter(Boolean);
|
|
1240
|
-
return /* @__PURE__ */
|
|
1241
|
-
i > 0 ? /* @__PURE__ */
|
|
1242
|
-
/* @__PURE__ */
|
|
1299
|
+
return /* @__PURE__ */ jsx7("div", { ...a.el(props.elementKey ?? "field.group", "throttle-field-group"), children: items.map((child, i) => /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
1300
|
+
i > 0 ? /* @__PURE__ */ jsx7("div", { className: "throttle-field-group__divider" }) : null,
|
|
1301
|
+
/* @__PURE__ */ jsx7("div", { className: "throttle-field-group__item", children: child })
|
|
1243
1302
|
] }, i)) });
|
|
1244
1303
|
}
|
|
1245
1304
|
|
|
1246
1305
|
// src/react/components/primitives/Alert.tsx
|
|
1247
|
-
import { jsx as
|
|
1306
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1248
1307
|
function Alert(props) {
|
|
1249
1308
|
const a = useAppearance();
|
|
1250
1309
|
const Slot = a.slots.Alert;
|
|
1251
|
-
if (Slot) return /* @__PURE__ */
|
|
1252
|
-
return /* @__PURE__ */
|
|
1310
|
+
if (Slot) return /* @__PURE__ */ jsx8(Slot, { tone: props.tone, children: props.children });
|
|
1311
|
+
return /* @__PURE__ */ jsx8(
|
|
1253
1312
|
"p",
|
|
1254
1313
|
{
|
|
1255
1314
|
...a.el("alert", `throttle-alert throttle-alert--${props.tone}`),
|
|
@@ -1260,16 +1319,32 @@ function Alert(props) {
|
|
|
1260
1319
|
}
|
|
1261
1320
|
|
|
1262
1321
|
// src/react/components/primitives/Skeleton.tsx
|
|
1263
|
-
import { jsx as
|
|
1322
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1264
1323
|
function Skeleton(props) {
|
|
1265
1324
|
const a = useAppearance();
|
|
1266
1325
|
const rows = Array.from({ length: props.count ?? 1 });
|
|
1267
|
-
return /* @__PURE__ */
|
|
1326
|
+
return /* @__PURE__ */ jsx9("div", { "aria-hidden": "true", className: "throttle-stack", children: rows.map((_, i) => /* @__PURE__ */ jsx9("span", { ...a.el("skeleton", "throttle-skeleton") }, i)) });
|
|
1268
1327
|
}
|
|
1269
1328
|
|
|
1270
1329
|
// src/react/components/primitives/Modal.tsx
|
|
1271
1330
|
import { useEffect, useRef, useState } from "react";
|
|
1272
1331
|
import { createPortal } from "react-dom";
|
|
1332
|
+
|
|
1333
|
+
// src/react/components/surface.tsx
|
|
1334
|
+
import { createContext as createContext4, useContext as useContext4 } from "react";
|
|
1335
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1336
|
+
var Ctx4 = createContext4("standalone");
|
|
1337
|
+
function SurfaceProvider(props) {
|
|
1338
|
+
return /* @__PURE__ */ jsx10(Ctx4.Provider, { value: props.value, children: props.children });
|
|
1339
|
+
}
|
|
1340
|
+
function useSurface() {
|
|
1341
|
+
return useContext4(Ctx4);
|
|
1342
|
+
}
|
|
1343
|
+
function useCardClass() {
|
|
1344
|
+
return useSurface() === "modal" ? "throttle-card throttle-card--bare" : "throttle-card";
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// src/react/components/primitives/Modal.tsx
|
|
1273
1348
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1274
1349
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1275
1350
|
function Modal(props) {
|
|
@@ -1359,15 +1434,68 @@ function Modal(props) {
|
|
|
1359
1434
|
);
|
|
1360
1435
|
}
|
|
1361
1436
|
|
|
1362
|
-
// src/react/components/primitives/
|
|
1363
|
-
import {
|
|
1437
|
+
// src/react/components/primitives/Confirm.tsx
|
|
1438
|
+
import { createContext as createContext5, useCallback, useContext as useContext5, useId as useId2, useMemo as useMemo3, useRef as useRef2, useState as useState2 } from "react";
|
|
1364
1439
|
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1440
|
+
var ConfirmContext = createContext5(null);
|
|
1441
|
+
function ConfirmProvider({ children }) {
|
|
1442
|
+
const [request, setRequest] = useState2(null);
|
|
1443
|
+
const { t } = useCopy();
|
|
1444
|
+
const a = useAppearance();
|
|
1445
|
+
const titleId = useId2();
|
|
1446
|
+
const settle = useRef2(null);
|
|
1447
|
+
const answer = useCallback((value) => {
|
|
1448
|
+
settle.current?.(value);
|
|
1449
|
+
settle.current = null;
|
|
1450
|
+
setRequest(null);
|
|
1451
|
+
}, []);
|
|
1452
|
+
const ask = useCallback((next) => {
|
|
1453
|
+
settle.current?.(false);
|
|
1454
|
+
setRequest(next);
|
|
1455
|
+
return new Promise((resolve) => {
|
|
1456
|
+
settle.current = resolve;
|
|
1457
|
+
});
|
|
1458
|
+
}, []);
|
|
1459
|
+
return /* @__PURE__ */ jsxs5(ConfirmContext.Provider, { value: ask, children: [
|
|
1460
|
+
children,
|
|
1461
|
+
request ? /* @__PURE__ */ jsxs5(Modal, { open: true, onClose: () => answer(false), labelledBy: titleId, size: "compact", children: [
|
|
1462
|
+
/* @__PURE__ */ jsx12("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ jsx12("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request.title }) }),
|
|
1463
|
+
/* @__PURE__ */ jsxs5("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
|
|
1464
|
+
request.body ? /* @__PURE__ */ jsx12("p", { className: "throttle-muted", children: request.body }) : null,
|
|
1465
|
+
/* @__PURE__ */ jsxs5("div", { className: "throttle-actions", children: [
|
|
1466
|
+
/* @__PURE__ */ jsx12(
|
|
1467
|
+
Button,
|
|
1468
|
+
{
|
|
1469
|
+
elementKey: "confirm.confirmButton",
|
|
1470
|
+
variant: request.tone === "danger" ? "danger" : "primary",
|
|
1471
|
+
onClick: () => answer(true),
|
|
1472
|
+
children: request.confirmLabel ?? t.common.delete
|
|
1473
|
+
}
|
|
1474
|
+
),
|
|
1475
|
+
/* @__PURE__ */ jsx12(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request.cancelLabel ?? t.common.keepIt })
|
|
1476
|
+
] })
|
|
1477
|
+
] })
|
|
1478
|
+
] }) : null
|
|
1479
|
+
] });
|
|
1480
|
+
}
|
|
1481
|
+
function useConfirm() {
|
|
1482
|
+
const ask = useContext5(ConfirmContext);
|
|
1483
|
+
const { t } = useCopy();
|
|
1484
|
+
return useMemo3(
|
|
1485
|
+
() => ask ?? (async (request) => window.confirm(request.title || t.common.confirm)),
|
|
1486
|
+
[ask, t]
|
|
1487
|
+
);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// src/react/components/primitives/Dropdown.tsx
|
|
1491
|
+
import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
|
|
1492
|
+
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1365
1493
|
function Dropdown(props) {
|
|
1366
1494
|
const a = useAppearance();
|
|
1367
|
-
const [open, setOpen] =
|
|
1368
|
-
const root =
|
|
1369
|
-
const trigger =
|
|
1370
|
-
const menu =
|
|
1495
|
+
const [open, setOpen] = useState3(false);
|
|
1496
|
+
const root = useRef3(null);
|
|
1497
|
+
const trigger = useRef3(null);
|
|
1498
|
+
const menu = useRef3(null);
|
|
1371
1499
|
useEffect2(() => {
|
|
1372
1500
|
if (!open) return;
|
|
1373
1501
|
menu.current?.querySelector('[role="menuitem"]')?.focus();
|
|
@@ -1394,8 +1522,8 @@ function Dropdown(props) {
|
|
|
1394
1522
|
const next = (at + delta + items.length) % items.length;
|
|
1395
1523
|
items[next < 0 ? items.length - 1 : next].focus();
|
|
1396
1524
|
};
|
|
1397
|
-
return /* @__PURE__ */
|
|
1398
|
-
/* @__PURE__ */
|
|
1525
|
+
return /* @__PURE__ */ jsxs6("div", { ref: root, style: { position: "relative", display: "inline-block" }, children: [
|
|
1526
|
+
/* @__PURE__ */ jsx13(
|
|
1399
1527
|
"button",
|
|
1400
1528
|
{
|
|
1401
1529
|
ref: trigger,
|
|
@@ -1408,7 +1536,7 @@ function Dropdown(props) {
|
|
|
1408
1536
|
children: props.trigger
|
|
1409
1537
|
}
|
|
1410
1538
|
),
|
|
1411
|
-
open ? /* @__PURE__ */
|
|
1539
|
+
open ? /* @__PURE__ */ jsx13(
|
|
1412
1540
|
"div",
|
|
1413
1541
|
{
|
|
1414
1542
|
ref: menu,
|
|
@@ -1434,24 +1562,24 @@ function DropdownItem(props) {
|
|
|
1434
1562
|
const a = useAppearance();
|
|
1435
1563
|
const attrs = a.el(props.itemKey ?? "dropdown.item", "throttle-dropdown__item");
|
|
1436
1564
|
if (props.href) {
|
|
1437
|
-
return /* @__PURE__ */
|
|
1565
|
+
return /* @__PURE__ */ jsx13("a", { ...attrs, role: "menuitem", href: props.href, tabIndex: -1, children: props.children });
|
|
1438
1566
|
}
|
|
1439
|
-
return /* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ jsx13("button", { ...attrs, role: "menuitem", type: "button", tabIndex: -1, onClick: props.onClick, children: props.children });
|
|
1440
1568
|
}
|
|
1441
1569
|
function DropdownSeparator() {
|
|
1442
1570
|
const a = useAppearance();
|
|
1443
|
-
return /* @__PURE__ */
|
|
1571
|
+
return /* @__PURE__ */ jsx13("hr", { ...a.el("dropdown.separator", "throttle-dropdown__separator") });
|
|
1444
1572
|
}
|
|
1445
1573
|
|
|
1446
1574
|
// src/react/components/primitives/Tabs.tsx
|
|
1447
|
-
import { jsx as
|
|
1575
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1448
1576
|
function Tabs(props) {
|
|
1449
1577
|
const a = useAppearance();
|
|
1450
1578
|
const at = props.tabs.findIndex((t) => t.id === props.active);
|
|
1451
1579
|
const vertical = props.orientation === "vertical";
|
|
1452
1580
|
const listClass = vertical ? "throttle-tabs__rail" : "throttle-tabs__list";
|
|
1453
1581
|
const itemClass = vertical ? "throttle-tabs__railitem" : "throttle-tabs__tab";
|
|
1454
|
-
return /* @__PURE__ */
|
|
1582
|
+
return /* @__PURE__ */ jsx14(
|
|
1455
1583
|
"div",
|
|
1456
1584
|
{
|
|
1457
1585
|
...a.el("tabs.list", listClass),
|
|
@@ -1470,7 +1598,7 @@ function Tabs(props) {
|
|
|
1470
1598
|
children: props.tabs.map((tab) => {
|
|
1471
1599
|
const selected = tab.id === props.active;
|
|
1472
1600
|
const { className, ...rest } = a.el("tabs.tab", itemClass);
|
|
1473
|
-
return /* @__PURE__ */
|
|
1601
|
+
return /* @__PURE__ */ jsxs7(
|
|
1474
1602
|
"button",
|
|
1475
1603
|
{
|
|
1476
1604
|
...rest,
|
|
@@ -1495,16 +1623,16 @@ function Tabs(props) {
|
|
|
1495
1623
|
}
|
|
1496
1624
|
|
|
1497
1625
|
// src/react/components/primitives/DataTable.tsx
|
|
1498
|
-
import { jsx as
|
|
1626
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1499
1627
|
function DataTable(props) {
|
|
1500
1628
|
const a = useAppearance();
|
|
1501
1629
|
const clickable = Boolean(props.onRowClick);
|
|
1502
1630
|
return (
|
|
1503
1631
|
// Tables are the one thing allowed to be wider than the panel; it scrolls
|
|
1504
1632
|
// rather than forcing the whole page to.
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
1507
|
-
/* @__PURE__ */
|
|
1633
|
+
/* @__PURE__ */ jsx15("div", { className: "throttle-table__scroll", children: /* @__PURE__ */ jsxs8("table", { ...a.el(props.tableKey ?? "table", "throttle-table"), children: [
|
|
1634
|
+
/* @__PURE__ */ jsx15("thead", { children: /* @__PURE__ */ jsx15("tr", { children: props.columns.map((col) => /* @__PURE__ */ jsx15("th", { ...a.el("table.head", "throttle-table__head"), scope: "col", children: col.label }, col.key)) }) }),
|
|
1635
|
+
/* @__PURE__ */ jsx15("tbody", { children: props.rows.map((row) => /* @__PURE__ */ jsx15(
|
|
1508
1636
|
"tr",
|
|
1509
1637
|
{
|
|
1510
1638
|
...a.el(props.rowElementKey ?? "table.row", "throttle-table__row"),
|
|
@@ -1516,7 +1644,7 @@ function DataTable(props) {
|
|
|
1516
1644
|
props.onRowClick(row);
|
|
1517
1645
|
}
|
|
1518
1646
|
} : void 0,
|
|
1519
|
-
children: props.columns.map((col) => /* @__PURE__ */
|
|
1647
|
+
children: props.columns.map((col) => /* @__PURE__ */ jsx15("td", { ...a.el("table.cell", "throttle-table__cell"), children: col.render ? col.render(row) : String(row[col.key] ?? "") }, col.key))
|
|
1520
1648
|
},
|
|
1521
1649
|
props.rowKey(row)
|
|
1522
1650
|
)) })
|
|
@@ -1525,48 +1653,49 @@ function DataTable(props) {
|
|
|
1525
1653
|
}
|
|
1526
1654
|
|
|
1527
1655
|
// src/react/components/primitives/EmptyState.tsx
|
|
1528
|
-
import { jsx as
|
|
1656
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1529
1657
|
function EmptyState(props) {
|
|
1530
1658
|
const a = useAppearance();
|
|
1531
1659
|
const Slot = a.slots.EmptyState;
|
|
1532
|
-
if (Slot) return /* @__PURE__ */
|
|
1533
|
-
return /* @__PURE__ */
|
|
1534
|
-
/* @__PURE__ */
|
|
1535
|
-
props.description ? /* @__PURE__ */
|
|
1660
|
+
if (Slot) return /* @__PURE__ */ jsx16(Slot, { title: props.title, description: props.description });
|
|
1661
|
+
return /* @__PURE__ */ jsxs9("div", { ...a.el("emptyState", "throttle-empty"), children: [
|
|
1662
|
+
/* @__PURE__ */ jsx16("p", { ...a.el("emptyState.title", "throttle-empty__title"), children: props.title }),
|
|
1663
|
+
props.description ? /* @__PURE__ */ jsx16("p", { ...a.el("emptyState.description", "throttle-empty__description"), children: props.description }) : null
|
|
1536
1664
|
] });
|
|
1537
1665
|
}
|
|
1538
1666
|
|
|
1539
1667
|
// src/react/components/primitives/Avatar.tsx
|
|
1540
|
-
import { jsx as
|
|
1668
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1541
1669
|
function Avatar(props) {
|
|
1542
1670
|
const a = useAppearance();
|
|
1543
1671
|
const Slot = a.slots.Avatar;
|
|
1544
|
-
if (Slot) return /* @__PURE__ */
|
|
1672
|
+
if (Slot) return /* @__PURE__ */ jsx17(Slot, { name: props.name, email: props.email });
|
|
1545
1673
|
const initials = props.name.split(" ").map((part) => part.trim()[0]).filter(Boolean).slice(0, 2).join("") || props.email.trim()[0] || "?";
|
|
1546
|
-
return /* @__PURE__ */
|
|
1674
|
+
return /* @__PURE__ */ jsx17("span", { ...a.el("avatar", "throttle-avatar"), title: props.email, children: initials.toUpperCase() });
|
|
1547
1675
|
}
|
|
1548
1676
|
|
|
1549
1677
|
// src/react/components/primitives/Badge.tsx
|
|
1550
|
-
import { jsx as
|
|
1678
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1551
1679
|
function Badge(props) {
|
|
1552
1680
|
const a = useAppearance();
|
|
1553
1681
|
const tone = props.tone ?? "neutral";
|
|
1554
1682
|
const base = tone === "neutral" ? "throttle-badge" : `throttle-badge throttle-badge--${tone}`;
|
|
1555
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsx18("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
|
|
1556
1684
|
}
|
|
1557
1685
|
|
|
1558
1686
|
// src/react/components/auth/StepUpDialog.tsx
|
|
1559
|
-
import {
|
|
1687
|
+
import { useEffect as useEffect3, useId as useId3, useState as useState4 } from "react";
|
|
1688
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1560
1689
|
function StepUpDialog(props) {
|
|
1561
1690
|
const a = useAppearance();
|
|
1562
1691
|
const cardClass = useCardClass();
|
|
1563
1692
|
const { t } = useCopy();
|
|
1564
|
-
const [password, setPassword] =
|
|
1565
|
-
const titleId =
|
|
1693
|
+
const [password, setPassword] = useState4("");
|
|
1694
|
+
const titleId = useId3();
|
|
1566
1695
|
useEffect3(() => {
|
|
1567
1696
|
if (!props.open) setPassword("");
|
|
1568
1697
|
}, [props.open]);
|
|
1569
|
-
return /* @__PURE__ */
|
|
1698
|
+
return /* @__PURE__ */ jsx19(Modal, { open: props.open, onClose: () => props.onResolve(null), labelledBy: titleId, children: /* @__PURE__ */ jsx19("div", { ...a.el("stepUp.root", cardClass), children: /* @__PURE__ */ jsxs10(
|
|
1570
1699
|
"form",
|
|
1571
1700
|
{
|
|
1572
1701
|
onSubmit: (e) => {
|
|
@@ -1574,12 +1703,12 @@ function StepUpDialog(props) {
|
|
|
1574
1703
|
props.onResolve(password);
|
|
1575
1704
|
},
|
|
1576
1705
|
children: [
|
|
1577
|
-
/* @__PURE__ */
|
|
1578
|
-
/* @__PURE__ */
|
|
1579
|
-
/* @__PURE__ */
|
|
1706
|
+
/* @__PURE__ */ jsxs10("div", { className: "throttle-card__header", children: [
|
|
1707
|
+
/* @__PURE__ */ jsx19("h2", { id: titleId, ...a.el("stepUp.title", "throttle-card__title"), children: t.stepUp.title }),
|
|
1708
|
+
/* @__PURE__ */ jsx19("p", { className: "throttle-card__description", children: t.stepUp.description })
|
|
1580
1709
|
] }),
|
|
1581
|
-
/* @__PURE__ */
|
|
1582
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ jsxs10(CardBody, { children: [
|
|
1711
|
+
/* @__PURE__ */ jsx19(
|
|
1583
1712
|
Field,
|
|
1584
1713
|
{
|
|
1585
1714
|
label: t.stepUp.password,
|
|
@@ -1591,8 +1720,8 @@ function StepUpDialog(props) {
|
|
|
1591
1720
|
elementKey: "stepUp.passwordField"
|
|
1592
1721
|
}
|
|
1593
1722
|
),
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */
|
|
1723
|
+
/* @__PURE__ */ jsx19(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
|
|
1724
|
+
/* @__PURE__ */ jsx19(Button, { variant: "link", elementKey: "stepUp.cancelButton", onClick: () => props.onResolve(null), children: t.stepUp.cancelButton })
|
|
1596
1725
|
] })
|
|
1597
1726
|
]
|
|
1598
1727
|
}
|
|
@@ -1600,23 +1729,23 @@ function StepUpDialog(props) {
|
|
|
1600
1729
|
}
|
|
1601
1730
|
|
|
1602
1731
|
// src/react/components/auth/AuthModal.tsx
|
|
1603
|
-
import { useId as
|
|
1732
|
+
import { useId as useId4 } from "react";
|
|
1604
1733
|
|
|
1605
1734
|
// src/react/components/auth/AuthFlow.tsx
|
|
1606
|
-
import { useEffect as useEffect5, useState as
|
|
1735
|
+
import { useEffect as useEffect5, useState as useState11 } from "react";
|
|
1607
1736
|
|
|
1608
1737
|
// src/react/components/auth/SignIn.tsx
|
|
1609
|
-
import { useState as
|
|
1738
|
+
import { useState as useState6 } from "react";
|
|
1610
1739
|
|
|
1611
1740
|
// src/react/components/useAction.ts
|
|
1612
|
-
import { useCallback, useRef as
|
|
1741
|
+
import { useCallback as useCallback2, useRef as useRef4, useState as useState5 } from "react";
|
|
1613
1742
|
function useAction() {
|
|
1614
1743
|
const { errorMessage } = useCopy();
|
|
1615
|
-
const [submitting, setSubmitting] =
|
|
1616
|
-
const [error, setError] =
|
|
1617
|
-
const [notice, setNotice] =
|
|
1618
|
-
const inFlight =
|
|
1619
|
-
const run =
|
|
1744
|
+
const [submitting, setSubmitting] = useState5(false);
|
|
1745
|
+
const [error, setError] = useState5(null);
|
|
1746
|
+
const [notice, setNotice] = useState5(null);
|
|
1747
|
+
const inFlight = useRef4(false);
|
|
1748
|
+
const run = useCallback2(
|
|
1620
1749
|
async (fn) => {
|
|
1621
1750
|
if (inFlight.current) return;
|
|
1622
1751
|
inFlight.current = true;
|
|
@@ -1639,7 +1768,7 @@ function useAction() {
|
|
|
1639
1768
|
}
|
|
1640
1769
|
|
|
1641
1770
|
// src/react/components/auth/SignIn.tsx
|
|
1642
|
-
import { Fragment as Fragment2, jsx as
|
|
1771
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1643
1772
|
function SignIn(props) {
|
|
1644
1773
|
const a = useAppearance(props.appearance);
|
|
1645
1774
|
const cardClass = useCardClass();
|
|
@@ -1647,14 +1776,14 @@ function SignIn(props) {
|
|
|
1647
1776
|
const { t } = useCopy(props.localization);
|
|
1648
1777
|
const { auth } = useAuth();
|
|
1649
1778
|
const { submitting, error, run } = useAction();
|
|
1650
|
-
const [email, setEmail] =
|
|
1651
|
-
const [password, setPassword] =
|
|
1779
|
+
const [email, setEmail] = useState6("");
|
|
1780
|
+
const [password, setPassword] = useState6("");
|
|
1652
1781
|
const variant = props.variant ?? "quiet";
|
|
1653
1782
|
const branded = variant === "branded";
|
|
1654
1783
|
const grouped = variant === "grouped";
|
|
1655
1784
|
const logo = useBrandLogo(props.logo);
|
|
1656
|
-
const forgotLink = props.onForgotPassword ? /* @__PURE__ */
|
|
1657
|
-
const emailField = /* @__PURE__ */
|
|
1785
|
+
const forgotLink = props.onForgotPassword ? /* @__PURE__ */ jsx20(Button, { variant: "link", size: "xs", elementKey: "signIn.forgotLink", onClick: props.onForgotPassword, children: t.signIn.forgotLink }) : null;
|
|
1786
|
+
const emailField = /* @__PURE__ */ jsx20(
|
|
1658
1787
|
Field,
|
|
1659
1788
|
{
|
|
1660
1789
|
label: t.signIn.email,
|
|
@@ -1667,7 +1796,7 @@ function SignIn(props) {
|
|
|
1667
1796
|
grouped
|
|
1668
1797
|
}
|
|
1669
1798
|
);
|
|
1670
|
-
const passwordField = /* @__PURE__ */
|
|
1799
|
+
const passwordField = /* @__PURE__ */ jsx20(
|
|
1671
1800
|
Field,
|
|
1672
1801
|
{
|
|
1673
1802
|
label: t.signIn.password,
|
|
@@ -1681,7 +1810,7 @@ function SignIn(props) {
|
|
|
1681
1810
|
labelExtra: grouped ? void 0 : forgotLink
|
|
1682
1811
|
}
|
|
1683
1812
|
);
|
|
1684
|
-
return /* @__PURE__ */
|
|
1813
|
+
return /* @__PURE__ */ jsx20(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx20("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs11(
|
|
1685
1814
|
"form",
|
|
1686
1815
|
{
|
|
1687
1816
|
...a.el("signIn.root", cardClass),
|
|
@@ -1693,7 +1822,7 @@ function SignIn(props) {
|
|
|
1693
1822
|
});
|
|
1694
1823
|
},
|
|
1695
1824
|
children: [
|
|
1696
|
-
/* @__PURE__ */
|
|
1825
|
+
/* @__PURE__ */ jsx20(
|
|
1697
1826
|
CardHeader,
|
|
1698
1827
|
{
|
|
1699
1828
|
title: t.signIn.title,
|
|
@@ -1704,24 +1833,24 @@ function SignIn(props) {
|
|
|
1704
1833
|
branded
|
|
1705
1834
|
}
|
|
1706
1835
|
),
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
grouped ? /* @__PURE__ */
|
|
1836
|
+
/* @__PURE__ */ jsxs11(CardBody, { children: [
|
|
1837
|
+
grouped ? /* @__PURE__ */ jsxs11(FieldGroup, { children: [
|
|
1709
1838
|
emailField,
|
|
1710
1839
|
passwordField
|
|
1711
|
-
] }) : /* @__PURE__ */
|
|
1840
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
1712
1841
|
emailField,
|
|
1713
1842
|
passwordField
|
|
1714
1843
|
] }),
|
|
1715
|
-
grouped && forgotLink ? /* @__PURE__ */
|
|
1716
|
-
error ? /* @__PURE__ */
|
|
1717
|
-
/* @__PURE__ */
|
|
1844
|
+
grouped && forgotLink ? /* @__PURE__ */ jsx20("div", { className: "throttle-field-group__forgot", children: forgotLink }) : null,
|
|
1845
|
+
error ? /* @__PURE__ */ jsx20(Alert, { tone: "error", children: error }) : null,
|
|
1846
|
+
/* @__PURE__ */ jsx20(Button, { type: "submit", loading: submitting, elementKey: "signIn.submitButton", children: t.signIn.submitButton })
|
|
1718
1847
|
] }),
|
|
1719
|
-
props.onSignUp ? /* @__PURE__ */
|
|
1720
|
-
/* @__PURE__ */
|
|
1848
|
+
props.onSignUp ? /* @__PURE__ */ jsxs11(CardFooter, { ruled: !branded, children: [
|
|
1849
|
+
/* @__PURE__ */ jsxs11("span", { className: "throttle-muted", children: [
|
|
1721
1850
|
t.signIn.switchPrompt,
|
|
1722
1851
|
" "
|
|
1723
1852
|
] }),
|
|
1724
|
-
/* @__PURE__ */
|
|
1853
|
+
/* @__PURE__ */ jsx20(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
|
|
1725
1854
|
] }) : null
|
|
1726
1855
|
]
|
|
1727
1856
|
}
|
|
@@ -1729,8 +1858,8 @@ function SignIn(props) {
|
|
|
1729
1858
|
}
|
|
1730
1859
|
|
|
1731
1860
|
// src/react/components/auth/SignUp.tsx
|
|
1732
|
-
import { useState as
|
|
1733
|
-
import { Fragment as Fragment3, jsx as
|
|
1861
|
+
import { useState as useState7 } from "react";
|
|
1862
|
+
import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1734
1863
|
function SignUp(props) {
|
|
1735
1864
|
const a = useAppearance(props.appearance);
|
|
1736
1865
|
const cardClass = useCardClass();
|
|
@@ -1738,13 +1867,13 @@ function SignUp(props) {
|
|
|
1738
1867
|
const { t } = useCopy(props.localization);
|
|
1739
1868
|
const { auth } = useAuth();
|
|
1740
1869
|
const { submitting, error, notice, run } = useAction();
|
|
1741
|
-
const [email, setEmail] =
|
|
1742
|
-
const [password, setPassword] =
|
|
1870
|
+
const [email, setEmail] = useState7("");
|
|
1871
|
+
const [password, setPassword] = useState7("");
|
|
1743
1872
|
const variant = props.variant ?? "quiet";
|
|
1744
1873
|
const branded = variant === "branded";
|
|
1745
1874
|
const grouped = variant === "grouped";
|
|
1746
1875
|
const logo = useBrandLogo(props.logo);
|
|
1747
|
-
const emailField = /* @__PURE__ */
|
|
1876
|
+
const emailField = /* @__PURE__ */ jsx21(
|
|
1748
1877
|
Field,
|
|
1749
1878
|
{
|
|
1750
1879
|
label: t.signUp.email,
|
|
@@ -1757,7 +1886,7 @@ function SignUp(props) {
|
|
|
1757
1886
|
grouped
|
|
1758
1887
|
}
|
|
1759
1888
|
);
|
|
1760
|
-
const passwordField = /* @__PURE__ */
|
|
1889
|
+
const passwordField = /* @__PURE__ */ jsx21(
|
|
1761
1890
|
Field,
|
|
1762
1891
|
{
|
|
1763
1892
|
label: t.signUp.password,
|
|
@@ -1770,7 +1899,7 @@ function SignUp(props) {
|
|
|
1770
1899
|
grouped
|
|
1771
1900
|
}
|
|
1772
1901
|
);
|
|
1773
|
-
return /* @__PURE__ */
|
|
1902
|
+
return /* @__PURE__ */ jsx21(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx21("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs12(
|
|
1774
1903
|
"form",
|
|
1775
1904
|
{
|
|
1776
1905
|
...a.el("signUp.root", cardClass),
|
|
@@ -1786,7 +1915,7 @@ function SignUp(props) {
|
|
|
1786
1915
|
});
|
|
1787
1916
|
},
|
|
1788
1917
|
children: [
|
|
1789
|
-
/* @__PURE__ */
|
|
1918
|
+
/* @__PURE__ */ jsx21(
|
|
1790
1919
|
CardHeader,
|
|
1791
1920
|
{
|
|
1792
1921
|
title: t.signUp.title,
|
|
@@ -1797,24 +1926,24 @@ function SignUp(props) {
|
|
|
1797
1926
|
branded
|
|
1798
1927
|
}
|
|
1799
1928
|
),
|
|
1800
|
-
/* @__PURE__ */
|
|
1801
|
-
grouped ? /* @__PURE__ */
|
|
1929
|
+
/* @__PURE__ */ jsxs12(CardBody, { children: [
|
|
1930
|
+
grouped ? /* @__PURE__ */ jsxs12(FieldGroup, { children: [
|
|
1802
1931
|
emailField,
|
|
1803
1932
|
passwordField
|
|
1804
|
-
] }) : /* @__PURE__ */
|
|
1933
|
+
] }) : /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
1805
1934
|
emailField,
|
|
1806
1935
|
passwordField
|
|
1807
1936
|
] }),
|
|
1808
|
-
error ? /* @__PURE__ */
|
|
1809
|
-
notice ? /* @__PURE__ */
|
|
1810
|
-
/* @__PURE__ */
|
|
1937
|
+
error ? /* @__PURE__ */ jsx21(Alert, { tone: "error", children: error }) : null,
|
|
1938
|
+
notice ? /* @__PURE__ */ jsx21(Alert, { tone: "info", children: notice }) : null,
|
|
1939
|
+
/* @__PURE__ */ jsx21(Button, { type: "submit", loading: submitting, elementKey: "signUp.submitButton", children: t.signUp.submitButton })
|
|
1811
1940
|
] }),
|
|
1812
|
-
props.onSignIn ? /* @__PURE__ */
|
|
1813
|
-
/* @__PURE__ */
|
|
1941
|
+
props.onSignIn ? /* @__PURE__ */ jsxs12(CardFooter, { ruled: !branded, children: [
|
|
1942
|
+
/* @__PURE__ */ jsxs12("span", { className: "throttle-muted", children: [
|
|
1814
1943
|
t.signUp.switchPrompt,
|
|
1815
1944
|
" "
|
|
1816
1945
|
] }),
|
|
1817
|
-
/* @__PURE__ */
|
|
1946
|
+
/* @__PURE__ */ jsx21(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
|
|
1818
1947
|
] }) : null
|
|
1819
1948
|
]
|
|
1820
1949
|
}
|
|
@@ -1822,8 +1951,8 @@ function SignUp(props) {
|
|
|
1822
1951
|
}
|
|
1823
1952
|
|
|
1824
1953
|
// src/react/components/auth/ForgotPassword.tsx
|
|
1825
|
-
import { useState as
|
|
1826
|
-
import { jsx as
|
|
1954
|
+
import { useState as useState8 } from "react";
|
|
1955
|
+
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1827
1956
|
function ForgotPassword(props) {
|
|
1828
1957
|
const a = useAppearance(props.appearance);
|
|
1829
1958
|
const cardClass = useCardClass();
|
|
@@ -1831,10 +1960,10 @@ function ForgotPassword(props) {
|
|
|
1831
1960
|
const { t } = useCopy(props.localization);
|
|
1832
1961
|
const { auth } = useAuth();
|
|
1833
1962
|
const { submitting, error, notice, run } = useAction();
|
|
1834
|
-
const [email, setEmail] =
|
|
1963
|
+
const [email, setEmail] = useState8("");
|
|
1835
1964
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1836
1965
|
const logo = useBrandLogo(props.logo);
|
|
1837
|
-
return /* @__PURE__ */
|
|
1966
|
+
return /* @__PURE__ */ jsx22(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx22("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs13(
|
|
1838
1967
|
"form",
|
|
1839
1968
|
{
|
|
1840
1969
|
...a.el("forgotPassword.root", cardClass),
|
|
@@ -1846,7 +1975,7 @@ function ForgotPassword(props) {
|
|
|
1846
1975
|
});
|
|
1847
1976
|
},
|
|
1848
1977
|
children: [
|
|
1849
|
-
/* @__PURE__ */
|
|
1978
|
+
/* @__PURE__ */ jsx22(
|
|
1850
1979
|
CardHeader,
|
|
1851
1980
|
{
|
|
1852
1981
|
title: t.forgotPassword.title,
|
|
@@ -1857,8 +1986,8 @@ function ForgotPassword(props) {
|
|
|
1857
1986
|
branded
|
|
1858
1987
|
}
|
|
1859
1988
|
),
|
|
1860
|
-
/* @__PURE__ */
|
|
1861
|
-
/* @__PURE__ */
|
|
1989
|
+
/* @__PURE__ */ jsxs13(CardBody, { children: [
|
|
1990
|
+
/* @__PURE__ */ jsx22(
|
|
1862
1991
|
Field,
|
|
1863
1992
|
{
|
|
1864
1993
|
label: t.forgotPassword.email,
|
|
@@ -1870,19 +1999,19 @@ function ForgotPassword(props) {
|
|
|
1870
1999
|
elementKey: "forgotPassword.emailField"
|
|
1871
2000
|
}
|
|
1872
2001
|
),
|
|
1873
|
-
error ? /* @__PURE__ */
|
|
1874
|
-
notice ? /* @__PURE__ */
|
|
1875
|
-
/* @__PURE__ */
|
|
2002
|
+
error ? /* @__PURE__ */ jsx22(Alert, { tone: "error", children: error }) : null,
|
|
2003
|
+
notice ? /* @__PURE__ */ jsx22(Alert, { tone: "success", children: notice }) : null,
|
|
2004
|
+
/* @__PURE__ */ jsx22(Button, { type: "submit", loading: submitting, elementKey: "forgotPassword.submitButton", children: t.forgotPassword.submitButton })
|
|
1876
2005
|
] }),
|
|
1877
|
-
props.onBack ? /* @__PURE__ */
|
|
2006
|
+
props.onBack ? /* @__PURE__ */ jsx22(CardFooter, { ruled: !branded, children: /* @__PURE__ */ jsx22(Button, { variant: "link", elementKey: "forgotPassword.backLink", onClick: props.onBack, children: t.forgotPassword.backLink }) }) : null
|
|
1878
2007
|
]
|
|
1879
2008
|
}
|
|
1880
2009
|
) }) });
|
|
1881
2010
|
}
|
|
1882
2011
|
|
|
1883
2012
|
// src/react/components/auth/ResetPassword.tsx
|
|
1884
|
-
import { useState as
|
|
1885
|
-
import { jsx as
|
|
2013
|
+
import { useState as useState9 } from "react";
|
|
2014
|
+
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1886
2015
|
function ResetPassword(props) {
|
|
1887
2016
|
const a = useAppearance(props.appearance);
|
|
1888
2017
|
const cardClass = useCardClass();
|
|
@@ -1890,11 +2019,11 @@ function ResetPassword(props) {
|
|
|
1890
2019
|
const { t } = useCopy(props.localization);
|
|
1891
2020
|
const { auth } = useAuth();
|
|
1892
2021
|
const { submitting, error, notice, run } = useAction();
|
|
1893
|
-
const [password, setPassword] =
|
|
2022
|
+
const [password, setPassword] = useState9("");
|
|
1894
2023
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1895
2024
|
const logo = useBrandLogo(props.logo);
|
|
1896
|
-
return /* @__PURE__ */
|
|
1897
|
-
/* @__PURE__ */
|
|
2025
|
+
return /* @__PURE__ */ jsx23(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx23("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs14("div", { ...a.el("resetPassword.root", cardClass), children: [
|
|
2026
|
+
/* @__PURE__ */ jsx23(
|
|
1898
2027
|
CardHeader,
|
|
1899
2028
|
{
|
|
1900
2029
|
title: t.resetPassword.title,
|
|
@@ -1904,11 +2033,11 @@ function ResetPassword(props) {
|
|
|
1904
2033
|
branded
|
|
1905
2034
|
}
|
|
1906
2035
|
),
|
|
1907
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ jsx23(CardBody, { children: !props.token ? (
|
|
1908
2037
|
// No form at all without a token. A submit button that can only
|
|
1909
2038
|
// fail is worse than an explanation.
|
|
1910
|
-
/* @__PURE__ */
|
|
1911
|
-
) : /* @__PURE__ */
|
|
2039
|
+
/* @__PURE__ */ jsx23(Alert, { tone: "error", children: t.resetPassword.missingToken })
|
|
2040
|
+
) : /* @__PURE__ */ jsx23(
|
|
1912
2041
|
"form",
|
|
1913
2042
|
{
|
|
1914
2043
|
onSubmit: (e) => {
|
|
@@ -1919,8 +2048,8 @@ function ResetPassword(props) {
|
|
|
1919
2048
|
return t.resetPassword.doneNotice;
|
|
1920
2049
|
});
|
|
1921
2050
|
},
|
|
1922
|
-
children: /* @__PURE__ */
|
|
1923
|
-
/* @__PURE__ */
|
|
2051
|
+
children: /* @__PURE__ */ jsxs14("div", { className: "throttle-stack", children: [
|
|
2052
|
+
/* @__PURE__ */ jsx23(
|
|
1924
2053
|
Field,
|
|
1925
2054
|
{
|
|
1926
2055
|
label: t.resetPassword.password,
|
|
@@ -1932,9 +2061,9 @@ function ResetPassword(props) {
|
|
|
1932
2061
|
elementKey: "resetPassword.passwordField"
|
|
1933
2062
|
}
|
|
1934
2063
|
),
|
|
1935
|
-
error ? /* @__PURE__ */
|
|
1936
|
-
notice ? /* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
2064
|
+
error ? /* @__PURE__ */ jsx23(Alert, { tone: "error", children: error }) : null,
|
|
2065
|
+
notice ? /* @__PURE__ */ jsx23(Alert, { tone: "success", children: notice }) : null,
|
|
2066
|
+
/* @__PURE__ */ jsx23(Button, { type: "submit", loading: submitting, elementKey: "resetPassword.submitButton", children: t.resetPassword.submitButton })
|
|
1938
2067
|
] })
|
|
1939
2068
|
}
|
|
1940
2069
|
) })
|
|
@@ -1942,8 +2071,8 @@ function ResetPassword(props) {
|
|
|
1942
2071
|
}
|
|
1943
2072
|
|
|
1944
2073
|
// src/react/components/auth/VerifyEmail.tsx
|
|
1945
|
-
import { useEffect as useEffect4, useRef as
|
|
1946
|
-
import { jsx as
|
|
2074
|
+
import { useEffect as useEffect4, useRef as useRef5, useState as useState10 } from "react";
|
|
2075
|
+
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1947
2076
|
function VerifyEmail(props) {
|
|
1948
2077
|
const a = useAppearance(props.appearance);
|
|
1949
2078
|
const cardClass = useCardClass();
|
|
@@ -1951,11 +2080,11 @@ function VerifyEmail(props) {
|
|
|
1951
2080
|
const { t, errorMessage } = useCopy(props.localization);
|
|
1952
2081
|
const { auth } = useAuth();
|
|
1953
2082
|
const { submitting, notice, run } = useAction();
|
|
1954
|
-
const [state, setState] =
|
|
1955
|
-
const [error, setError] =
|
|
2083
|
+
const [state, setState] = useState10(props.token ? "verifying" : "idle");
|
|
2084
|
+
const [error, setError] = useState10(null);
|
|
1956
2085
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1957
2086
|
const logo = useBrandLogo(props.logo);
|
|
1958
|
-
const attempted =
|
|
2087
|
+
const attempted = useRef5(null);
|
|
1959
2088
|
useEffect4(() => {
|
|
1960
2089
|
const token = props.token;
|
|
1961
2090
|
if (!token || attempted.current === token) return;
|
|
@@ -1969,8 +2098,8 @@ function VerifyEmail(props) {
|
|
|
1969
2098
|
setState("failed");
|
|
1970
2099
|
});
|
|
1971
2100
|
}, [props.token, auth]);
|
|
1972
|
-
return /* @__PURE__ */
|
|
1973
|
-
/* @__PURE__ */
|
|
2101
|
+
return /* @__PURE__ */ jsx24(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx24("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs15("div", { ...a.el("verifyEmail.root", cardClass), children: [
|
|
2102
|
+
/* @__PURE__ */ jsx24(
|
|
1974
2103
|
CardHeader,
|
|
1975
2104
|
{
|
|
1976
2105
|
title: t.verifyEmail.title,
|
|
@@ -1980,17 +2109,17 @@ function VerifyEmail(props) {
|
|
|
1980
2109
|
branded
|
|
1981
2110
|
}
|
|
1982
2111
|
),
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
state === "verifying" ? /* @__PURE__ */
|
|
1985
|
-
/* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ jsxs15(CardBody, { children: [
|
|
2113
|
+
state === "verifying" ? /* @__PURE__ */ jsxs15("p", { children: [
|
|
2114
|
+
/* @__PURE__ */ jsx24(Spinner, {}),
|
|
1986
2115
|
" ",
|
|
1987
2116
|
t.verifyEmail.verifying
|
|
1988
2117
|
] }) : null,
|
|
1989
|
-
state === "done" ? /* @__PURE__ */
|
|
1990
|
-
state === "failed" && error ? /* @__PURE__ */
|
|
1991
|
-
state === "idle" ? /* @__PURE__ */
|
|
1992
|
-
notice ? /* @__PURE__ */
|
|
1993
|
-
state !== "done" ? /* @__PURE__ */
|
|
2118
|
+
state === "done" ? /* @__PURE__ */ jsx24(Alert, { tone: "success", children: t.verifyEmail.success }) : null,
|
|
2119
|
+
state === "failed" && error ? /* @__PURE__ */ jsx24(Alert, { tone: "error", children: error }) : null,
|
|
2120
|
+
state === "idle" ? /* @__PURE__ */ jsx24("p", { className: "throttle-muted", children: t.verifyEmail.instructions }) : null,
|
|
2121
|
+
notice ? /* @__PURE__ */ jsx24(Alert, { tone: "success", children: notice }) : null,
|
|
2122
|
+
state !== "done" ? /* @__PURE__ */ jsx24(
|
|
1994
2123
|
Button,
|
|
1995
2124
|
{
|
|
1996
2125
|
variant: "secondary",
|
|
@@ -2008,7 +2137,7 @@ function VerifyEmail(props) {
|
|
|
2008
2137
|
}
|
|
2009
2138
|
|
|
2010
2139
|
// src/react/components/auth/AuthFlow.tsx
|
|
2011
|
-
import { jsx as
|
|
2140
|
+
import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2012
2141
|
var HASH_FOR = {
|
|
2013
2142
|
signIn: "#/sign-in",
|
|
2014
2143
|
signUp: "#/sign-up",
|
|
@@ -2034,8 +2163,8 @@ function readLocation() {
|
|
|
2034
2163
|
function AuthFlow(props) {
|
|
2035
2164
|
const a = useAppearance(props.appearance);
|
|
2036
2165
|
const controlled = props.view !== void 0;
|
|
2037
|
-
const [internal, setInternal] =
|
|
2038
|
-
const [urlToken, setUrlToken] =
|
|
2166
|
+
const [internal, setInternal] = useState11(props.initialView ?? "signIn");
|
|
2167
|
+
const [urlToken, setUrlToken] = useState11(void 0);
|
|
2039
2168
|
useEffect5(() => {
|
|
2040
2169
|
const found = readLocation();
|
|
2041
2170
|
if (found.token) setUrlToken(found.token);
|
|
@@ -2066,8 +2195,8 @@ function AuthFlow(props) {
|
|
|
2066
2195
|
return () => window.removeEventListener("hashchange", onHashChange);
|
|
2067
2196
|
}, [props.routing, controlled]);
|
|
2068
2197
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
2069
|
-
return /* @__PURE__ */
|
|
2070
|
-
view === "signIn" ? /* @__PURE__ */
|
|
2198
|
+
return /* @__PURE__ */ jsx25("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs16("div", { ...a.el("authFlow.root"), children: [
|
|
2199
|
+
view === "signIn" ? /* @__PURE__ */ jsx25(
|
|
2071
2200
|
SignIn,
|
|
2072
2201
|
{
|
|
2073
2202
|
...shared,
|
|
@@ -2076,19 +2205,19 @@ function AuthFlow(props) {
|
|
|
2076
2205
|
onSignUp: () => go("signUp")
|
|
2077
2206
|
}
|
|
2078
2207
|
) : null,
|
|
2079
|
-
view === "signUp" ? /* @__PURE__ */
|
|
2080
|
-
view === "forgotPassword" ? /* @__PURE__ */
|
|
2081
|
-
view === "resetPassword" ? /* @__PURE__ */
|
|
2082
|
-
view === "verifyEmail" ? /* @__PURE__ */
|
|
2208
|
+
view === "signUp" ? /* @__PURE__ */ jsx25(SignUp, { ...shared, onSuccess: props.afterSignUp, onSignIn: () => go("signIn") }) : null,
|
|
2209
|
+
view === "forgotPassword" ? /* @__PURE__ */ jsx25(ForgotPassword, { ...shared, onBack: () => go("signIn") }) : null,
|
|
2210
|
+
view === "resetPassword" ? /* @__PURE__ */ jsx25(ResetPassword, { ...shared, token, onSuccess: () => go("signIn") }) : null,
|
|
2211
|
+
view === "verifyEmail" ? /* @__PURE__ */ jsx25(VerifyEmail, { ...shared, token }) : null
|
|
2083
2212
|
] }) });
|
|
2084
2213
|
}
|
|
2085
2214
|
|
|
2086
2215
|
// src/react/components/auth/AuthModal.tsx
|
|
2087
|
-
import { jsx as
|
|
2216
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2088
2217
|
function AuthModal(props) {
|
|
2089
2218
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2090
|
-
const titleId =
|
|
2091
|
-
return /* @__PURE__ */
|
|
2219
|
+
const titleId = useId4();
|
|
2220
|
+
return /* @__PURE__ */ jsx26(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsxs17(
|
|
2092
2221
|
Modal,
|
|
2093
2222
|
{
|
|
2094
2223
|
open: props.open,
|
|
@@ -2098,8 +2227,8 @@ function AuthModal(props) {
|
|
|
2098
2227
|
overlayKey: "authModal.overlay",
|
|
2099
2228
|
containerKey: "authModal.container",
|
|
2100
2229
|
children: [
|
|
2101
|
-
/* @__PURE__ */
|
|
2102
|
-
/* @__PURE__ */
|
|
2230
|
+
/* @__PURE__ */ jsx26("h2", { id: titleId, style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Account" }),
|
|
2231
|
+
/* @__PURE__ */ jsx26(
|
|
2103
2232
|
AuthFlow,
|
|
2104
2233
|
{
|
|
2105
2234
|
initialView: props.initialView,
|
|
@@ -2115,14 +2244,14 @@ function AuthModal(props) {
|
|
|
2115
2244
|
}
|
|
2116
2245
|
|
|
2117
2246
|
// src/react/components/account/AccountModal.tsx
|
|
2118
|
-
import { useId as
|
|
2247
|
+
import { useId as useId7 } from "react";
|
|
2119
2248
|
|
|
2120
2249
|
// src/react/components/account/AccountDashboard.tsx
|
|
2121
|
-
import { useEffect as
|
|
2250
|
+
import { useEffect as useEffect9, useId as useId6, useState as useState21 } from "react";
|
|
2122
2251
|
|
|
2123
2252
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2124
|
-
import { useState as
|
|
2125
|
-
import { jsx as
|
|
2253
|
+
import { useState as useState12 } from "react";
|
|
2254
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2126
2255
|
var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
|
|
2127
2256
|
function readDismissed() {
|
|
2128
2257
|
try {
|
|
@@ -2143,14 +2272,14 @@ function VerifyEmailBanner(props) {
|
|
|
2143
2272
|
const { t } = useCopy(props.localization);
|
|
2144
2273
|
const { auth, status, emailVerified } = useAuth();
|
|
2145
2274
|
const { submitting, notice, error, run } = useAction();
|
|
2146
|
-
const [dismissed, setDismissed] =
|
|
2275
|
+
const [dismissed, setDismissed] = useState12(readDismissed);
|
|
2147
2276
|
if (status !== "authenticated" || emailVerified || dismissed) return null;
|
|
2148
|
-
return /* @__PURE__ */
|
|
2149
|
-
/* @__PURE__ */
|
|
2150
|
-
notice ? /* @__PURE__ */
|
|
2151
|
-
error ? /* @__PURE__ */
|
|
2152
|
-
/* @__PURE__ */
|
|
2153
|
-
/* @__PURE__ */
|
|
2277
|
+
return /* @__PURE__ */ jsx27(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx27("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs18("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
|
|
2278
|
+
/* @__PURE__ */ jsx27("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
|
|
2279
|
+
notice ? /* @__PURE__ */ jsx27(Alert, { tone: "success", children: notice }) : null,
|
|
2280
|
+
error ? /* @__PURE__ */ jsx27(Alert, { tone: "error", children: error }) : null,
|
|
2281
|
+
/* @__PURE__ */ jsxs18("span", { className: "throttle-actions", children: [
|
|
2282
|
+
/* @__PURE__ */ jsx27(
|
|
2154
2283
|
Button,
|
|
2155
2284
|
{
|
|
2156
2285
|
variant: "secondary",
|
|
@@ -2163,7 +2292,7 @@ function VerifyEmailBanner(props) {
|
|
|
2163
2292
|
children: t.verifyBanner.resendButton
|
|
2164
2293
|
}
|
|
2165
2294
|
),
|
|
2166
|
-
/* @__PURE__ */
|
|
2295
|
+
/* @__PURE__ */ jsx27(
|
|
2167
2296
|
Button,
|
|
2168
2297
|
{
|
|
2169
2298
|
variant: "link",
|
|
@@ -2180,9 +2309,9 @@ function VerifyEmailBanner(props) {
|
|
|
2180
2309
|
}
|
|
2181
2310
|
|
|
2182
2311
|
// src/react/components/account/icons.tsx
|
|
2183
|
-
import { jsx as
|
|
2312
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2184
2313
|
function Glyph(props) {
|
|
2185
|
-
return /* @__PURE__ */
|
|
2314
|
+
return /* @__PURE__ */ jsx28(
|
|
2186
2315
|
"svg",
|
|
2187
2316
|
{
|
|
2188
2317
|
className: "throttle-tabs__railicon",
|
|
@@ -2201,68 +2330,68 @@ function Glyph(props) {
|
|
|
2201
2330
|
);
|
|
2202
2331
|
}
|
|
2203
2332
|
var ACCOUNT_ICONS = {
|
|
2204
|
-
profile: /* @__PURE__ */
|
|
2205
|
-
/* @__PURE__ */
|
|
2206
|
-
/* @__PURE__ */
|
|
2333
|
+
profile: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2334
|
+
/* @__PURE__ */ jsx28("circle", { cx: "12", cy: "8", r: "4" }),
|
|
2335
|
+
/* @__PURE__ */ jsx28("path", { d: "M4 21c0-4 3.6-6 8-6s8 2 8 6" })
|
|
2207
2336
|
] }),
|
|
2208
|
-
addresses: /* @__PURE__ */
|
|
2209
|
-
/* @__PURE__ */
|
|
2210
|
-
/* @__PURE__ */
|
|
2337
|
+
addresses: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2338
|
+
/* @__PURE__ */ jsx28("path", { d: "M12 21s7-5.3 7-11a7 7 0 1 0-14 0c0 5.7 7 11 7 11Z" }),
|
|
2339
|
+
/* @__PURE__ */ jsx28("circle", { cx: "12", cy: "10", r: "2.5" })
|
|
2211
2340
|
] }),
|
|
2212
|
-
paymentMethods: /* @__PURE__ */
|
|
2213
|
-
/* @__PURE__ */
|
|
2214
|
-
/* @__PURE__ */
|
|
2341
|
+
paymentMethods: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2342
|
+
/* @__PURE__ */ jsx28("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
|
|
2343
|
+
/* @__PURE__ */ jsx28("path", { d: "M2.5 10h19" })
|
|
2215
2344
|
] }),
|
|
2216
|
-
orders: /* @__PURE__ */
|
|
2217
|
-
/* @__PURE__ */
|
|
2218
|
-
/* @__PURE__ */
|
|
2219
|
-
/* @__PURE__ */
|
|
2345
|
+
orders: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2346
|
+
/* @__PURE__ */ jsx28("path", { d: "M4 7h16v13H4z" }),
|
|
2347
|
+
/* @__PURE__ */ jsx28("path", { d: "M8 7V4h8v3" }),
|
|
2348
|
+
/* @__PURE__ */ jsx28("path", { d: "M8 12h8" })
|
|
2220
2349
|
] }),
|
|
2221
|
-
invoices: /* @__PURE__ */
|
|
2222
|
-
/* @__PURE__ */
|
|
2223
|
-
/* @__PURE__ */
|
|
2350
|
+
invoices: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2351
|
+
/* @__PURE__ */ jsx28("path", { d: "M6 3h12v18l-3-2-3 2-3-2-3 2Z" }),
|
|
2352
|
+
/* @__PURE__ */ jsx28("path", { d: "M9 8h6M9 12h6" })
|
|
2224
2353
|
] }),
|
|
2225
|
-
subscriptions: /* @__PURE__ */
|
|
2226
|
-
/* @__PURE__ */
|
|
2227
|
-
/* @__PURE__ */
|
|
2228
|
-
/* @__PURE__ */
|
|
2354
|
+
subscriptions: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2355
|
+
/* @__PURE__ */ jsx28("path", { d: "M3 12a9 9 0 0 1 15.5-6.2" }),
|
|
2356
|
+
/* @__PURE__ */ jsx28("path", { d: "M21 12a9 9 0 0 1-15.5 6.2" }),
|
|
2357
|
+
/* @__PURE__ */ jsx28("path", { d: "M18 3v4h-4M6 21v-4h4" })
|
|
2229
2358
|
] }),
|
|
2230
|
-
security: /* @__PURE__ */
|
|
2231
|
-
/* @__PURE__ */
|
|
2232
|
-
/* @__PURE__ */
|
|
2359
|
+
security: /* @__PURE__ */ jsxs19(Glyph, { children: [
|
|
2360
|
+
/* @__PURE__ */ jsx28("path", { d: "M12 3 4 6.5V12c0 5 3.4 8.3 8 9 4.6-.7 8-4 8-9V6.5Z" }),
|
|
2361
|
+
/* @__PURE__ */ jsx28("path", { d: "m9 12 2 2 4-4" })
|
|
2233
2362
|
] })
|
|
2234
2363
|
};
|
|
2235
2364
|
|
|
2236
2365
|
// src/react/components/account/ProfilePanel.tsx
|
|
2237
|
-
import { useEffect as useEffect6, useState as
|
|
2366
|
+
import { useEffect as useEffect6, useState as useState13, useRef as useRef6 } from "react";
|
|
2238
2367
|
|
|
2239
2368
|
// src/react/components/account/PanelState.tsx
|
|
2240
|
-
import { Fragment as Fragment4, jsx as
|
|
2369
|
+
import { Fragment as Fragment4, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2241
2370
|
function PanelState(props) {
|
|
2242
2371
|
const { t, errorMessage } = useCopy();
|
|
2243
2372
|
const { data, isLoading, error, refetch } = props.resource;
|
|
2244
2373
|
const empty = props.isEmpty(data);
|
|
2245
|
-
if (isLoading && empty) return /* @__PURE__ */
|
|
2246
|
-
const errorBanner = error ? /* @__PURE__ */
|
|
2247
|
-
/* @__PURE__ */
|
|
2248
|
-
/* @__PURE__ */
|
|
2374
|
+
if (isLoading && empty) return /* @__PURE__ */ jsx29(Skeleton, { count: props.skeletonRows ?? 3 });
|
|
2375
|
+
const errorBanner = error ? /* @__PURE__ */ jsxs20("div", { className: "throttle-stack", children: [
|
|
2376
|
+
/* @__PURE__ */ jsx29(Alert, { tone: "error", children: errorMessage(error) }),
|
|
2377
|
+
/* @__PURE__ */ jsx29(Button, { variant: "secondary", onClick: () => void refetch(), children: t.common.retry })
|
|
2249
2378
|
] }) : null;
|
|
2250
2379
|
const gatedByVerification = error?.code === "verification_required";
|
|
2251
2380
|
if (gatedByVerification && empty) {
|
|
2252
|
-
return /* @__PURE__ */
|
|
2381
|
+
return /* @__PURE__ */ jsx29(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
|
|
2253
2382
|
}
|
|
2254
2383
|
if (error && empty) return errorBanner;
|
|
2255
2384
|
if (empty) {
|
|
2256
|
-
return props.gated ? /* @__PURE__ */
|
|
2385
|
+
return props.gated ? /* @__PURE__ */ jsx29(EmptyState, { title: props.emptyTitle, description: props.gatedDescription }) : /* @__PURE__ */ jsx29(EmptyState, { title: props.emptyTitle, description: props.emptyDescription });
|
|
2257
2386
|
}
|
|
2258
|
-
return /* @__PURE__ */
|
|
2387
|
+
return /* @__PURE__ */ jsxs20(Fragment4, { children: [
|
|
2259
2388
|
errorBanner,
|
|
2260
2389
|
props.children(data)
|
|
2261
2390
|
] });
|
|
2262
2391
|
}
|
|
2263
2392
|
|
|
2264
2393
|
// src/react/components/account/ProfilePanel.tsx
|
|
2265
|
-
import { jsx as
|
|
2394
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2266
2395
|
function ProfilePanel(props) {
|
|
2267
2396
|
const a = useAppearance(props.appearance);
|
|
2268
2397
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2270,8 +2399,8 @@ function ProfilePanel(props) {
|
|
|
2270
2399
|
const { status } = useAuth();
|
|
2271
2400
|
const resource = useCustomer();
|
|
2272
2401
|
const { submitting, error, notice, run } = useAction();
|
|
2273
|
-
const [form, setForm] =
|
|
2274
|
-
const edited =
|
|
2402
|
+
const [form, setForm] = useState13({ firstName: "", lastName: "", phone: "", company: "" });
|
|
2403
|
+
const edited = useRef6(false);
|
|
2275
2404
|
useEffect6(() => {
|
|
2276
2405
|
const c = resource.data;
|
|
2277
2406
|
if (!c || edited.current) return;
|
|
@@ -2279,19 +2408,18 @@ function ProfilePanel(props) {
|
|
|
2279
2408
|
firstName: c.firstName ?? "",
|
|
2280
2409
|
lastName: c.lastName ?? "",
|
|
2281
2410
|
phone: c.phone ?? "",
|
|
2282
|
-
company: c.company ?? ""
|
|
2283
|
-
acceptsMarketing: Boolean(c.acceptsMarketing)
|
|
2411
|
+
company: c.company ?? ""
|
|
2284
2412
|
});
|
|
2285
2413
|
}, [resource.data]);
|
|
2286
2414
|
if (status === "unauthenticated") return null;
|
|
2287
|
-
return /* @__PURE__ */
|
|
2415
|
+
return /* @__PURE__ */ jsx30(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx30("div", { ...a.rootProps, children: /* @__PURE__ */ jsx30("div", { ...a.el("profilePanel.root", "throttle-panel"), children: /* @__PURE__ */ jsx30(
|
|
2288
2416
|
PanelState,
|
|
2289
2417
|
{
|
|
2290
2418
|
resource,
|
|
2291
2419
|
isEmpty: (c) => c === null,
|
|
2292
2420
|
emptyTitle: t.common.somethingWentWrong,
|
|
2293
2421
|
skeletonRows: 4,
|
|
2294
|
-
children: (customer) => /* @__PURE__ */
|
|
2422
|
+
children: (customer) => /* @__PURE__ */ jsxs21(
|
|
2295
2423
|
"form",
|
|
2296
2424
|
{
|
|
2297
2425
|
...a.el("profilePanel.form", "throttle-stack"),
|
|
@@ -2303,14 +2431,13 @@ function ProfilePanel(props) {
|
|
|
2303
2431
|
firstName: form.firstName,
|
|
2304
2432
|
lastName: form.lastName,
|
|
2305
2433
|
phone: form.phone,
|
|
2306
|
-
company: form.company || null
|
|
2307
|
-
acceptsMarketing: form.acceptsMarketing
|
|
2434
|
+
company: form.company || null
|
|
2308
2435
|
});
|
|
2309
2436
|
return t.profile.savedNotice;
|
|
2310
2437
|
});
|
|
2311
2438
|
},
|
|
2312
2439
|
children: [
|
|
2313
|
-
/* @__PURE__ */
|
|
2440
|
+
/* @__PURE__ */ jsx30(
|
|
2314
2441
|
Field,
|
|
2315
2442
|
{
|
|
2316
2443
|
label: t.profile.email,
|
|
@@ -2322,7 +2449,7 @@ function ProfilePanel(props) {
|
|
|
2322
2449
|
hint: t.profile.emailReadOnly
|
|
2323
2450
|
}
|
|
2324
2451
|
),
|
|
2325
|
-
/* @__PURE__ */
|
|
2452
|
+
/* @__PURE__ */ jsx30(
|
|
2326
2453
|
Field,
|
|
2327
2454
|
{
|
|
2328
2455
|
label: t.profile.firstName,
|
|
@@ -2334,7 +2461,7 @@ function ProfilePanel(props) {
|
|
|
2334
2461
|
}
|
|
2335
2462
|
}
|
|
2336
2463
|
),
|
|
2337
|
-
/* @__PURE__ */
|
|
2464
|
+
/* @__PURE__ */ jsx30(
|
|
2338
2465
|
Field,
|
|
2339
2466
|
{
|
|
2340
2467
|
label: t.profile.lastName,
|
|
@@ -2346,7 +2473,7 @@ function ProfilePanel(props) {
|
|
|
2346
2473
|
}
|
|
2347
2474
|
}
|
|
2348
2475
|
),
|
|
2349
|
-
/* @__PURE__ */
|
|
2476
|
+
/* @__PURE__ */ jsx30(
|
|
2350
2477
|
Field,
|
|
2351
2478
|
{
|
|
2352
2479
|
label: t.profile.phone,
|
|
@@ -2359,7 +2486,7 @@ function ProfilePanel(props) {
|
|
|
2359
2486
|
}
|
|
2360
2487
|
}
|
|
2361
2488
|
),
|
|
2362
|
-
/* @__PURE__ */
|
|
2489
|
+
/* @__PURE__ */ jsx30(
|
|
2363
2490
|
Field,
|
|
2364
2491
|
{
|
|
2365
2492
|
label: t.profile.company,
|
|
@@ -2371,23 +2498,9 @@ function ProfilePanel(props) {
|
|
|
2371
2498
|
}
|
|
2372
2499
|
}
|
|
2373
2500
|
),
|
|
2374
|
-
/* @__PURE__ */
|
|
2375
|
-
|
|
2376
|
-
|
|
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
|
-
error ? /* @__PURE__ */ jsx29(Alert, { tone: "error", children: error }) : null,
|
|
2389
|
-
notice ? /* @__PURE__ */ jsx29(Alert, { tone: "success", children: notice }) : null,
|
|
2390
|
-
/* @__PURE__ */ jsx29(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
2501
|
+
error ? /* @__PURE__ */ jsx30(Alert, { tone: "error", children: error }) : null,
|
|
2502
|
+
notice ? /* @__PURE__ */ jsx30(Alert, { tone: "success", children: notice }) : null,
|
|
2503
|
+
/* @__PURE__ */ jsx30(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
|
|
2391
2504
|
]
|
|
2392
2505
|
}
|
|
2393
2506
|
)
|
|
@@ -2396,16 +2509,16 @@ function ProfilePanel(props) {
|
|
|
2396
2509
|
}
|
|
2397
2510
|
|
|
2398
2511
|
// src/react/components/account/AddressesPanel.tsx
|
|
2399
|
-
import { useState as
|
|
2512
|
+
import { useState as useState15 } from "react";
|
|
2400
2513
|
|
|
2401
2514
|
// src/react/components/account/AddressForm.tsx
|
|
2402
|
-
import { useState as
|
|
2403
|
-
import { jsx as
|
|
2515
|
+
import { useState as useState14 } from "react";
|
|
2516
|
+
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2404
2517
|
function AddressForm(props) {
|
|
2405
2518
|
const a = useAppearance();
|
|
2406
2519
|
const { t } = useCopy();
|
|
2407
2520
|
const i = props.initial;
|
|
2408
|
-
const [form, setForm] =
|
|
2521
|
+
const [form, setForm] = useState14({
|
|
2409
2522
|
label: i?.label ?? "",
|
|
2410
2523
|
firstName: i?.firstName ?? "",
|
|
2411
2524
|
lastName: i?.lastName ?? "",
|
|
@@ -2419,7 +2532,7 @@ function AddressForm(props) {
|
|
|
2419
2532
|
phone: i?.phone ?? ""
|
|
2420
2533
|
});
|
|
2421
2534
|
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
2422
|
-
return /* @__PURE__ */
|
|
2535
|
+
return /* @__PURE__ */ jsxs22(
|
|
2423
2536
|
"form",
|
|
2424
2537
|
{
|
|
2425
2538
|
...a.el("addressesPanel.form", "throttle-stack"),
|
|
@@ -2441,11 +2554,11 @@ function AddressForm(props) {
|
|
|
2441
2554
|
});
|
|
2442
2555
|
},
|
|
2443
2556
|
children: [
|
|
2444
|
-
/* @__PURE__ */
|
|
2445
|
-
/* @__PURE__ */
|
|
2446
|
-
/* @__PURE__ */
|
|
2447
|
-
/* @__PURE__ */
|
|
2448
|
-
/* @__PURE__ */
|
|
2557
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
|
|
2558
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
|
|
2559
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" }),
|
|
2560
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" }),
|
|
2561
|
+
/* @__PURE__ */ jsx31(
|
|
2449
2562
|
Field,
|
|
2450
2563
|
{
|
|
2451
2564
|
label: t.addresses.addressLine1,
|
|
@@ -2455,7 +2568,7 @@ function AddressForm(props) {
|
|
|
2455
2568
|
autoComplete: "address-line1"
|
|
2456
2569
|
}
|
|
2457
2570
|
),
|
|
2458
|
-
/* @__PURE__ */
|
|
2571
|
+
/* @__PURE__ */ jsx31(
|
|
2459
2572
|
Field,
|
|
2460
2573
|
{
|
|
2461
2574
|
label: t.addresses.addressLine2,
|
|
@@ -2464,8 +2577,8 @@ function AddressForm(props) {
|
|
|
2464
2577
|
autoComplete: "address-line2"
|
|
2465
2578
|
}
|
|
2466
2579
|
),
|
|
2467
|
-
/* @__PURE__ */
|
|
2468
|
-
/* @__PURE__ */
|
|
2580
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
|
|
2581
|
+
/* @__PURE__ */ jsx31(
|
|
2469
2582
|
Field,
|
|
2470
2583
|
{
|
|
2471
2584
|
label: t.addresses.stateProvince,
|
|
@@ -2474,7 +2587,7 @@ function AddressForm(props) {
|
|
|
2474
2587
|
autoComplete: "address-level1"
|
|
2475
2588
|
}
|
|
2476
2589
|
),
|
|
2477
|
-
/* @__PURE__ */
|
|
2590
|
+
/* @__PURE__ */ jsx31(
|
|
2478
2591
|
Field,
|
|
2479
2592
|
{
|
|
2480
2593
|
label: t.addresses.postalCode,
|
|
@@ -2483,7 +2596,7 @@ function AddressForm(props) {
|
|
|
2483
2596
|
autoComplete: "postal-code"
|
|
2484
2597
|
}
|
|
2485
2598
|
),
|
|
2486
|
-
/* @__PURE__ */
|
|
2599
|
+
/* @__PURE__ */ jsx31(
|
|
2487
2600
|
Field,
|
|
2488
2601
|
{
|
|
2489
2602
|
label: t.addresses.countryCode,
|
|
@@ -2494,11 +2607,11 @@ function AddressForm(props) {
|
|
|
2494
2607
|
hint: "ISO 3166-1 alpha-2, e.g. GB"
|
|
2495
2608
|
}
|
|
2496
2609
|
),
|
|
2497
|
-
/* @__PURE__ */
|
|
2498
|
-
props.error ? /* @__PURE__ */
|
|
2499
|
-
/* @__PURE__ */
|
|
2500
|
-
/* @__PURE__ */
|
|
2501
|
-
/* @__PURE__ */
|
|
2610
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
|
|
2611
|
+
props.error ? /* @__PURE__ */ jsx31(Alert, { tone: "error", children: props.error }) : null,
|
|
2612
|
+
/* @__PURE__ */ jsxs22("div", { className: "throttle-actions", children: [
|
|
2613
|
+
/* @__PURE__ */ jsx31(Button, { type: "submit", loading: props.submitting, children: t.common.save }),
|
|
2614
|
+
/* @__PURE__ */ jsx31(Button, { variant: "link", onClick: props.onCancel, children: t.common.cancel })
|
|
2502
2615
|
] })
|
|
2503
2616
|
]
|
|
2504
2617
|
}
|
|
@@ -2506,14 +2619,15 @@ function AddressForm(props) {
|
|
|
2506
2619
|
}
|
|
2507
2620
|
|
|
2508
2621
|
// src/react/components/account/AddressesPanel.tsx
|
|
2509
|
-
import { Fragment as Fragment5, jsx as
|
|
2622
|
+
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2510
2623
|
function AddressesPanel(props) {
|
|
2511
2624
|
const a = useAppearance(props.appearance);
|
|
2512
2625
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2513
2626
|
const { t } = useCopy(props.localization);
|
|
2514
2627
|
const resource = useAddresses();
|
|
2515
2628
|
const { submitting, error, run } = useAction();
|
|
2516
|
-
const
|
|
2629
|
+
const confirm = useConfirm();
|
|
2630
|
+
const [editing, setEditing] = useState15(null);
|
|
2517
2631
|
const variant = props.variant ?? "rows";
|
|
2518
2632
|
const rowsVariant = variant === "rows";
|
|
2519
2633
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -2521,9 +2635,9 @@ function AddressesPanel(props) {
|
|
|
2521
2635
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
2522
2636
|
const close = () => setEditing(null);
|
|
2523
2637
|
const formatAddress = (address) => [address.addressLine2, address.city, address.stateProvince, address.postalCode, address.countryCode].filter(Boolean).join(", ");
|
|
2524
|
-
return /* @__PURE__ */
|
|
2525
|
-
!editing && error ? /* @__PURE__ */
|
|
2526
|
-
editing ? /* @__PURE__ */
|
|
2638
|
+
return /* @__PURE__ */ jsx32(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx32("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs23("div", { ...a.el("addressesPanel.root", "throttle-panel"), children: [
|
|
2639
|
+
!editing && error ? /* @__PURE__ */ jsx32(Alert, { tone: "error", children: error }) : null,
|
|
2640
|
+
editing ? /* @__PURE__ */ jsx32(
|
|
2527
2641
|
AddressForm,
|
|
2528
2642
|
{
|
|
2529
2643
|
initial: editing === "new" ? void 0 : editing,
|
|
@@ -2536,16 +2650,16 @@ function AddressesPanel(props) {
|
|
|
2536
2650
|
close();
|
|
2537
2651
|
})
|
|
2538
2652
|
}
|
|
2539
|
-
) : /* @__PURE__ */
|
|
2540
|
-
/* @__PURE__ */
|
|
2541
|
-
/* @__PURE__ */
|
|
2653
|
+
) : /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
2654
|
+
/* @__PURE__ */ jsx32("div", { children: /* @__PURE__ */ jsx32(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
|
|
2655
|
+
/* @__PURE__ */ jsx32(
|
|
2542
2656
|
PanelState,
|
|
2543
2657
|
{
|
|
2544
2658
|
resource,
|
|
2545
2659
|
isEmpty: (rows) => rows.length === 0,
|
|
2546
2660
|
emptyTitle: t.addresses.empty,
|
|
2547
2661
|
emptyDescription: t.addresses.emptyDescription,
|
|
2548
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
2662
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx32(
|
|
2549
2663
|
DataTable,
|
|
2550
2664
|
{
|
|
2551
2665
|
tableKey: "addressesPanel.table",
|
|
@@ -2554,13 +2668,13 @@ function AddressesPanel(props) {
|
|
|
2554
2668
|
rows,
|
|
2555
2669
|
columns: [
|
|
2556
2670
|
{ key: "label", label: t.addresses.label, render: (address) => address.label || address.addressLine1 },
|
|
2557
|
-
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */
|
|
2671
|
+
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
2558
2672
|
address.addressLine1,
|
|
2559
2673
|
formatAddress(address) ? `, ${formatAddress(address)}` : ""
|
|
2560
2674
|
] }) },
|
|
2561
|
-
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */
|
|
2562
|
-
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */
|
|
2563
|
-
!address.isDefault ? /* @__PURE__ */
|
|
2675
|
+
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ jsx32(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null },
|
|
2676
|
+
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ jsxs23("div", { className: "throttle-actions", children: [
|
|
2677
|
+
!address.isDefault ? /* @__PURE__ */ jsx32(
|
|
2564
2678
|
Button,
|
|
2565
2679
|
{
|
|
2566
2680
|
variant: "secondary",
|
|
@@ -2569,7 +2683,7 @@ function AddressesPanel(props) {
|
|
|
2569
2683
|
children: t.addresses.makeDefault
|
|
2570
2684
|
}
|
|
2571
2685
|
) : null,
|
|
2572
|
-
/* @__PURE__ */
|
|
2686
|
+
/* @__PURE__ */ jsx32(
|
|
2573
2687
|
Button,
|
|
2574
2688
|
{
|
|
2575
2689
|
variant: "secondary",
|
|
@@ -2578,14 +2692,14 @@ function AddressesPanel(props) {
|
|
|
2578
2692
|
children: t.common.edit
|
|
2579
2693
|
}
|
|
2580
2694
|
),
|
|
2581
|
-
/* @__PURE__ */
|
|
2695
|
+
/* @__PURE__ */ jsx32(
|
|
2582
2696
|
Button,
|
|
2583
2697
|
{
|
|
2584
2698
|
variant: "danger",
|
|
2585
2699
|
elementKey: "addressesPanel.deleteButton",
|
|
2586
2700
|
disabled: submitting,
|
|
2587
|
-
onClick: () => {
|
|
2588
|
-
if (!
|
|
2701
|
+
onClick: async () => {
|
|
2702
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
2589
2703
|
void run(() => resource.remove(address.id));
|
|
2590
2704
|
},
|
|
2591
2705
|
children: t.common.delete
|
|
@@ -2594,17 +2708,17 @@ function AddressesPanel(props) {
|
|
|
2594
2708
|
] }) }
|
|
2595
2709
|
]
|
|
2596
2710
|
}
|
|
2597
|
-
) : /* @__PURE__ */
|
|
2598
|
-
/* @__PURE__ */
|
|
2599
|
-
/* @__PURE__ */
|
|
2600
|
-
/* @__PURE__ */
|
|
2601
|
-
address.isDefault ? /* @__PURE__ */
|
|
2711
|
+
) : /* @__PURE__ */ jsx32("div", { ...a.el("addressesPanel.list", listBase), children: rows.map((address) => /* @__PURE__ */ jsxs23("div", { ...a.el("addressesPanel.item", itemBase), children: [
|
|
2712
|
+
/* @__PURE__ */ jsxs23("div", { children: [
|
|
2713
|
+
/* @__PURE__ */ jsxs23("div", { className: "throttle-row", children: [
|
|
2714
|
+
/* @__PURE__ */ jsx32("strong", { children: address.label || address.addressLine1 }),
|
|
2715
|
+
address.isDefault ? /* @__PURE__ */ jsx32(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null
|
|
2602
2716
|
] }),
|
|
2603
|
-
/* @__PURE__ */
|
|
2604
|
-
/* @__PURE__ */
|
|
2717
|
+
/* @__PURE__ */ jsx32("p", { className: "throttle-muted", children: address.addressLine1 }),
|
|
2718
|
+
/* @__PURE__ */ jsx32("p", { className: "throttle-muted", children: formatAddress(address) })
|
|
2605
2719
|
] }),
|
|
2606
|
-
/* @__PURE__ */
|
|
2607
|
-
!address.isDefault ? /* @__PURE__ */
|
|
2720
|
+
/* @__PURE__ */ jsxs23("div", { className: "throttle-actions", children: [
|
|
2721
|
+
!address.isDefault ? /* @__PURE__ */ jsx32(
|
|
2608
2722
|
Button,
|
|
2609
2723
|
{
|
|
2610
2724
|
variant: actionVariant("secondary"),
|
|
@@ -2613,7 +2727,7 @@ function AddressesPanel(props) {
|
|
|
2613
2727
|
children: t.addresses.makeDefault
|
|
2614
2728
|
}
|
|
2615
2729
|
) : null,
|
|
2616
|
-
/* @__PURE__ */
|
|
2730
|
+
/* @__PURE__ */ jsx32(
|
|
2617
2731
|
Button,
|
|
2618
2732
|
{
|
|
2619
2733
|
variant: actionVariant("secondary"),
|
|
@@ -2622,14 +2736,14 @@ function AddressesPanel(props) {
|
|
|
2622
2736
|
children: t.common.edit
|
|
2623
2737
|
}
|
|
2624
2738
|
),
|
|
2625
|
-
/* @__PURE__ */
|
|
2739
|
+
/* @__PURE__ */ jsx32(
|
|
2626
2740
|
Button,
|
|
2627
2741
|
{
|
|
2628
2742
|
variant: actionVariant("danger"),
|
|
2629
2743
|
elementKey: "addressesPanel.deleteButton",
|
|
2630
2744
|
disabled: submitting,
|
|
2631
|
-
onClick: () => {
|
|
2632
|
-
if (!
|
|
2745
|
+
onClick: async () => {
|
|
2746
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
2633
2747
|
void run(() => resource.remove(address.id));
|
|
2634
2748
|
},
|
|
2635
2749
|
children: t.common.delete
|
|
@@ -2644,7 +2758,104 @@ function AddressesPanel(props) {
|
|
|
2644
2758
|
}
|
|
2645
2759
|
|
|
2646
2760
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2647
|
-
import {
|
|
2761
|
+
import { useState as useState17 } from "react";
|
|
2762
|
+
|
|
2763
|
+
// src/react/components/account/AddCardDialog.tsx
|
|
2764
|
+
import { useEffect as useEffect7, useId as useId5, useRef as useRef7, useState as useState16 } from "react";
|
|
2765
|
+
import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2766
|
+
function AddCardDialog(props) {
|
|
2767
|
+
const { account } = useAuth();
|
|
2768
|
+
const titleId = useId5();
|
|
2769
|
+
const { t } = useCopy(props.localization);
|
|
2770
|
+
const [src, setSrc] = useState16(null);
|
|
2771
|
+
const [error, setError] = useState16(null);
|
|
2772
|
+
const [busy, setBusy] = useState16(false);
|
|
2773
|
+
const onAdded = useRef7(props.onAdded);
|
|
2774
|
+
const onClose = useRef7(props.onClose);
|
|
2775
|
+
onAdded.current = props.onAdded;
|
|
2776
|
+
onClose.current = props.onClose;
|
|
2777
|
+
useEffect7(() => {
|
|
2778
|
+
if (!props.open) {
|
|
2779
|
+
setSrc(null);
|
|
2780
|
+
setError(null);
|
|
2781
|
+
return;
|
|
2782
|
+
}
|
|
2783
|
+
let live = true;
|
|
2784
|
+
setError(null);
|
|
2785
|
+
account.startCardSetup().then(
|
|
2786
|
+
(session) => {
|
|
2787
|
+
if (!live) return;
|
|
2788
|
+
let url = session.embedUrl;
|
|
2789
|
+
try {
|
|
2790
|
+
const u = new URL(session.embedUrl, window.location.origin);
|
|
2791
|
+
u.searchParams.set("parentOrigin", window.location.origin);
|
|
2792
|
+
url = u.toString();
|
|
2793
|
+
} catch {
|
|
2794
|
+
}
|
|
2795
|
+
setSrc(url);
|
|
2796
|
+
},
|
|
2797
|
+
(err) => {
|
|
2798
|
+
if (live) setError(messageForError(err));
|
|
2799
|
+
}
|
|
2800
|
+
);
|
|
2801
|
+
return () => {
|
|
2802
|
+
live = false;
|
|
2803
|
+
};
|
|
2804
|
+
}, [props.open, account]);
|
|
2805
|
+
useEffect7(() => {
|
|
2806
|
+
if (!src) return;
|
|
2807
|
+
const frameOrigin = (() => {
|
|
2808
|
+
try {
|
|
2809
|
+
return new URL(src).origin;
|
|
2810
|
+
} catch {
|
|
2811
|
+
return null;
|
|
2812
|
+
}
|
|
2813
|
+
})();
|
|
2814
|
+
if (!frameOrigin) return;
|
|
2815
|
+
async function onMessage(event) {
|
|
2816
|
+
if (event.origin !== frameOrigin) return;
|
|
2817
|
+
const data = event.data;
|
|
2818
|
+
if (!data || typeof data.type !== "string") return;
|
|
2819
|
+
if (data.type === "throttle.completed" && data.paymentId) {
|
|
2820
|
+
setBusy(true);
|
|
2821
|
+
try {
|
|
2822
|
+
await account.confirmCardSetup(data.paymentId);
|
|
2823
|
+
onAdded.current();
|
|
2824
|
+
onClose.current();
|
|
2825
|
+
} catch (err) {
|
|
2826
|
+
setError(messageForError(err));
|
|
2827
|
+
} finally {
|
|
2828
|
+
setBusy(false);
|
|
2829
|
+
}
|
|
2830
|
+
} else if (data.type === "throttle.error") {
|
|
2831
|
+
setError(data.message || t.common.somethingWentWrong);
|
|
2832
|
+
} else if (data.type === "throttle.cancelled") {
|
|
2833
|
+
onClose.current();
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
window.addEventListener("message", onMessage);
|
|
2837
|
+
return () => window.removeEventListener("message", onMessage);
|
|
2838
|
+
}, [src, account, t]);
|
|
2839
|
+
if (!props.open) return null;
|
|
2840
|
+
return /* @__PURE__ */ jsxs24(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
|
|
2841
|
+
/* @__PURE__ */ jsx33("div", { className: "throttle-modal__header", children: /* @__PURE__ */ jsx33("h2", { id: titleId, className: "throttle-modal__title", children: t.paymentMethods.addTitle }) }),
|
|
2842
|
+
/* @__PURE__ */ jsxs24("div", { className: "throttle-modal__body", children: [
|
|
2843
|
+
error ? /* @__PURE__ */ jsx33(Alert, { tone: "error", children: error }) : null,
|
|
2844
|
+
busy ? /* @__PURE__ */ jsx33("div", { className: "throttle-centre", children: /* @__PURE__ */ jsx33(Spinner, {}) }) : src ? /* @__PURE__ */ jsx33(
|
|
2845
|
+
"iframe",
|
|
2846
|
+
{
|
|
2847
|
+
className: "throttle-cardframe",
|
|
2848
|
+
src,
|
|
2849
|
+
title: t.paymentMethods.addTitle,
|
|
2850
|
+
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
2851
|
+
}
|
|
2852
|
+
) : !error ? /* @__PURE__ */ jsx33("div", { className: "throttle-centre", children: /* @__PURE__ */ jsx33(Spinner, {}) }) : null
|
|
2853
|
+
] })
|
|
2854
|
+
] });
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2858
|
+
import { jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2648
2859
|
function PaymentMethodsPanel(props) {
|
|
2649
2860
|
const a = useAppearance(props.appearance);
|
|
2650
2861
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2652,6 +2863,8 @@ function PaymentMethodsPanel(props) {
|
|
|
2652
2863
|
const { emailVerified } = useAuth();
|
|
2653
2864
|
const resource = useSavedCards();
|
|
2654
2865
|
const { submitting, error, run } = useAction();
|
|
2866
|
+
const confirm = useConfirm();
|
|
2867
|
+
const [adding, setAdding] = useState17(false);
|
|
2655
2868
|
const variant = props.variant ?? "rows";
|
|
2656
2869
|
const rowsVariant = variant === "rows";
|
|
2657
2870
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -2659,9 +2872,21 @@ function PaymentMethodsPanel(props) {
|
|
|
2659
2872
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
2660
2873
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
2661
2874
|
const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
|
|
2662
|
-
return /* @__PURE__ */
|
|
2663
|
-
error ? /* @__PURE__ */
|
|
2664
|
-
/* @__PURE__ */
|
|
2875
|
+
return /* @__PURE__ */ jsx34(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx34("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs25("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
|
|
2876
|
+
error ? /* @__PURE__ */ jsx34(Alert, { tone: "error", children: error }) : null,
|
|
2877
|
+
emailVerified ? /* @__PURE__ */ jsx34("div", { children: /* @__PURE__ */ jsx34(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
|
|
2878
|
+
/* @__PURE__ */ jsx34(
|
|
2879
|
+
AddCardDialog,
|
|
2880
|
+
{
|
|
2881
|
+
open: adding,
|
|
2882
|
+
onClose: () => setAdding(false),
|
|
2883
|
+
onAdded: () => {
|
|
2884
|
+
void resource.refetch();
|
|
2885
|
+
},
|
|
2886
|
+
localization: props.localization
|
|
2887
|
+
}
|
|
2888
|
+
),
|
|
2889
|
+
/* @__PURE__ */ jsx34(
|
|
2665
2890
|
PanelState,
|
|
2666
2891
|
{
|
|
2667
2892
|
resource,
|
|
@@ -2670,7 +2895,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2670
2895
|
isEmpty: (rows) => rows.length === 0,
|
|
2671
2896
|
emptyTitle: t.paymentMethods.empty,
|
|
2672
2897
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
2673
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
2898
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx34(
|
|
2674
2899
|
DataTable,
|
|
2675
2900
|
{
|
|
2676
2901
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -2680,9 +2905,9 @@ function PaymentMethodsPanel(props) {
|
|
|
2680
2905
|
columns: [
|
|
2681
2906
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
2682
2907
|
{ 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__ */
|
|
2908
|
+
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ jsx34(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
|
|
2909
|
+
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ jsxs25("div", { className: "throttle-actions", children: [
|
|
2910
|
+
!card.isDefault ? /* @__PURE__ */ jsx34(
|
|
2686
2911
|
Button,
|
|
2687
2912
|
{
|
|
2688
2913
|
variant: "secondary",
|
|
@@ -2692,14 +2917,14 @@ function PaymentMethodsPanel(props) {
|
|
|
2692
2917
|
children: t.paymentMethods.makeDefault
|
|
2693
2918
|
}
|
|
2694
2919
|
) : null,
|
|
2695
|
-
/* @__PURE__ */
|
|
2920
|
+
/* @__PURE__ */ jsx34(
|
|
2696
2921
|
Button,
|
|
2697
2922
|
{
|
|
2698
2923
|
variant: "danger",
|
|
2699
2924
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
2700
2925
|
disabled: submitting,
|
|
2701
|
-
onClick: () => {
|
|
2702
|
-
if (!
|
|
2926
|
+
onClick: async () => {
|
|
2927
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
2703
2928
|
void run(() => resource.remove(card.id));
|
|
2704
2929
|
},
|
|
2705
2930
|
children: t.common.delete
|
|
@@ -2708,13 +2933,13 @@ function PaymentMethodsPanel(props) {
|
|
|
2708
2933
|
] }) }
|
|
2709
2934
|
]
|
|
2710
2935
|
}
|
|
2711
|
-
) : /* @__PURE__ */
|
|
2712
|
-
/* @__PURE__ */
|
|
2713
|
-
/* @__PURE__ */
|
|
2714
|
-
/* @__PURE__ */
|
|
2715
|
-
card.isDefault ? /* @__PURE__ */
|
|
2936
|
+
) : /* @__PURE__ */ jsx34("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ jsxs25("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
|
|
2937
|
+
/* @__PURE__ */ jsxs25("div", { children: [
|
|
2938
|
+
/* @__PURE__ */ jsxs25("div", { className: "throttle-row", children: [
|
|
2939
|
+
/* @__PURE__ */ jsx34("strong", { children: cardLabel(card) }),
|
|
2940
|
+
card.isDefault ? /* @__PURE__ */ jsx34(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
|
|
2716
2941
|
] }),
|
|
2717
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */
|
|
2942
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ jsxs25("p", { className: "throttle-muted", children: [
|
|
2718
2943
|
t.paymentMethods.expires,
|
|
2719
2944
|
" ",
|
|
2720
2945
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -2722,8 +2947,8 @@ function PaymentMethodsPanel(props) {
|
|
|
2722
2947
|
card.cardExpYear
|
|
2723
2948
|
] }) : null
|
|
2724
2949
|
] }),
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
!card.isDefault ? /* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ jsxs25("div", { className: "throttle-actions", children: [
|
|
2951
|
+
!card.isDefault ? /* @__PURE__ */ jsx34(
|
|
2727
2952
|
Button,
|
|
2728
2953
|
{
|
|
2729
2954
|
variant: actionVariant("secondary"),
|
|
@@ -2733,14 +2958,14 @@ function PaymentMethodsPanel(props) {
|
|
|
2733
2958
|
children: t.paymentMethods.makeDefault
|
|
2734
2959
|
}
|
|
2735
2960
|
) : null,
|
|
2736
|
-
/* @__PURE__ */
|
|
2961
|
+
/* @__PURE__ */ jsx34(
|
|
2737
2962
|
Button,
|
|
2738
2963
|
{
|
|
2739
2964
|
variant: actionVariant("danger"),
|
|
2740
2965
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
2741
2966
|
disabled: submitting,
|
|
2742
|
-
onClick: () => {
|
|
2743
|
-
if (!
|
|
2967
|
+
onClick: async () => {
|
|
2968
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
2744
2969
|
void run(() => resource.remove(card.id));
|
|
2745
2970
|
},
|
|
2746
2971
|
children: t.common.delete
|
|
@@ -2754,7 +2979,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2754
2979
|
}
|
|
2755
2980
|
|
|
2756
2981
|
// src/react/components/account/OrdersPanel.tsx
|
|
2757
|
-
import { useState as
|
|
2982
|
+
import { useState as useState18 } from "react";
|
|
2758
2983
|
|
|
2759
2984
|
// src/react/components/format.ts
|
|
2760
2985
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -2786,7 +3011,7 @@ function formatDate(value, locale) {
|
|
|
2786
3011
|
}
|
|
2787
3012
|
|
|
2788
3013
|
// src/react/components/account/OrderStatus.tsx
|
|
2789
|
-
import { Fragment as Fragment6, jsx as
|
|
3014
|
+
import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2790
3015
|
function copyKey(wire) {
|
|
2791
3016
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
2792
3017
|
}
|
|
@@ -2794,25 +3019,76 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
2794
3019
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
2795
3020
|
function StatusBadge(props) {
|
|
2796
3021
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2797
|
-
return /* @__PURE__ */
|
|
3022
|
+
return /* @__PURE__ */ jsx35(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
2798
3023
|
}
|
|
2799
3024
|
function OrderStatus(props) {
|
|
2800
3025
|
const labels = props.t.orders.statusLabels;
|
|
2801
3026
|
const payLabels = props.t.orders.paymentLabels;
|
|
2802
3027
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2803
3028
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
2804
|
-
return /* @__PURE__ */
|
|
2805
|
-
/* @__PURE__ */
|
|
2806
|
-
money ? /* @__PURE__ */
|
|
3029
|
+
return /* @__PURE__ */ jsxs26(Fragment6, { children: [
|
|
3030
|
+
/* @__PURE__ */ jsx35(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
|
|
3031
|
+
money ? /* @__PURE__ */ jsx35(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
|
|
3032
|
+
] });
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// src/react/components/account/AddressBlock.tsx
|
|
3036
|
+
import { jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3037
|
+
function addressLines(address) {
|
|
3038
|
+
if (!address || typeof address !== "object") return [];
|
|
3039
|
+
const a = address;
|
|
3040
|
+
const str = (k) => typeof a[k] === "string" && a[k].trim() ? a[k].trim() : null;
|
|
3041
|
+
const name = [str("firstName"), str("lastName")].filter(Boolean).join(" ");
|
|
3042
|
+
const cityLine = [str("city"), str("stateProvince"), str("postalCode")].filter(Boolean).join(", ");
|
|
3043
|
+
return [
|
|
3044
|
+
name || null,
|
|
3045
|
+
str("company"),
|
|
3046
|
+
str("addressLine1") ?? str("line1"),
|
|
3047
|
+
str("addressLine2") ?? str("line2"),
|
|
3048
|
+
cityLine || null,
|
|
3049
|
+
str("countryCode") ?? str("country")
|
|
3050
|
+
].filter((l) => Boolean(l));
|
|
3051
|
+
}
|
|
3052
|
+
function AddressBlock(props) {
|
|
3053
|
+
const a = useAppearance();
|
|
3054
|
+
const lines = addressLines(props.address);
|
|
3055
|
+
if (lines.length === 0) return null;
|
|
3056
|
+
return /* @__PURE__ */ jsxs27("div", { ...a.el(props.elementKey ?? "orderDetail.address", "throttle-addressblock"), children: [
|
|
3057
|
+
/* @__PURE__ */ jsx36("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3058
|
+
lines.map((l) => /* @__PURE__ */ jsx36("p", { className: "throttle-addressblock__line throttle-muted", children: l }, l))
|
|
3059
|
+
] });
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
// src/react/components/account/OrderTimeline.tsx
|
|
3063
|
+
import { jsx as jsx37, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
3064
|
+
function orderTimeline(order, labels) {
|
|
3065
|
+
const entries = [{ label: labels.placed, at: order.createdAt }];
|
|
3066
|
+
if (order.completedAt) entries.push({ label: labels.completed, at: order.completedAt });
|
|
3067
|
+
if (order.cancelledAt) entries.push({ label: labels.cancelled, at: order.cancelledAt });
|
|
3068
|
+
if (order.closedAt) entries.push({ label: labels.closed, at: order.closedAt });
|
|
3069
|
+
return entries.sort((x, y) => new Date(x.at).getTime() - new Date(y.at).getTime());
|
|
3070
|
+
}
|
|
3071
|
+
function OrderTimeline(props) {
|
|
3072
|
+
const a = useAppearance();
|
|
3073
|
+
if (props.entries.length <= 1) return null;
|
|
3074
|
+
return /* @__PURE__ */ jsxs28("div", { ...a.el("orderDetail.timeline", "throttle-timeline"), children: [
|
|
3075
|
+
/* @__PURE__ */ jsx37("h4", { className: "throttle-section__title", children: props.heading }),
|
|
3076
|
+
props.entries.map((e) => /* @__PURE__ */ jsxs28("div", { className: "throttle-timeline__row", children: [
|
|
3077
|
+
/* @__PURE__ */ jsx37("span", { className: "throttle-timeline__dot", "aria-hidden": "true" }),
|
|
3078
|
+
/* @__PURE__ */ jsx37("span", { className: "throttle-timeline__label", children: e.label }),
|
|
3079
|
+
/* @__PURE__ */ jsx37("span", { className: "throttle-muted", children: formatDate(e.at, props.locale) })
|
|
3080
|
+
] }, `${e.label}-${e.at}`))
|
|
2807
3081
|
] });
|
|
2808
3082
|
}
|
|
2809
3083
|
|
|
2810
3084
|
// src/react/components/account/OrderDetail.tsx
|
|
2811
|
-
import { Fragment as Fragment7, jsx as
|
|
3085
|
+
import { Fragment as Fragment7, jsx as jsx38, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
3086
|
+
var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
|
|
3087
|
+
var CAN_REORDER = /* @__PURE__ */ new Set(["fulfilled", "cancelled", "closed"]);
|
|
2812
3088
|
function Line(props) {
|
|
2813
|
-
return /* @__PURE__ */
|
|
2814
|
-
/* @__PURE__ */
|
|
2815
|
-
/* @__PURE__ */
|
|
3089
|
+
return /* @__PURE__ */ jsxs29("div", { className: "throttle-row", children: [
|
|
3090
|
+
/* @__PURE__ */ jsx38("span", { className: "throttle-muted", children: props.label }),
|
|
3091
|
+
/* @__PURE__ */ jsx38("span", { children: props.value })
|
|
2816
3092
|
] });
|
|
2817
3093
|
}
|
|
2818
3094
|
function OrderDetail(props) {
|
|
@@ -2820,7 +3096,7 @@ function OrderDetail(props) {
|
|
|
2820
3096
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2821
3097
|
const { t, locale } = useCopy(props.localization);
|
|
2822
3098
|
const resource = useOrder(props.orderId);
|
|
2823
|
-
return /* @__PURE__ */
|
|
3099
|
+
return /* @__PURE__ */ jsx38(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx38("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs29("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
|
|
2824
3100
|
props.onBack ? (
|
|
2825
3101
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
2826
3102
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -2828,27 +3104,27 @@ function OrderDetail(props) {
|
|
|
2828
3104
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
2829
3105
|
// its own width. A CSS fix would need a compound selector, and
|
|
2830
3106
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
2831
|
-
/* @__PURE__ */
|
|
3107
|
+
/* @__PURE__ */ jsx38("div", { children: /* @__PURE__ */ jsx38(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
2832
3108
|
) : null,
|
|
2833
|
-
/* @__PURE__ */
|
|
3109
|
+
/* @__PURE__ */ jsx38(
|
|
2834
3110
|
PanelState,
|
|
2835
3111
|
{
|
|
2836
3112
|
resource,
|
|
2837
3113
|
isEmpty: (o) => o === null,
|
|
2838
3114
|
emptyTitle: t.orders.empty,
|
|
2839
3115
|
skeletonRows: 5,
|
|
2840
|
-
children: (order) => /* @__PURE__ */
|
|
2841
|
-
/* @__PURE__ */
|
|
2842
|
-
/* @__PURE__ */
|
|
2843
|
-
/* @__PURE__ */
|
|
3116
|
+
children: (order) => /* @__PURE__ */ jsxs29(Fragment7, { children: [
|
|
3117
|
+
/* @__PURE__ */ jsxs29("div", { className: "throttle-row", children: [
|
|
3118
|
+
/* @__PURE__ */ jsx38("h3", { children: order.orderNumber }),
|
|
3119
|
+
/* @__PURE__ */ jsx38(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
|
|
2844
3120
|
] }),
|
|
2845
|
-
/* @__PURE__ */
|
|
2846
|
-
/* @__PURE__ */
|
|
2847
|
-
item.imageUrl ? /* @__PURE__ */
|
|
2848
|
-
/* @__PURE__ */
|
|
2849
|
-
/* @__PURE__ */
|
|
2850
|
-
item.description ? /* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
3121
|
+
/* @__PURE__ */ jsx38("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
|
|
3122
|
+
/* @__PURE__ */ jsx38("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ jsxs29("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
|
|
3123
|
+
item.imageUrl ? /* @__PURE__ */ jsx38("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
|
|
3124
|
+
/* @__PURE__ */ jsxs29("div", { style: { flex: 1 }, children: [
|
|
3125
|
+
/* @__PURE__ */ jsx38("strong", { children: item.name }),
|
|
3126
|
+
item.description ? /* @__PURE__ */ jsx38("p", { className: "throttle-muted", children: item.description }) : null,
|
|
3127
|
+
/* @__PURE__ */ jsxs29("p", { className: "throttle-muted", children: [
|
|
2852
3128
|
t.orders.quantity,
|
|
2853
3129
|
" ",
|
|
2854
3130
|
item.quantity,
|
|
@@ -2856,16 +3132,87 @@ function OrderDetail(props) {
|
|
|
2856
3132
|
formatMoney(item.unitPrice, order.currency, locale)
|
|
2857
3133
|
] })
|
|
2858
3134
|
] }),
|
|
2859
|
-
/* @__PURE__ */
|
|
3135
|
+
/* @__PURE__ */ jsx38("span", { children: formatMoney(item.total, order.currency, locale) })
|
|
2860
3136
|
] }, item.id)) }),
|
|
2861
|
-
/* @__PURE__ */
|
|
2862
|
-
/* @__PURE__ */
|
|
2863
|
-
order.discountTotal ? /* @__PURE__ */
|
|
2864
|
-
/* @__PURE__ */
|
|
2865
|
-
/* @__PURE__ */
|
|
2866
|
-
/* @__PURE__ */
|
|
3137
|
+
/* @__PURE__ */ jsxs29("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
|
|
3138
|
+
/* @__PURE__ */ jsx38(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
|
|
3139
|
+
order.discountTotal ? /* @__PURE__ */ jsx38(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
|
|
3140
|
+
/* @__PURE__ */ jsx38(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
|
|
3141
|
+
/* @__PURE__ */ jsx38(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
|
|
3142
|
+
/* @__PURE__ */ jsx38(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
|
|
3143
|
+
] }),
|
|
3144
|
+
/* @__PURE__ */ jsxs29("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
|
|
3145
|
+
/* @__PURE__ */ jsx38(
|
|
3146
|
+
AddressBlock,
|
|
3147
|
+
{
|
|
3148
|
+
heading: t.orders.shipTo,
|
|
3149
|
+
address: order.shippingAddress,
|
|
3150
|
+
elementKey: "orderDetail.shippingAddress"
|
|
3151
|
+
}
|
|
3152
|
+
),
|
|
3153
|
+
/* @__PURE__ */ jsx38(
|
|
3154
|
+
AddressBlock,
|
|
3155
|
+
{
|
|
3156
|
+
heading: t.orders.billTo,
|
|
3157
|
+
address: order.billingAddress,
|
|
3158
|
+
elementKey: "orderDetail.billingAddress"
|
|
3159
|
+
}
|
|
3160
|
+
)
|
|
2867
3161
|
] }),
|
|
2868
|
-
|
|
3162
|
+
/* @__PURE__ */ jsx38(
|
|
3163
|
+
OrderTimeline,
|
|
3164
|
+
{
|
|
3165
|
+
heading: t.orders.history,
|
|
3166
|
+
locale,
|
|
3167
|
+
entries: orderTimeline(order, {
|
|
3168
|
+
placed: t.orders.placed,
|
|
3169
|
+
completed: t.orders.completed,
|
|
3170
|
+
cancelled: t.orders.cancelledAt,
|
|
3171
|
+
closed: t.orders.closedAt
|
|
3172
|
+
})
|
|
3173
|
+
}
|
|
3174
|
+
),
|
|
3175
|
+
(() => {
|
|
3176
|
+
const target = {
|
|
3177
|
+
id: order.id,
|
|
3178
|
+
orderNumber: order.orderNumber,
|
|
3179
|
+
currency: order.currency,
|
|
3180
|
+
lineItems: order.lineItems.map((li) => ({
|
|
3181
|
+
name: li.name,
|
|
3182
|
+
unitPrice: li.unitPrice,
|
|
3183
|
+
quantity: li.quantity
|
|
3184
|
+
}))
|
|
3185
|
+
};
|
|
3186
|
+
return /* @__PURE__ */ jsxs29("div", { className: "throttle-actions", children: [
|
|
3187
|
+
props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ jsx38(
|
|
3188
|
+
Button,
|
|
3189
|
+
{
|
|
3190
|
+
elementKey: "orderDetail.payButton",
|
|
3191
|
+
onClick: () => props.onPayNow(target),
|
|
3192
|
+
children: t.orders.payNow
|
|
3193
|
+
}
|
|
3194
|
+
) : null,
|
|
3195
|
+
props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ jsx38(
|
|
3196
|
+
Button,
|
|
3197
|
+
{
|
|
3198
|
+
variant: "secondary",
|
|
3199
|
+
elementKey: "orderDetail.trackButton",
|
|
3200
|
+
onClick: () => props.onTrackShipment(target),
|
|
3201
|
+
children: t.orders.track
|
|
3202
|
+
}
|
|
3203
|
+
) : null,
|
|
3204
|
+
props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ jsx38(
|
|
3205
|
+
Button,
|
|
3206
|
+
{
|
|
3207
|
+
variant: "secondary",
|
|
3208
|
+
elementKey: "orderDetail.reorderButton",
|
|
3209
|
+
onClick: () => props.onReorder(target),
|
|
3210
|
+
children: t.orders.reorder
|
|
3211
|
+
}
|
|
3212
|
+
) : null,
|
|
3213
|
+
order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ jsx38(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
|
|
3214
|
+
] });
|
|
3215
|
+
})()
|
|
2869
3216
|
] })
|
|
2870
3217
|
}
|
|
2871
3218
|
)
|
|
@@ -2873,31 +3220,34 @@ function OrderDetail(props) {
|
|
|
2873
3220
|
}
|
|
2874
3221
|
|
|
2875
3222
|
// src/react/components/account/OrdersPanel.tsx
|
|
2876
|
-
import { jsx as
|
|
3223
|
+
import { jsx as jsx39, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2877
3224
|
function OrdersPanel(props) {
|
|
2878
3225
|
const a = useAppearance(props.appearance);
|
|
2879
3226
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2880
3227
|
const { t, locale } = useCopy(props.localization);
|
|
2881
3228
|
const { emailVerified } = useAuth();
|
|
2882
3229
|
const resource = useOrders();
|
|
2883
|
-
const [openId, setOpenId] =
|
|
3230
|
+
const [openId, setOpenId] = useState18(null);
|
|
2884
3231
|
const variant = props.variant ?? "table";
|
|
2885
3232
|
const rowsVariant = variant === "rows";
|
|
2886
3233
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
2887
3234
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
2888
3235
|
if (openId) {
|
|
2889
|
-
return /* @__PURE__ */
|
|
3236
|
+
return /* @__PURE__ */ jsx39(
|
|
2890
3237
|
OrderDetail,
|
|
2891
3238
|
{
|
|
2892
3239
|
orderId: openId,
|
|
2893
3240
|
onBack: () => setOpenId(null),
|
|
3241
|
+
onPayNow: props.onPayNow,
|
|
3242
|
+
onReorder: props.onReorder,
|
|
3243
|
+
onTrackShipment: props.onTrackShipment,
|
|
2894
3244
|
onViewSubscription: props.onViewSubscription,
|
|
2895
3245
|
appearance: props.appearance,
|
|
2896
3246
|
localization: props.localization
|
|
2897
3247
|
}
|
|
2898
3248
|
);
|
|
2899
3249
|
}
|
|
2900
|
-
return /* @__PURE__ */
|
|
3250
|
+
return /* @__PURE__ */ jsx39(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx39("div", { ...a.rootProps, children: /* @__PURE__ */ jsx39("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ jsx39(
|
|
2901
3251
|
PanelState,
|
|
2902
3252
|
{
|
|
2903
3253
|
resource,
|
|
@@ -2906,7 +3256,7 @@ function OrdersPanel(props) {
|
|
|
2906
3256
|
isEmpty: (rows) => rows.length === 0,
|
|
2907
3257
|
emptyTitle: t.orders.empty,
|
|
2908
3258
|
emptyDescription: t.orders.emptyDescription,
|
|
2909
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3259
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx39(
|
|
2910
3260
|
DataTable,
|
|
2911
3261
|
{
|
|
2912
3262
|
tableKey: "ordersPanel.table",
|
|
@@ -2920,25 +3270,25 @@ function OrdersPanel(props) {
|
|
|
2920
3270
|
{
|
|
2921
3271
|
key: "status",
|
|
2922
3272
|
label: t.orders.status,
|
|
2923
|
-
render: (o) => /* @__PURE__ */
|
|
3273
|
+
render: (o) => /* @__PURE__ */ jsx39(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
2924
3274
|
},
|
|
2925
3275
|
{
|
|
2926
3276
|
key: "total",
|
|
2927
3277
|
label: t.orders.total,
|
|
2928
|
-
render: (o) => /* @__PURE__ */
|
|
3278
|
+
render: (o) => /* @__PURE__ */ jsx39("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
2929
3279
|
}
|
|
2930
3280
|
]
|
|
2931
3281
|
}
|
|
2932
|
-
) : /* @__PURE__ */
|
|
2933
|
-
/* @__PURE__ */
|
|
2934
|
-
/* @__PURE__ */
|
|
2935
|
-
/* @__PURE__ */
|
|
2936
|
-
/* @__PURE__ */
|
|
3282
|
+
) : /* @__PURE__ */ jsx39("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ jsxs30("div", { ...a.el("ordersPanel.item", itemBase), children: [
|
|
3283
|
+
/* @__PURE__ */ jsxs30("div", { children: [
|
|
3284
|
+
/* @__PURE__ */ jsxs30("div", { className: "throttle-row", children: [
|
|
3285
|
+
/* @__PURE__ */ jsx39("strong", { children: o.orderNumber }),
|
|
3286
|
+
/* @__PURE__ */ jsx39(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
2937
3287
|
] }),
|
|
2938
|
-
/* @__PURE__ */
|
|
2939
|
-
/* @__PURE__ */
|
|
3288
|
+
/* @__PURE__ */ jsx39("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
|
|
3289
|
+
/* @__PURE__ */ jsx39("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
|
|
2940
3290
|
] }),
|
|
2941
|
-
/* @__PURE__ */
|
|
3291
|
+
/* @__PURE__ */ jsx39("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx39(
|
|
2942
3292
|
Button,
|
|
2943
3293
|
{
|
|
2944
3294
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -2953,14 +3303,14 @@ function OrdersPanel(props) {
|
|
|
2953
3303
|
}
|
|
2954
3304
|
|
|
2955
3305
|
// src/react/components/account/InvoicesPanel.tsx
|
|
2956
|
-
import { useState as
|
|
3306
|
+
import { useState as useState19 } from "react";
|
|
2957
3307
|
|
|
2958
3308
|
// src/react/components/account/InvoiceDetail.tsx
|
|
2959
|
-
import { Fragment as Fragment8, jsx as
|
|
3309
|
+
import { Fragment as Fragment8, jsx as jsx40, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
2960
3310
|
function Line2(props) {
|
|
2961
|
-
return /* @__PURE__ */
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
3311
|
+
return /* @__PURE__ */ jsxs31("div", { className: "throttle-row", children: [
|
|
3312
|
+
/* @__PURE__ */ jsx40("span", { className: "throttle-muted", children: props.label }),
|
|
3313
|
+
/* @__PURE__ */ jsx40("span", { children: props.value })
|
|
2964
3314
|
] });
|
|
2965
3315
|
}
|
|
2966
3316
|
function InvoiceDetail(props) {
|
|
@@ -2970,7 +3320,7 @@ function InvoiceDetail(props) {
|
|
|
2970
3320
|
const { account } = useAuth();
|
|
2971
3321
|
const resource = useInvoice(props.invoiceId);
|
|
2972
3322
|
const { submitting, error, run } = useAction();
|
|
2973
|
-
return /* @__PURE__ */
|
|
3323
|
+
return /* @__PURE__ */ jsx40(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx40("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs31("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
|
|
2974
3324
|
props.onBack ? (
|
|
2975
3325
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
2976
3326
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -2978,25 +3328,25 @@ function InvoiceDetail(props) {
|
|
|
2978
3328
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
2979
3329
|
// its own width. A CSS fix would need a compound selector, and
|
|
2980
3330
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
2981
|
-
/* @__PURE__ */
|
|
3331
|
+
/* @__PURE__ */ jsx40("div", { children: /* @__PURE__ */ jsx40(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
2982
3332
|
) : null,
|
|
2983
|
-
/* @__PURE__ */
|
|
2984
|
-
/* @__PURE__ */
|
|
2985
|
-
/* @__PURE__ */
|
|
2986
|
-
/* @__PURE__ */
|
|
3333
|
+
/* @__PURE__ */ jsx40(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ jsxs31(Fragment8, { children: [
|
|
3334
|
+
/* @__PURE__ */ jsxs31("div", { className: "throttle-row", children: [
|
|
3335
|
+
/* @__PURE__ */ jsx40("h3", { children: invoice.number }),
|
|
3336
|
+
/* @__PURE__ */ jsx40(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
|
|
2987
3337
|
] }),
|
|
2988
|
-
/* @__PURE__ */
|
|
2989
|
-
/* @__PURE__ */
|
|
2990
|
-
invoice.dueAt ? /* @__PURE__ */
|
|
2991
|
-
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */
|
|
3338
|
+
/* @__PURE__ */ jsxs31("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
|
|
3339
|
+
/* @__PURE__ */ jsx40(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
|
|
3340
|
+
invoice.dueAt ? /* @__PURE__ */ jsx40(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
|
|
3341
|
+
invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ jsx40(
|
|
2992
3342
|
Line2,
|
|
2993
3343
|
{
|
|
2994
3344
|
label: t.invoices.period,
|
|
2995
3345
|
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
2996
3346
|
}
|
|
2997
3347
|
) : null,
|
|
2998
|
-
/* @__PURE__ */
|
|
2999
|
-
invoice.amountRefunded ? /* @__PURE__ */
|
|
3348
|
+
/* @__PURE__ */ jsx40(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
|
|
3349
|
+
invoice.amountRefunded ? /* @__PURE__ */ jsx40(
|
|
3000
3350
|
Line2,
|
|
3001
3351
|
{
|
|
3002
3352
|
label: t.invoices.refunded,
|
|
@@ -3004,8 +3354,8 @@ function InvoiceDetail(props) {
|
|
|
3004
3354
|
}
|
|
3005
3355
|
) : null
|
|
3006
3356
|
] }),
|
|
3007
|
-
error ? /* @__PURE__ */
|
|
3008
|
-
/* @__PURE__ */
|
|
3357
|
+
error ? /* @__PURE__ */ jsx40(Alert, { tone: "error", children: error }) : null,
|
|
3358
|
+
/* @__PURE__ */ jsx40(
|
|
3009
3359
|
Button,
|
|
3010
3360
|
{
|
|
3011
3361
|
variant: "secondary",
|
|
@@ -3024,20 +3374,20 @@ function InvoiceDetail(props) {
|
|
|
3024
3374
|
}
|
|
3025
3375
|
|
|
3026
3376
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3027
|
-
import { jsx as
|
|
3377
|
+
import { jsx as jsx41, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3028
3378
|
function InvoicesPanel(props) {
|
|
3029
3379
|
const a = useAppearance(props.appearance);
|
|
3030
3380
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3031
3381
|
const { t, locale } = useCopy(props.localization);
|
|
3032
3382
|
const { emailVerified } = useAuth();
|
|
3033
3383
|
const resource = useInvoices();
|
|
3034
|
-
const [openId, setOpenId] =
|
|
3384
|
+
const [openId, setOpenId] = useState19(null);
|
|
3035
3385
|
const variant = props.variant ?? "table";
|
|
3036
3386
|
const rowsVariant = variant === "rows";
|
|
3037
3387
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3038
3388
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3039
3389
|
if (openId) {
|
|
3040
|
-
return /* @__PURE__ */
|
|
3390
|
+
return /* @__PURE__ */ jsx41(
|
|
3041
3391
|
InvoiceDetail,
|
|
3042
3392
|
{
|
|
3043
3393
|
invoiceId: openId,
|
|
@@ -3047,7 +3397,7 @@ function InvoicesPanel(props) {
|
|
|
3047
3397
|
}
|
|
3048
3398
|
);
|
|
3049
3399
|
}
|
|
3050
|
-
return /* @__PURE__ */
|
|
3400
|
+
return /* @__PURE__ */ jsx41(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx41("div", { ...a.rootProps, children: /* @__PURE__ */ jsx41("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ jsx41(
|
|
3051
3401
|
PanelState,
|
|
3052
3402
|
{
|
|
3053
3403
|
resource,
|
|
@@ -3056,7 +3406,7 @@ function InvoicesPanel(props) {
|
|
|
3056
3406
|
isEmpty: (rows) => rows.length === 0,
|
|
3057
3407
|
emptyTitle: t.invoices.empty,
|
|
3058
3408
|
emptyDescription: t.invoices.emptyDescription,
|
|
3059
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3409
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx41(
|
|
3060
3410
|
DataTable,
|
|
3061
3411
|
{
|
|
3062
3412
|
tableKey: "invoicesPanel.table",
|
|
@@ -3067,24 +3417,24 @@ function InvoicesPanel(props) {
|
|
|
3067
3417
|
columns: [
|
|
3068
3418
|
{ key: "number", label: t.invoices.number },
|
|
3069
3419
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
3070
|
-
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */
|
|
3420
|
+
{ key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ jsx41(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
|
|
3071
3421
|
{
|
|
3072
3422
|
key: "total",
|
|
3073
3423
|
label: t.invoices.total,
|
|
3074
|
-
render: (i) => /* @__PURE__ */
|
|
3424
|
+
render: (i) => /* @__PURE__ */ jsx41("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
3075
3425
|
}
|
|
3076
3426
|
]
|
|
3077
3427
|
}
|
|
3078
|
-
) : /* @__PURE__ */
|
|
3079
|
-
/* @__PURE__ */
|
|
3080
|
-
/* @__PURE__ */
|
|
3081
|
-
/* @__PURE__ */
|
|
3082
|
-
/* @__PURE__ */
|
|
3428
|
+
) : /* @__PURE__ */ jsx41("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ jsxs32("div", { ...a.el("invoicesPanel.item", itemBase), children: [
|
|
3429
|
+
/* @__PURE__ */ jsxs32("div", { children: [
|
|
3430
|
+
/* @__PURE__ */ jsxs32("div", { className: "throttle-row", children: [
|
|
3431
|
+
/* @__PURE__ */ jsx41("strong", { children: i.number }),
|
|
3432
|
+
/* @__PURE__ */ jsx41(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
|
|
3083
3433
|
] }),
|
|
3084
|
-
/* @__PURE__ */
|
|
3085
|
-
/* @__PURE__ */
|
|
3434
|
+
/* @__PURE__ */ jsx41("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
|
|
3435
|
+
/* @__PURE__ */ jsx41("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
|
|
3086
3436
|
] }),
|
|
3087
|
-
/* @__PURE__ */
|
|
3437
|
+
/* @__PURE__ */ jsx41("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx41(
|
|
3088
3438
|
Button,
|
|
3089
3439
|
{
|
|
3090
3440
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3099,7 +3449,7 @@ function InvoicesPanel(props) {
|
|
|
3099
3449
|
}
|
|
3100
3450
|
|
|
3101
3451
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3102
|
-
import { jsx as
|
|
3452
|
+
import { jsx as jsx42, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
3103
3453
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
3104
3454
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
3105
3455
|
var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
@@ -3110,62 +3460,79 @@ function SubscriptionsPanel(props) {
|
|
|
3110
3460
|
const { emailVerified } = useAuth();
|
|
3111
3461
|
const resource = useSubscriptions();
|
|
3112
3462
|
const { submitting, error, run } = useAction();
|
|
3463
|
+
const confirm = useConfirm();
|
|
3113
3464
|
const variant = props.variant ?? "rows";
|
|
3114
3465
|
const rowsVariant = variant === "rows";
|
|
3115
3466
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3116
3467
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3117
3468
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3118
|
-
const confirmThen = (fn) => () => {
|
|
3119
|
-
|
|
3120
|
-
|
|
3469
|
+
const confirmThen = (fn, ask) => () => {
|
|
3470
|
+
void (async () => {
|
|
3471
|
+
if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
|
|
3472
|
+
await run(fn);
|
|
3473
|
+
})();
|
|
3121
3474
|
};
|
|
3122
3475
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3123
3476
|
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__ */
|
|
3477
|
+
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ jsxs33("div", { className: "throttle-actions", children: [
|
|
3478
|
+
CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ jsx42(
|
|
3126
3479
|
Button,
|
|
3127
3480
|
{
|
|
3128
3481
|
variant: variantFor("secondary"),
|
|
3129
3482
|
loading: submitting,
|
|
3130
3483
|
elementKey: "subscriptionsPanel.pauseButton",
|
|
3131
|
-
onClick: (
|
|
3484
|
+
onClick: confirmThen(() => resource.pause(sub.id), {
|
|
3485
|
+
title: t.subscriptions.pauseConfirm,
|
|
3486
|
+
confirmLabel: t.subscriptions.pauseButton
|
|
3487
|
+
}),
|
|
3132
3488
|
children: t.subscriptions.pauseButton
|
|
3133
3489
|
}
|
|
3134
3490
|
) : null,
|
|
3135
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */
|
|
3491
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ jsx42(
|
|
3136
3492
|
Button,
|
|
3137
3493
|
{
|
|
3138
3494
|
variant: variantFor("secondary"),
|
|
3139
3495
|
loading: submitting,
|
|
3140
3496
|
elementKey: "subscriptionsPanel.resumeButton",
|
|
3141
|
-
onClick: (
|
|
3497
|
+
onClick: confirmThen(() => resource.resume(sub.id), {
|
|
3498
|
+
title: t.subscriptions.resumeConfirm,
|
|
3499
|
+
confirmLabel: t.subscriptions.resumeButton
|
|
3500
|
+
}),
|
|
3142
3501
|
children: t.subscriptions.resumeButton
|
|
3143
3502
|
}
|
|
3144
3503
|
) : null,
|
|
3145
|
-
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3504
|
+
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx42(
|
|
3146
3505
|
Button,
|
|
3147
3506
|
{
|
|
3148
3507
|
variant: variantFor("secondary"),
|
|
3149
3508
|
elementKey: "subscriptionsPanel.cancelButton",
|
|
3150
3509
|
disabled: submitting,
|
|
3151
|
-
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: true })
|
|
3510
|
+
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: true }), {
|
|
3511
|
+
title: t.subscriptions.cancelConfirm,
|
|
3512
|
+
confirmLabel: t.subscriptions.cancelConfirmAction,
|
|
3513
|
+
tone: "danger"
|
|
3514
|
+
}),
|
|
3152
3515
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
3153
3516
|
}
|
|
3154
3517
|
) : null,
|
|
3155
|
-
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */
|
|
3518
|
+
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ jsx42(
|
|
3156
3519
|
Button,
|
|
3157
3520
|
{
|
|
3158
3521
|
variant: variantFor("danger"),
|
|
3159
3522
|
elementKey: "subscriptionsPanel.cancelNowButton",
|
|
3160
3523
|
disabled: submitting,
|
|
3161
|
-
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: false })
|
|
3524
|
+
onClick: confirmThen(() => resource.cancel(sub.id, { atPeriodEnd: false }), {
|
|
3525
|
+
title: t.subscriptions.cancelNowConfirm,
|
|
3526
|
+
confirmLabel: t.subscriptions.cancelConfirmAction,
|
|
3527
|
+
tone: "danger"
|
|
3528
|
+
}),
|
|
3162
3529
|
children: t.subscriptions.cancelNow
|
|
3163
3530
|
}
|
|
3164
3531
|
) : null
|
|
3165
3532
|
] });
|
|
3166
|
-
return /* @__PURE__ */
|
|
3167
|
-
error ? /* @__PURE__ */
|
|
3168
|
-
/* @__PURE__ */
|
|
3533
|
+
return /* @__PURE__ */ jsx42(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx42("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs33("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
|
|
3534
|
+
error ? /* @__PURE__ */ jsx42(Alert, { tone: "error", children: error }) : null,
|
|
3535
|
+
/* @__PURE__ */ jsx42(
|
|
3169
3536
|
PanelState,
|
|
3170
3537
|
{
|
|
3171
3538
|
resource,
|
|
@@ -3174,7 +3541,7 @@ function SubscriptionsPanel(props) {
|
|
|
3174
3541
|
isEmpty: (rows) => rows.length === 0,
|
|
3175
3542
|
emptyTitle: t.subscriptions.empty,
|
|
3176
3543
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
3177
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3544
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx42(
|
|
3178
3545
|
DataTable,
|
|
3179
3546
|
{
|
|
3180
3547
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -3183,42 +3550,42 @@ function SubscriptionsPanel(props) {
|
|
|
3183
3550
|
rows,
|
|
3184
3551
|
columns: [
|
|
3185
3552
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
3186
|
-
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */
|
|
3553
|
+
{ key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ jsx42("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
|
|
3187
3554
|
{ 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__ */
|
|
3555
|
+
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ jsxs33("div", { className: "throttle-row", children: [
|
|
3556
|
+
/* @__PURE__ */ jsx42(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
|
|
3557
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx42(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3191
3558
|
] }) },
|
|
3192
3559
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
3193
3560
|
]
|
|
3194
3561
|
}
|
|
3195
|
-
) : /* @__PURE__ */
|
|
3196
|
-
/* @__PURE__ */
|
|
3197
|
-
/* @__PURE__ */
|
|
3198
|
-
/* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */
|
|
3562
|
+
) : /* @__PURE__ */ jsx42("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ jsxs33("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
|
|
3563
|
+
/* @__PURE__ */ jsxs33("div", { children: [
|
|
3564
|
+
/* @__PURE__ */ jsxs33("div", { className: "throttle-row", children: [
|
|
3565
|
+
/* @__PURE__ */ jsx42("strong", { children: sub.planName ?? sub.planReference }),
|
|
3566
|
+
/* @__PURE__ */ jsx42(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
|
|
3200
3567
|
] }),
|
|
3201
|
-
/* @__PURE__ */
|
|
3568
|
+
/* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3202
3569
|
formatMoney(sub.amount, sub.currency, locale),
|
|
3203
3570
|
" / ",
|
|
3204
3571
|
sub.interval,
|
|
3205
3572
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3206
3573
|
] }),
|
|
3207
|
-
sub.status === "cancelled" ? /* @__PURE__ */
|
|
3574
|
+
sub.status === "cancelled" ? /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3208
3575
|
t.subscriptions.cancelledOn,
|
|
3209
3576
|
" ",
|
|
3210
3577
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
3211
|
-
] }) : /* @__PURE__ */
|
|
3578
|
+
] }) : /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3212
3579
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
3213
3580
|
" ",
|
|
3214
3581
|
formatDate(sub.currentPeriodEnd, locale)
|
|
3215
3582
|
] }),
|
|
3216
|
-
sub.trialEnd ? /* @__PURE__ */
|
|
3583
|
+
sub.trialEnd ? /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3217
3584
|
t.subscriptions.trialEnds,
|
|
3218
3585
|
" ",
|
|
3219
3586
|
formatDate(sub.trialEnd, locale)
|
|
3220
3587
|
] }) : null,
|
|
3221
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3588
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx42(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3222
3589
|
] }),
|
|
3223
3590
|
lifecycleActions(sub, actionVariant)
|
|
3224
3591
|
] }, sub.id)) })
|
|
@@ -3228,7 +3595,7 @@ function SubscriptionsPanel(props) {
|
|
|
3228
3595
|
}
|
|
3229
3596
|
|
|
3230
3597
|
// src/react/components/account/SecurityPanel.tsx
|
|
3231
|
-
import { useCallback as
|
|
3598
|
+
import { useCallback as useCallback3, useEffect as useEffect8, useRef as useRef8, useState as useState20 } from "react";
|
|
3232
3599
|
|
|
3233
3600
|
// src/react/components/account/device.ts
|
|
3234
3601
|
var BROWSERS = [
|
|
@@ -3261,7 +3628,7 @@ function describeDevice(userAgent) {
|
|
|
3261
3628
|
}
|
|
3262
3629
|
|
|
3263
3630
|
// src/react/components/account/SecurityPanel.tsx
|
|
3264
|
-
import { Fragment as Fragment9, jsx as
|
|
3631
|
+
import { Fragment as Fragment9, jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3265
3632
|
function SecurityPanel(props) {
|
|
3266
3633
|
const a = useAppearance(props.appearance);
|
|
3267
3634
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3271,16 +3638,16 @@ function SecurityPanel(props) {
|
|
|
3271
3638
|
const rowsVariant = variant === "rows";
|
|
3272
3639
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3273
3640
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
3274
|
-
const [password, setPassword] =
|
|
3641
|
+
const [password, setPassword] = useState20("");
|
|
3275
3642
|
const passwordAction = useAction();
|
|
3276
3643
|
const sessionAction = useAction();
|
|
3277
|
-
const [sessions, setSessions] =
|
|
3278
|
-
const [listError, setListError] =
|
|
3279
|
-
const errorMessageRef =
|
|
3280
|
-
|
|
3644
|
+
const [sessions, setSessions] = useState20(null);
|
|
3645
|
+
const [listError, setListError] = useState20(null);
|
|
3646
|
+
const errorMessageRef = useRef8(errorMessage);
|
|
3647
|
+
useEffect8(() => {
|
|
3281
3648
|
errorMessageRef.current = errorMessage;
|
|
3282
3649
|
});
|
|
3283
|
-
const load =
|
|
3650
|
+
const load = useCallback3(async () => {
|
|
3284
3651
|
try {
|
|
3285
3652
|
setSessions(await auth.listSessions());
|
|
3286
3653
|
setListError(null);
|
|
@@ -3288,12 +3655,12 @@ function SecurityPanel(props) {
|
|
|
3288
3655
|
setListError(errorMessageRef.current(err));
|
|
3289
3656
|
}
|
|
3290
3657
|
}, [auth]);
|
|
3291
|
-
|
|
3658
|
+
useEffect8(() => {
|
|
3292
3659
|
void load();
|
|
3293
3660
|
}, [load]);
|
|
3294
3661
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
3295
|
-
return /* @__PURE__ */
|
|
3296
|
-
/* @__PURE__ */
|
|
3662
|
+
return /* @__PURE__ */ jsx43(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx43("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs34("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
|
|
3663
|
+
/* @__PURE__ */ jsxs34(
|
|
3297
3664
|
"form",
|
|
3298
3665
|
{
|
|
3299
3666
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -3306,8 +3673,8 @@ function SecurityPanel(props) {
|
|
|
3306
3673
|
});
|
|
3307
3674
|
},
|
|
3308
3675
|
children: [
|
|
3309
|
-
/* @__PURE__ */
|
|
3310
|
-
/* @__PURE__ */
|
|
3676
|
+
/* @__PURE__ */ jsx43("h3", { children: t.security.passwordTitle }),
|
|
3677
|
+
/* @__PURE__ */ jsx43(
|
|
3311
3678
|
Field,
|
|
3312
3679
|
{
|
|
3313
3680
|
label: t.security.newPassword,
|
|
@@ -3318,21 +3685,21 @@ function SecurityPanel(props) {
|
|
|
3318
3685
|
onChange: setPassword
|
|
3319
3686
|
}
|
|
3320
3687
|
),
|
|
3321
|
-
passwordAction.error ? /* @__PURE__ */
|
|
3322
|
-
passwordAction.notice ? /* @__PURE__ */
|
|
3323
|
-
/* @__PURE__ */
|
|
3688
|
+
passwordAction.error ? /* @__PURE__ */ jsx43(Alert, { tone: "error", children: passwordAction.error }) : null,
|
|
3689
|
+
passwordAction.notice ? /* @__PURE__ */ jsx43(Alert, { tone: "success", children: passwordAction.notice }) : null,
|
|
3690
|
+
/* @__PURE__ */ jsx43(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
|
|
3324
3691
|
]
|
|
3325
3692
|
}
|
|
3326
3693
|
),
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3329
|
-
listError ? /* @__PURE__ */
|
|
3330
|
-
/* @__PURE__ */
|
|
3331
|
-
/* @__PURE__ */
|
|
3694
|
+
/* @__PURE__ */ jsxs34("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
|
|
3695
|
+
/* @__PURE__ */ jsx43("h3", { children: t.security.sessionsTitle }),
|
|
3696
|
+
listError ? /* @__PURE__ */ jsxs34(Fragment9, { children: [
|
|
3697
|
+
/* @__PURE__ */ jsx43(Alert, { tone: "error", children: listError }),
|
|
3698
|
+
/* @__PURE__ */ jsx43(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
|
|
3332
3699
|
] }) : null,
|
|
3333
|
-
sessionAction.error ? /* @__PURE__ */
|
|
3334
|
-
sessions === null && !listError ? /* @__PURE__ */
|
|
3335
|
-
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */
|
|
3700
|
+
sessionAction.error ? /* @__PURE__ */ jsx43(Alert, { tone: "error", children: sessionAction.error }) : null,
|
|
3701
|
+
sessions === null && !listError ? /* @__PURE__ */ jsx43(Skeleton, { count: 2 }) : null,
|
|
3702
|
+
sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ jsx43(
|
|
3336
3703
|
DataTable,
|
|
3337
3704
|
{
|
|
3338
3705
|
tableKey: "securityPanel.table",
|
|
@@ -3340,12 +3707,12 @@ function SecurityPanel(props) {
|
|
|
3340
3707
|
rowKey: (session) => session.id,
|
|
3341
3708
|
rows: sessions,
|
|
3342
3709
|
columns: [
|
|
3343
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */
|
|
3344
|
-
/* @__PURE__ */
|
|
3345
|
-
session.current ? /* @__PURE__ */
|
|
3710
|
+
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ jsxs34("div", { className: "throttle-row", children: [
|
|
3711
|
+
/* @__PURE__ */ jsx43("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
3712
|
+
session.current ? /* @__PURE__ */ jsx43(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3346
3713
|
] }) },
|
|
3347
3714
|
{ key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
|
|
3348
|
-
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */
|
|
3715
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ jsx43(
|
|
3349
3716
|
Button,
|
|
3350
3717
|
{
|
|
3351
3718
|
variant: "danger",
|
|
@@ -3360,19 +3727,19 @@ function SecurityPanel(props) {
|
|
|
3360
3727
|
) : null }
|
|
3361
3728
|
]
|
|
3362
3729
|
}
|
|
3363
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */
|
|
3364
|
-
/* @__PURE__ */
|
|
3365
|
-
/* @__PURE__ */
|
|
3366
|
-
/* @__PURE__ */
|
|
3367
|
-
session.current ? /* @__PURE__ */
|
|
3730
|
+
) : (sessions ?? []).map((session) => /* @__PURE__ */ jsxs34("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
|
|
3731
|
+
/* @__PURE__ */ jsxs34("div", { children: [
|
|
3732
|
+
/* @__PURE__ */ jsxs34("div", { className: "throttle-row", children: [
|
|
3733
|
+
/* @__PURE__ */ jsx43("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
|
|
3734
|
+
session.current ? /* @__PURE__ */ jsx43(Badge, { tone: "success", children: t.security.thisDevice }) : null
|
|
3368
3735
|
] }),
|
|
3369
|
-
/* @__PURE__ */
|
|
3736
|
+
/* @__PURE__ */ jsxs34("p", { className: "throttle-muted", children: [
|
|
3370
3737
|
t.security.lastActive,
|
|
3371
3738
|
" ",
|
|
3372
3739
|
formatDate(session.lastUsedAt, locale)
|
|
3373
3740
|
] })
|
|
3374
3741
|
] }),
|
|
3375
|
-
!session.current ? /* @__PURE__ */
|
|
3742
|
+
!session.current ? /* @__PURE__ */ jsx43(
|
|
3376
3743
|
Button,
|
|
3377
3744
|
{
|
|
3378
3745
|
variant: revokeVariant,
|
|
@@ -3386,8 +3753,8 @@ function SecurityPanel(props) {
|
|
|
3386
3753
|
}
|
|
3387
3754
|
) : null
|
|
3388
3755
|
] }, session.id)),
|
|
3389
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */
|
|
3390
|
-
others.length > 0 ? /* @__PURE__ */
|
|
3756
|
+
sessions !== null && others.length === 0 ? /* @__PURE__ */ jsx43("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
|
|
3757
|
+
others.length > 0 ? /* @__PURE__ */ jsx43(
|
|
3391
3758
|
Button,
|
|
3392
3759
|
{
|
|
3393
3760
|
variant: "danger",
|
|
@@ -3407,7 +3774,7 @@ function SecurityPanel(props) {
|
|
|
3407
3774
|
}
|
|
3408
3775
|
|
|
3409
3776
|
// src/react/components/account/AccountDashboard.tsx
|
|
3410
|
-
import { Fragment as Fragment10, jsx as
|
|
3777
|
+
import { Fragment as Fragment10, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3411
3778
|
var ACCOUNT_TABS = [
|
|
3412
3779
|
"profile",
|
|
3413
3780
|
"addresses",
|
|
@@ -3436,9 +3803,9 @@ function AccountDashboard(props) {
|
|
|
3436
3803
|
const { status } = useAuth();
|
|
3437
3804
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
3438
3805
|
const controlled = props.tab !== void 0;
|
|
3439
|
-
const [internal, setInternal] =
|
|
3440
|
-
const idBase =
|
|
3441
|
-
|
|
3806
|
+
const [internal, setInternal] = useState21(shown[0] ?? "profile");
|
|
3807
|
+
const idBase = useId6();
|
|
3808
|
+
useEffect9(() => {
|
|
3442
3809
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
3443
3810
|
const apply = () => {
|
|
3444
3811
|
const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
|
|
@@ -3459,7 +3826,7 @@ function AccountDashboard(props) {
|
|
|
3459
3826
|
};
|
|
3460
3827
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
3461
3828
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
3462
|
-
const nav = /* @__PURE__ */
|
|
3829
|
+
const nav = /* @__PURE__ */ jsx44(
|
|
3463
3830
|
Tabs,
|
|
3464
3831
|
{
|
|
3465
3832
|
idBase,
|
|
@@ -3475,7 +3842,7 @@ function AccountDashboard(props) {
|
|
|
3475
3842
|
}))
|
|
3476
3843
|
}
|
|
3477
3844
|
);
|
|
3478
|
-
const panel = /* @__PURE__ */
|
|
3845
|
+
const panel = /* @__PURE__ */ jsxs35(
|
|
3479
3846
|
"div",
|
|
3480
3847
|
{
|
|
3481
3848
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -3484,36 +3851,46 @@ function AccountDashboard(props) {
|
|
|
3484
3851
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
3485
3852
|
tabIndex: 0,
|
|
3486
3853
|
children: [
|
|
3487
|
-
active === "profile" ? /* @__PURE__ */
|
|
3488
|
-
active === "addresses" ? /* @__PURE__ */
|
|
3489
|
-
active === "paymentMethods" ? /* @__PURE__ */
|
|
3490
|
-
active === "orders" ? /* @__PURE__ */
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3854
|
+
active === "profile" ? /* @__PURE__ */ jsx44(ProfilePanel, { ...shared }) : null,
|
|
3855
|
+
active === "addresses" ? /* @__PURE__ */ jsx44(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3856
|
+
active === "paymentMethods" ? /* @__PURE__ */ jsx44(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3857
|
+
active === "orders" ? /* @__PURE__ */ jsx44(
|
|
3858
|
+
OrdersPanel,
|
|
3859
|
+
{
|
|
3860
|
+
...shared,
|
|
3861
|
+
variant: props.panelVariant,
|
|
3862
|
+
onViewSubscription: () => go("subscriptions"),
|
|
3863
|
+
onPayNow: props.onPayNow,
|
|
3864
|
+
onReorder: props.onReorder,
|
|
3865
|
+
onTrackShipment: props.onTrackShipment
|
|
3866
|
+
}
|
|
3867
|
+
) : null,
|
|
3868
|
+
active === "invoices" ? /* @__PURE__ */ jsx44(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3869
|
+
active === "subscriptions" ? /* @__PURE__ */ jsx44(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
|
|
3870
|
+
active === "security" ? /* @__PURE__ */ jsx44(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
|
|
3494
3871
|
]
|
|
3495
3872
|
}
|
|
3496
3873
|
);
|
|
3497
|
-
return /* @__PURE__ */
|
|
3498
|
-
/* @__PURE__ */
|
|
3499
|
-
sidebar ? /* @__PURE__ */
|
|
3500
|
-
/* @__PURE__ */
|
|
3874
|
+
return /* @__PURE__ */ jsx44(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx44("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs35("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
|
|
3875
|
+
/* @__PURE__ */ jsx44(VerifyEmailBanner, { ...shared }),
|
|
3876
|
+
sidebar ? /* @__PURE__ */ jsxs35("div", { className: "throttle-account", children: [
|
|
3877
|
+
/* @__PURE__ */ jsx44("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
|
|
3501
3878
|
panel
|
|
3502
|
-
] }) : /* @__PURE__ */
|
|
3503
|
-
/* @__PURE__ */
|
|
3879
|
+
] }) : /* @__PURE__ */ jsxs35(Fragment10, { children: [
|
|
3880
|
+
/* @__PURE__ */ jsx44("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
3504
3881
|
panel
|
|
3505
3882
|
] })
|
|
3506
3883
|
] }) }) });
|
|
3507
3884
|
}
|
|
3508
3885
|
|
|
3509
3886
|
// src/react/components/account/AccountModal.tsx
|
|
3510
|
-
import { jsx as
|
|
3887
|
+
import { jsx as jsx45, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
3511
3888
|
function AccountModal(props) {
|
|
3512
3889
|
const a = useAppearance(props.appearance);
|
|
3513
3890
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3514
3891
|
const { t } = useCopy(props.localization);
|
|
3515
|
-
const titleId =
|
|
3516
|
-
return /* @__PURE__ */
|
|
3892
|
+
const titleId = useId7();
|
|
3893
|
+
return /* @__PURE__ */ jsx45(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsxs36(
|
|
3517
3894
|
Modal,
|
|
3518
3895
|
{
|
|
3519
3896
|
open: props.open,
|
|
@@ -3523,15 +3900,15 @@ function AccountModal(props) {
|
|
|
3523
3900
|
overlayKey: "accountModal.overlay",
|
|
3524
3901
|
containerKey: "accountModal.container",
|
|
3525
3902
|
children: [
|
|
3526
|
-
/* @__PURE__ */
|
|
3527
|
-
/* @__PURE__ */
|
|
3903
|
+
/* @__PURE__ */ jsx45("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ jsx45("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
|
|
3904
|
+
/* @__PURE__ */ jsx45("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ jsx45(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
|
|
3528
3905
|
]
|
|
3529
3906
|
}
|
|
3530
3907
|
) });
|
|
3531
3908
|
}
|
|
3532
3909
|
|
|
3533
3910
|
// src/react/components/provider.tsx
|
|
3534
|
-
import { jsx as
|
|
3911
|
+
import { jsx as jsx46, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
3535
3912
|
var warned = /* @__PURE__ */ new Set();
|
|
3536
3913
|
function warnOnce(key, message) {
|
|
3537
3914
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -3539,9 +3916,9 @@ function warnOnce(key, message) {
|
|
|
3539
3916
|
warned.add(key);
|
|
3540
3917
|
console.warn(`[@usethrottle/auth] ${message}`);
|
|
3541
3918
|
}
|
|
3542
|
-
var ThrottleUIContext =
|
|
3919
|
+
var ThrottleUIContext = createContext6(null);
|
|
3543
3920
|
function useThrottle() {
|
|
3544
|
-
const ctx =
|
|
3921
|
+
const ctx = useContext6(ThrottleUIContext);
|
|
3545
3922
|
if (!ctx) {
|
|
3546
3923
|
warnOnce(
|
|
3547
3924
|
"use-throttle-no-provider",
|
|
@@ -3576,51 +3953,51 @@ function ThrottleProvider(props) {
|
|
|
3576
3953
|
__captureStepUp
|
|
3577
3954
|
} = props;
|
|
3578
3955
|
useInjectStyles(injectStyles);
|
|
3579
|
-
const [stepUpOpen, setStepUpOpen] =
|
|
3580
|
-
const resolveStepUp =
|
|
3581
|
-
const claimRef =
|
|
3956
|
+
const [stepUpOpen, setStepUpOpen] = useState22(false);
|
|
3957
|
+
const resolveStepUp = useRef9(null);
|
|
3958
|
+
const claimRef = useRef9(claimCartOnSignIn);
|
|
3582
3959
|
claimRef.current = claimCartOnSignIn;
|
|
3583
|
-
const [overlay, setOverlay] =
|
|
3584
|
-
const overlayRestoreFocus =
|
|
3585
|
-
const [accountTabs, setAccountTabs] =
|
|
3586
|
-
const onOverlaySuccess =
|
|
3587
|
-
const openSignIn =
|
|
3960
|
+
const [overlay, setOverlay] = useState22(null);
|
|
3961
|
+
const overlayRestoreFocus = useRef9(null);
|
|
3962
|
+
const [accountTabs, setAccountTabs] = useState22(void 0);
|
|
3963
|
+
const onOverlaySuccess = useRef9(null);
|
|
3964
|
+
const openSignIn = useCallback4((onSuccess) => {
|
|
3588
3965
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
3589
3966
|
setOverlay("signIn");
|
|
3590
3967
|
}, []);
|
|
3591
|
-
const openSignUp =
|
|
3968
|
+
const openSignUp = useCallback4((onSuccess) => {
|
|
3592
3969
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
3593
3970
|
setOverlay("signUp");
|
|
3594
3971
|
}, []);
|
|
3595
|
-
const openAccount =
|
|
3972
|
+
const openAccount = useCallback4((opts) => {
|
|
3596
3973
|
onOverlaySuccess.current = null;
|
|
3597
3974
|
overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
|
|
3598
3975
|
setAccountTabs(opts?.tabs);
|
|
3599
3976
|
setOverlay("account");
|
|
3600
3977
|
}, []);
|
|
3601
|
-
const closeOverlay =
|
|
3978
|
+
const closeOverlay = useCallback4(() => {
|
|
3602
3979
|
onOverlaySuccess.current = null;
|
|
3603
3980
|
overlayRestoreFocus.current = null;
|
|
3604
3981
|
setOverlay(null);
|
|
3605
3982
|
}, []);
|
|
3606
|
-
const handleOverlaySuccess =
|
|
3983
|
+
const handleOverlaySuccess = useCallback4(() => {
|
|
3607
3984
|
const fn = onOverlaySuccess.current;
|
|
3608
3985
|
onOverlaySuccess.current = null;
|
|
3609
3986
|
setOverlay(null);
|
|
3610
3987
|
fn?.();
|
|
3611
3988
|
}, []);
|
|
3612
|
-
const ui =
|
|
3989
|
+
const ui = useMemo4(
|
|
3613
3990
|
() => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
|
|
3614
3991
|
[overlay, openSignIn, openSignUp, openAccount, closeOverlay]
|
|
3615
3992
|
);
|
|
3616
|
-
const askForStepUp =
|
|
3993
|
+
const askForStepUp = useCallback4(
|
|
3617
3994
|
() => new Promise((resolve) => {
|
|
3618
3995
|
resolveStepUp.current = resolve;
|
|
3619
3996
|
setStepUpOpen(true);
|
|
3620
3997
|
}),
|
|
3621
3998
|
[]
|
|
3622
3999
|
);
|
|
3623
|
-
const auth =
|
|
4000
|
+
const auth = useMemo4(() => {
|
|
3624
4001
|
__captureStepUp?.(askForStepUp);
|
|
3625
4002
|
const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
|
|
3626
4003
|
const account = createAccount(client);
|
|
@@ -3653,10 +4030,10 @@ function ThrottleProvider(props) {
|
|
|
3653
4030
|
resolve?.(password);
|
|
3654
4031
|
};
|
|
3655
4032
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
3656
|
-
return /* @__PURE__ */
|
|
4033
|
+
return /* @__PURE__ */ jsx46(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ jsx46(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ jsx46(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ jsx46(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ jsx46(ConfirmProvider, { children: /* @__PURE__ */ jsxs37(ThrottleUIContext.Provider, { value: ui, children: [
|
|
3657
4034
|
children,
|
|
3658
|
-
/* @__PURE__ */
|
|
3659
|
-
/* @__PURE__ */
|
|
4035
|
+
/* @__PURE__ */ jsx46(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
|
|
4036
|
+
/* @__PURE__ */ jsx46(
|
|
3660
4037
|
AuthModal,
|
|
3661
4038
|
{
|
|
3662
4039
|
open: authOverlayOpen,
|
|
@@ -3667,23 +4044,23 @@ function ThrottleProvider(props) {
|
|
|
3667
4044
|
},
|
|
3668
4045
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
3669
4046
|
),
|
|
3670
|
-
/* @__PURE__ */
|
|
3671
|
-
] }) }) }) }) });
|
|
4047
|
+
/* @__PURE__ */ jsx46(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
4048
|
+
] }) }) }) }) }) });
|
|
3672
4049
|
}
|
|
3673
4050
|
|
|
3674
4051
|
// src/react/components/auth/SignInButton.tsx
|
|
3675
|
-
import { cloneElement, isValidElement, useContext as
|
|
3676
|
-
import { jsx as
|
|
4052
|
+
import { cloneElement, isValidElement, useContext as useContext7, useState as useState23 } from "react";
|
|
4053
|
+
import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
3677
4054
|
function SignInButton(props) {
|
|
3678
4055
|
const a = useAppearance(props.appearance);
|
|
3679
4056
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3680
4057
|
const { t } = useCopy(props.localization);
|
|
3681
|
-
const ui =
|
|
3682
|
-
const [localOpen, setLocalOpen] =
|
|
4058
|
+
const ui = useContext7(ThrottleUIContext);
|
|
4059
|
+
const [localOpen, setLocalOpen] = useState23(false);
|
|
3683
4060
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3684
4061
|
const label = props.children ?? t.signIn.submitButton;
|
|
3685
4062
|
if (props.mode === "redirect") {
|
|
3686
|
-
return /* @__PURE__ */
|
|
4063
|
+
return /* @__PURE__ */ jsx47(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx47("span", { ...a.rootProps, children: /* @__PURE__ */ jsx47("a", { ...a.el("signInButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
3687
4064
|
}
|
|
3688
4065
|
const openModal = () => {
|
|
3689
4066
|
if (useShared) ui.openSignIn(props.afterSignIn);
|
|
@@ -3693,10 +4070,10 @@ function SignInButton(props) {
|
|
|
3693
4070
|
if (useShared) ui.close();
|
|
3694
4071
|
else setLocalOpen(false);
|
|
3695
4072
|
};
|
|
3696
|
-
const trigger = props.asChild && isValidElement(props.children) ? cloneElement(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3697
|
-
return /* @__PURE__ */
|
|
3698
|
-
/* @__PURE__ */
|
|
3699
|
-
!useShared ? /* @__PURE__ */
|
|
4073
|
+
const trigger = props.asChild && isValidElement(props.children) ? cloneElement(props.children, { onClick: openModal }) : /* @__PURE__ */ jsx47(Button, { elementKey: "signInButton.root", onClick: openModal, children: label });
|
|
4074
|
+
return /* @__PURE__ */ jsxs38(AppearanceProvider, { value: scoped, children: [
|
|
4075
|
+
/* @__PURE__ */ jsx47("span", { ...a.rootProps, children: trigger }),
|
|
4076
|
+
!useShared ? /* @__PURE__ */ jsx47(
|
|
3700
4077
|
AuthModal,
|
|
3701
4078
|
{
|
|
3702
4079
|
open: localOpen,
|
|
@@ -3714,18 +4091,18 @@ function SignInButton(props) {
|
|
|
3714
4091
|
}
|
|
3715
4092
|
|
|
3716
4093
|
// src/react/components/auth/SignUpButton.tsx
|
|
3717
|
-
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useContext as
|
|
3718
|
-
import { jsx as
|
|
4094
|
+
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useContext as useContext8, useState as useState24 } from "react";
|
|
4095
|
+
import { jsx as jsx48, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
3719
4096
|
function SignUpButton(props) {
|
|
3720
4097
|
const a = useAppearance(props.appearance);
|
|
3721
4098
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3722
4099
|
const { t } = useCopy(props.localization);
|
|
3723
|
-
const ui =
|
|
3724
|
-
const [localOpen, setLocalOpen] =
|
|
4100
|
+
const ui = useContext8(ThrottleUIContext);
|
|
4101
|
+
const [localOpen, setLocalOpen] = useState24(false);
|
|
3725
4102
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3726
4103
|
const label = props.children ?? t.signUp.submitButton;
|
|
3727
4104
|
if (props.mode === "redirect") {
|
|
3728
|
-
return /* @__PURE__ */
|
|
4105
|
+
return /* @__PURE__ */ jsx48(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx48("span", { ...a.rootProps, children: /* @__PURE__ */ jsx48("a", { ...a.el("signUpButton.root", "throttle-button throttle-button--primary"), href: props.url ?? "#", children: label }) }) });
|
|
3729
4106
|
}
|
|
3730
4107
|
const openModal = () => {
|
|
3731
4108
|
if (useShared) ui.openSignUp(props.afterSignUp);
|
|
@@ -3735,10 +4112,10 @@ function SignUpButton(props) {
|
|
|
3735
4112
|
if (useShared) ui.close();
|
|
3736
4113
|
else setLocalOpen(false);
|
|
3737
4114
|
};
|
|
3738
|
-
const trigger = props.asChild && isValidElement2(props.children) ? cloneElement2(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3739
|
-
return /* @__PURE__ */
|
|
3740
|
-
/* @__PURE__ */
|
|
3741
|
-
!useShared ? /* @__PURE__ */
|
|
4115
|
+
const trigger = props.asChild && isValidElement2(props.children) ? cloneElement2(props.children, { onClick: openModal }) : /* @__PURE__ */ jsx48(Button, { elementKey: "signUpButton.root", onClick: openModal, children: label });
|
|
4116
|
+
return /* @__PURE__ */ jsxs39(AppearanceProvider, { value: scoped, children: [
|
|
4117
|
+
/* @__PURE__ */ jsx48("span", { ...a.rootProps, children: trigger }),
|
|
4118
|
+
!useShared ? /* @__PURE__ */ jsx48(
|
|
3742
4119
|
AuthModal,
|
|
3743
4120
|
{
|
|
3744
4121
|
open: localOpen,
|
|
@@ -3756,14 +4133,14 @@ function SignUpButton(props) {
|
|
|
3756
4133
|
}
|
|
3757
4134
|
|
|
3758
4135
|
// src/react/components/auth/SignOutButton.tsx
|
|
3759
|
-
import { jsx as
|
|
4136
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
3760
4137
|
function SignOutButton(props) {
|
|
3761
4138
|
const a = useAppearance();
|
|
3762
4139
|
const { auth } = useAuth();
|
|
3763
4140
|
const { t } = useCopy(props.localization);
|
|
3764
4141
|
const { submitting, run } = useAction();
|
|
3765
4142
|
const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
|
|
3766
|
-
return /* @__PURE__ */
|
|
4143
|
+
return /* @__PURE__ */ jsx49("span", { ...a.rootProps, children: /* @__PURE__ */ jsx49(
|
|
3767
4144
|
Button,
|
|
3768
4145
|
{
|
|
3769
4146
|
variant: "secondary",
|
|
@@ -3780,13 +4157,13 @@ function SignOutButton(props) {
|
|
|
3780
4157
|
}
|
|
3781
4158
|
|
|
3782
4159
|
// src/react/components/auth/SignInPage.tsx
|
|
3783
|
-
import { jsx as
|
|
4160
|
+
import { jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
3784
4161
|
function SignInPage(props) {
|
|
3785
4162
|
const a = useAppearance(props.appearance);
|
|
3786
4163
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3787
|
-
return /* @__PURE__ */
|
|
3788
|
-
props.logo ? /* @__PURE__ */
|
|
3789
|
-
/* @__PURE__ */
|
|
4164
|
+
return /* @__PURE__ */ jsx50(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx50("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs40("div", { ...a.el("signInPage.root", "throttle-page"), children: [
|
|
4165
|
+
props.logo ? /* @__PURE__ */ jsx50("div", { ...a.el("signInPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4166
|
+
/* @__PURE__ */ jsx50(
|
|
3790
4167
|
SignIn,
|
|
3791
4168
|
{
|
|
3792
4169
|
onSuccess: props.onSuccess,
|
|
@@ -3796,18 +4173,18 @@ function SignInPage(props) {
|
|
|
3796
4173
|
localization: props.localization
|
|
3797
4174
|
}
|
|
3798
4175
|
),
|
|
3799
|
-
props.footer ? /* @__PURE__ */
|
|
4176
|
+
props.footer ? /* @__PURE__ */ jsx50("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3800
4177
|
] }) }) });
|
|
3801
4178
|
}
|
|
3802
4179
|
|
|
3803
4180
|
// src/react/components/auth/SignUpPage.tsx
|
|
3804
|
-
import { jsx as
|
|
4181
|
+
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
3805
4182
|
function SignUpPage(props) {
|
|
3806
4183
|
const a = useAppearance(props.appearance);
|
|
3807
4184
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3808
|
-
return /* @__PURE__ */
|
|
3809
|
-
props.logo ? /* @__PURE__ */
|
|
3810
|
-
/* @__PURE__ */
|
|
4185
|
+
return /* @__PURE__ */ jsx51(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx51("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs41("div", { ...a.el("signUpPage.root", "throttle-page"), children: [
|
|
4186
|
+
props.logo ? /* @__PURE__ */ jsx51("div", { ...a.el("signUpPage.logo", "throttle-page__logo"), children: props.logo }) : null,
|
|
4187
|
+
/* @__PURE__ */ jsx51(
|
|
3811
4188
|
SignUp,
|
|
3812
4189
|
{
|
|
3813
4190
|
onSuccess: props.onSuccess,
|
|
@@ -3816,42 +4193,42 @@ function SignUpPage(props) {
|
|
|
3816
4193
|
localization: props.localization
|
|
3817
4194
|
}
|
|
3818
4195
|
),
|
|
3819
|
-
props.footer ? /* @__PURE__ */
|
|
4196
|
+
props.footer ? /* @__PURE__ */ jsx51("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3820
4197
|
] }) }) });
|
|
3821
4198
|
}
|
|
3822
4199
|
|
|
3823
4200
|
// src/react/components/guards.tsx
|
|
3824
|
-
import { Fragment as Fragment11, jsx as
|
|
4201
|
+
import { Fragment as Fragment11, jsx as jsx52 } from "react/jsx-runtime";
|
|
3825
4202
|
function SignedIn(props) {
|
|
3826
4203
|
const { status } = useAuth();
|
|
3827
|
-
return status === "authenticated" ? /* @__PURE__ */
|
|
4204
|
+
return status === "authenticated" ? /* @__PURE__ */ jsx52(Fragment11, { children: props.children }) : null;
|
|
3828
4205
|
}
|
|
3829
4206
|
function SignedOut(props) {
|
|
3830
4207
|
const { status } = useAuth();
|
|
3831
|
-
return status === "unauthenticated" ? /* @__PURE__ */
|
|
4208
|
+
return status === "unauthenticated" ? /* @__PURE__ */ jsx52(Fragment11, { children: props.children }) : null;
|
|
3832
4209
|
}
|
|
3833
4210
|
function Protect(props) {
|
|
3834
4211
|
const { status, emailVerified } = useAuth();
|
|
3835
4212
|
if (status === "loading") return null;
|
|
3836
|
-
if (status !== "authenticated") return /* @__PURE__ */
|
|
3837
|
-
if (props.requireVerified && !emailVerified) return /* @__PURE__ */
|
|
3838
|
-
return /* @__PURE__ */
|
|
4213
|
+
if (status !== "authenticated") return /* @__PURE__ */ jsx52(Fragment11, { children: props.fallback ?? null });
|
|
4214
|
+
if (props.requireVerified && !emailVerified) return /* @__PURE__ */ jsx52(Fragment11, { children: props.fallback ?? null });
|
|
4215
|
+
return /* @__PURE__ */ jsx52(Fragment11, { children: props.children });
|
|
3839
4216
|
}
|
|
3840
4217
|
|
|
3841
4218
|
// src/react/components/UserButton.tsx
|
|
3842
|
-
import { useContext as
|
|
3843
|
-
import { jsx as
|
|
4219
|
+
import { useContext as useContext9, useId as useId8, useRef as useRef10, useState as useState25 } from "react";
|
|
4220
|
+
import { jsx as jsx53, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
3844
4221
|
function UserButtonRoot(props) {
|
|
3845
4222
|
const a = useAppearance(props.appearance);
|
|
3846
4223
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3847
4224
|
const { t } = useCopy(props.localization);
|
|
3848
4225
|
const { auth, status, customer, emailVerified } = useAuth();
|
|
3849
|
-
const ui =
|
|
3850
|
-
const [localOpen, setLocalOpen] =
|
|
4226
|
+
const ui = useContext9(ThrottleUIContext);
|
|
4227
|
+
const [localOpen, setLocalOpen] = useState25(false);
|
|
3851
4228
|
const accountOpen = ui ? false : localOpen;
|
|
3852
|
-
const titleId =
|
|
3853
|
-
const rootRef =
|
|
3854
|
-
const openerRef =
|
|
4229
|
+
const titleId = useId8();
|
|
4230
|
+
const rootRef = useRef10(null);
|
|
4231
|
+
const openerRef = useRef10(null);
|
|
3855
4232
|
const openAccount = () => {
|
|
3856
4233
|
const opener = rootRef.current?.querySelector('button[aria-haspopup="menu"]') ?? null;
|
|
3857
4234
|
openerRef.current = opener;
|
|
@@ -3860,25 +4237,25 @@ function UserButtonRoot(props) {
|
|
|
3860
4237
|
};
|
|
3861
4238
|
if (status !== "authenticated" || !customer) return null;
|
|
3862
4239
|
const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
|
|
3863
|
-
return /* @__PURE__ */
|
|
3864
|
-
/* @__PURE__ */
|
|
4240
|
+
return /* @__PURE__ */ jsx53(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx53("span", { ...a.rootProps, children: /* @__PURE__ */ jsxs42("span", { ref: rootRef, ...a.el("userButton.root"), children: [
|
|
4241
|
+
/* @__PURE__ */ jsxs42(
|
|
3865
4242
|
Dropdown,
|
|
3866
4243
|
{
|
|
3867
4244
|
label: t.userButton.openMenu,
|
|
3868
4245
|
triggerKey: "userButton.trigger",
|
|
3869
4246
|
menuKey: "userButton.menu",
|
|
3870
|
-
trigger: /* @__PURE__ */
|
|
4247
|
+
trigger: /* @__PURE__ */ jsx53(Avatar, { name, email: customer.email }),
|
|
3871
4248
|
children: [
|
|
3872
|
-
/* @__PURE__ */
|
|
3873
|
-
/* @__PURE__ */
|
|
3874
|
-
/* @__PURE__ */
|
|
3875
|
-
/* @__PURE__ */
|
|
4249
|
+
/* @__PURE__ */ jsx53("div", { ...a.el("userButton.identity", "throttle-dropdown__item"), children: /* @__PURE__ */ jsxs42("span", { children: [
|
|
4250
|
+
/* @__PURE__ */ jsx53("span", { ...a.el("userButton.email"), children: customer.email }),
|
|
4251
|
+
/* @__PURE__ */ jsx53("br", {}),
|
|
4252
|
+
/* @__PURE__ */ jsx53(Badge, { tone: emailVerified ? "success" : "warning", elementKey: "userButton.badge", children: emailVerified ? t.userButton.verified : t.userButton.unverified })
|
|
3876
4253
|
] }) }),
|
|
3877
|
-
/* @__PURE__ */
|
|
3878
|
-
props.mode === "navigate" ? /* @__PURE__ */
|
|
4254
|
+
/* @__PURE__ */ jsx53(DropdownSeparator, {}),
|
|
4255
|
+
props.mode === "navigate" ? /* @__PURE__ */ jsx53(DropdownItem, { itemKey: "userButton.manageButton", href: props.accountUrl ?? "#", children: t.userButton.manage }) : /* @__PURE__ */ jsx53(DropdownItem, { itemKey: "userButton.manageButton", onClick: openAccount, children: t.userButton.manage }),
|
|
3879
4256
|
props.children,
|
|
3880
|
-
/* @__PURE__ */
|
|
3881
|
-
/* @__PURE__ */
|
|
4257
|
+
/* @__PURE__ */ jsx53(DropdownSeparator, {}),
|
|
4258
|
+
/* @__PURE__ */ jsx53(
|
|
3882
4259
|
DropdownItem,
|
|
3883
4260
|
{
|
|
3884
4261
|
itemKey: "userButton.signOutButton",
|
|
@@ -3886,7 +4263,7 @@ function UserButtonRoot(props) {
|
|
|
3886
4263
|
children: t.userButton.signOut
|
|
3887
4264
|
}
|
|
3888
4265
|
),
|
|
3889
|
-
/* @__PURE__ */
|
|
4266
|
+
/* @__PURE__ */ jsx53(
|
|
3890
4267
|
DropdownItem,
|
|
3891
4268
|
{
|
|
3892
4269
|
itemKey: "userButton.signOutAllButton",
|
|
@@ -3897,7 +4274,7 @@ function UserButtonRoot(props) {
|
|
|
3897
4274
|
]
|
|
3898
4275
|
}
|
|
3899
4276
|
),
|
|
3900
|
-
props.mode !== "navigate" && !ui ? /* @__PURE__ */
|
|
4277
|
+
props.mode !== "navigate" && !ui ? /* @__PURE__ */ jsxs42(
|
|
3901
4278
|
Modal,
|
|
3902
4279
|
{
|
|
3903
4280
|
open: accountOpen,
|
|
@@ -3905,8 +4282,8 @@ function UserButtonRoot(props) {
|
|
|
3905
4282
|
labelledBy: titleId,
|
|
3906
4283
|
restoreFocusTo: openerRef.current,
|
|
3907
4284
|
children: [
|
|
3908
|
-
/* @__PURE__ */
|
|
3909
|
-
/* @__PURE__ */
|
|
4285
|
+
/* @__PURE__ */ jsx53("h2", { id: titleId, style: { padding: "16px 16px 0", margin: 0 }, children: t.account.title }),
|
|
4286
|
+
/* @__PURE__ */ jsx53("div", { style: { padding: 16 }, children: /* @__PURE__ */ jsx53(
|
|
3910
4287
|
AccountDashboard,
|
|
3911
4288
|
{
|
|
3912
4289
|
tabs: props.tabs,
|
|
@@ -3920,13 +4297,13 @@ function UserButtonRoot(props) {
|
|
|
3920
4297
|
] }) }) });
|
|
3921
4298
|
}
|
|
3922
4299
|
function UserButtonLink(props) {
|
|
3923
|
-
return /* @__PURE__ */
|
|
4300
|
+
return /* @__PURE__ */ jsxs42(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
|
|
3924
4301
|
props.icon,
|
|
3925
4302
|
props.label
|
|
3926
4303
|
] });
|
|
3927
4304
|
}
|
|
3928
4305
|
function UserButtonAction(props) {
|
|
3929
|
-
return /* @__PURE__ */
|
|
4306
|
+
return /* @__PURE__ */ jsxs42(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
|
|
3930
4307
|
props.icon,
|
|
3931
4308
|
props.label
|
|
3932
4309
|
] });
|
|
@@ -3939,6 +4316,7 @@ export {
|
|
|
3939
4316
|
ACCOUNT_TABS,
|
|
3940
4317
|
AccountDashboard,
|
|
3941
4318
|
AccountModal,
|
|
4319
|
+
AddCardDialog,
|
|
3942
4320
|
AddressesPanel,
|
|
3943
4321
|
AuthFlow,
|
|
3944
4322
|
AuthModal,
|