@usethrottle/auth 0.2.3 → 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/react/components/index.cjs +872 -617
- package/dist/react/components/index.cjs.map +1 -1
- package/dist/react/components/index.d.cts +56 -10
- package/dist/react/components/index.d.ts +56 -10
- package/dist/react/components/index.js +845 -590
- package/dist/react/components/index.js.map +1 -1
- package/dist/styles.css +10 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
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";
|
|
@@ -144,6 +144,10 @@ var VARIABLE_PROPERTY = {
|
|
|
144
144
|
// colorBackground/colorSurface because a merchant embedding the dashboard
|
|
145
145
|
// in their page usually wants it to paint nothing at all, while still
|
|
146
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",
|
|
147
151
|
accountSurface: "--throttle-color-account-surface",
|
|
148
152
|
accountPadding: "--throttle-account-padding",
|
|
149
153
|
shadowCard: "--throttle-shadow-card",
|
|
@@ -282,6 +286,18 @@ var THROTTLE_ELEMENT_KEYS = [
|
|
|
282
286
|
"paymentMethodsPanel.deleteButton",
|
|
283
287
|
"paymentMethodsPanel.addButton",
|
|
284
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",
|
|
285
301
|
"paymentMethodsPanel.table",
|
|
286
302
|
"paymentMethodsPanel.row",
|
|
287
303
|
"ordersPanel.root",
|
|
@@ -395,6 +411,9 @@ var enUS = {
|
|
|
395
411
|
loading: "Loading\u2026",
|
|
396
412
|
close: "Close",
|
|
397
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",
|
|
398
417
|
somethingWentWrong: "Something went wrong.",
|
|
399
418
|
actions: "Actions",
|
|
400
419
|
view: "View"
|
|
@@ -492,6 +511,7 @@ var enUS = {
|
|
|
492
511
|
addButton: "Add address",
|
|
493
512
|
defaultBadge: "Default",
|
|
494
513
|
makeDefault: "Make default",
|
|
514
|
+
deleteConfirmAction: "Delete address",
|
|
495
515
|
empty: "No saved addresses",
|
|
496
516
|
emptyDescription: "Addresses you use at checkout can be saved here.",
|
|
497
517
|
label: "Label",
|
|
@@ -521,9 +541,20 @@ var enUS = {
|
|
|
521
541
|
makeDefault: "Make default",
|
|
522
542
|
expires: "Expires",
|
|
523
543
|
deleteConfirm: "Remove this card?",
|
|
544
|
+
deleteConfirmAction: "Remove card",
|
|
524
545
|
columnCard: "Card"
|
|
525
546
|
},
|
|
526
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",
|
|
527
558
|
empty: "No orders yet",
|
|
528
559
|
emptyDescription: "Orders you place will appear here.",
|
|
529
560
|
gatedDescription: "Verify your email to see your order history.",
|
|
@@ -592,6 +623,12 @@ var enUS = {
|
|
|
592
623
|
downloadUnavailable: "This invoice is not available to download right now."
|
|
593
624
|
},
|
|
594
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?",
|
|
595
632
|
empty: "No subscriptions",
|
|
596
633
|
emptyDescription: "Subscriptions will appear here.",
|
|
597
634
|
gatedDescription: "Verify your email to see your subscriptions.",
|
|
@@ -713,6 +750,7 @@ var THROTTLE_STYLES = `
|
|
|
713
750
|
merchant's page without fighting their background. The accountSurface and
|
|
714
751
|
accountPadding appearance variables opt back into a card.
|
|
715
752
|
No backticks in this comment: the sheet is a TS template literal. */
|
|
753
|
+
--throttle-card-width: 400px;
|
|
716
754
|
--throttle-color-account-surface: transparent;
|
|
717
755
|
--throttle-account-padding: 0;
|
|
718
756
|
--throttle-color-border-control: #8b93a1;
|
|
@@ -813,7 +851,7 @@ var THROTTLE_STYLES = `
|
|
|
813
851
|
box-shadow: var(--throttle-shadow-card);
|
|
814
852
|
padding: var(--throttle-space-5);
|
|
815
853
|
width: 100%;
|
|
816
|
-
max-width:
|
|
854
|
+
max-width: var(--throttle-card-width);
|
|
817
855
|
margin-inline: auto;
|
|
818
856
|
}
|
|
819
857
|
/* Inside a Modal the dialog already provides the surface \u2014 background, radius
|
|
@@ -1017,6 +1055,13 @@ var THROTTLE_STYLES = `
|
|
|
1017
1055
|
is near-white, so on a light host page it was rendering white-on-white. */
|
|
1018
1056
|
.throttle-cardframe { width: 100%; min-height: 420px; border: 0; display: block; }
|
|
1019
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; }
|
|
1020
1065
|
.throttle-account-root { container-type: inline-size; background: var(--throttle-color-account-surface); color: var(--throttle-color-foreground); padding: var(--throttle-account-padding); }
|
|
1021
1066
|
.throttle-account { display: flex; gap: var(--throttle-space-5); align-items: flex-start; }
|
|
1022
1067
|
.throttle-account__content { flex: 1; min-width: 0; }
|
|
@@ -1054,6 +1099,7 @@ var THROTTLE_STYLES = `
|
|
|
1054
1099
|
it shrinks the rail to its content width, so width:100% alone cannot make
|
|
1055
1100
|
it span. Stretch it explicitly when stacked. */
|
|
1056
1101
|
.throttle-account { flex-direction: column; align-items: stretch; gap: var(--throttle-space-4); }
|
|
1102
|
+
.throttle-addresses { grid-template-columns: 1fr; }
|
|
1057
1103
|
.throttle-tabs__rail { width: 100%; }
|
|
1058
1104
|
}
|
|
1059
1105
|
|
|
@@ -1156,61 +1202,44 @@ function useInjectStyles(enabled) {
|
|
|
1156
1202
|
}, [enabled]);
|
|
1157
1203
|
}
|
|
1158
1204
|
|
|
1159
|
-
// src/react/components/auth/StepUpDialog.tsx
|
|
1160
|
-
import { useEffect as useEffect3, useId as useId2, useState as useState3 } from "react";
|
|
1161
|
-
|
|
1162
|
-
// src/react/components/surface.tsx
|
|
1163
|
-
import { createContext as createContext4, useContext as useContext4 } from "react";
|
|
1164
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1165
|
-
var Ctx4 = createContext4("standalone");
|
|
1166
|
-
function SurfaceProvider(props) {
|
|
1167
|
-
return /* @__PURE__ */ jsx4(Ctx4.Provider, { value: props.value, children: props.children });
|
|
1168
|
-
}
|
|
1169
|
-
function useSurface() {
|
|
1170
|
-
return useContext4(Ctx4);
|
|
1171
|
-
}
|
|
1172
|
-
function useCardClass() {
|
|
1173
|
-
return useSurface() === "modal" ? "throttle-card throttle-card--bare" : "throttle-card";
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
1205
|
// src/react/components/primitives/Card.tsx
|
|
1177
|
-
import { jsx as
|
|
1206
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1178
1207
|
function CardHeader(props) {
|
|
1179
1208
|
const a = useAppearance();
|
|
1180
1209
|
const headerClass = `throttle-card__header${props.branded ? " throttle-card__header--branded" : ""}`;
|
|
1181
1210
|
const titleClass = `throttle-card__title${props.branded ? " throttle-card__title--branded" : ""}`;
|
|
1182
1211
|
return /* @__PURE__ */ jsxs("div", { ...a.el("card.header", headerClass), children: [
|
|
1183
|
-
props.logo ? /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
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
|
|
1186
1215
|
] });
|
|
1187
1216
|
}
|
|
1188
1217
|
function CardBody(props) {
|
|
1189
1218
|
const a = useAppearance();
|
|
1190
|
-
return /* @__PURE__ */
|
|
1219
|
+
return /* @__PURE__ */ jsx4("div", { ...a.el("card.body", "throttle-card__body"), children: props.children });
|
|
1191
1220
|
}
|
|
1192
1221
|
function CardFooter(props) {
|
|
1193
1222
|
const a = useAppearance();
|
|
1194
1223
|
const className = `throttle-card__footer${props.ruled ? " throttle-card__footer--ruled" : ""}`;
|
|
1195
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx4("div", { ...a.el("card.footer", className), children: props.children });
|
|
1196
1225
|
}
|
|
1197
1226
|
|
|
1198
1227
|
// src/react/components/primitives/Spinner.tsx
|
|
1199
|
-
import { jsx as
|
|
1228
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1200
1229
|
function Spinner({ centred } = {}) {
|
|
1201
1230
|
const a = useAppearance();
|
|
1202
1231
|
const Slot = a.slots.Spinner;
|
|
1203
|
-
if (Slot) return /* @__PURE__ */
|
|
1232
|
+
if (Slot) return /* @__PURE__ */ jsx5(Slot, {});
|
|
1204
1233
|
const cls = `throttle-spinner${centred ? " throttle-spinner--centred" : ""}`;
|
|
1205
|
-
return /* @__PURE__ */
|
|
1234
|
+
return /* @__PURE__ */ jsx5("span", { ...a.el("spinner", cls), "aria-hidden": "true" });
|
|
1206
1235
|
}
|
|
1207
1236
|
|
|
1208
1237
|
// src/react/components/primitives/Button.tsx
|
|
1209
|
-
import { jsx as
|
|
1238
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1210
1239
|
function Button({ variant = "primary", size = "default", elementKey, loading, children, ...rest }) {
|
|
1211
1240
|
const a = useAppearance();
|
|
1212
1241
|
const Slot = a.slots.Button;
|
|
1213
|
-
if (Slot) return /* @__PURE__ */
|
|
1242
|
+
if (Slot) return /* @__PURE__ */ jsx6(Slot, { variant, loading, ...rest, children });
|
|
1214
1243
|
const base = `throttle-button throttle-button--${variant}${size === "xs" ? " throttle-button--xs" : ""}${loading ? " throttle-button--loading" : ""}`;
|
|
1215
1244
|
return /* @__PURE__ */ jsxs2(
|
|
1216
1245
|
"button",
|
|
@@ -1221,8 +1250,8 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1221
1250
|
disabled: rest.disabled || loading,
|
|
1222
1251
|
"aria-busy": loading ? true : void 0,
|
|
1223
1252
|
children: [
|
|
1224
|
-
loading ? /* @__PURE__ */
|
|
1225
|
-
/* @__PURE__ */
|
|
1253
|
+
loading ? /* @__PURE__ */ jsx6(Spinner, { centred: true }) : null,
|
|
1254
|
+
/* @__PURE__ */ jsx6("span", { className: `throttle-button__label${loading ? " throttle-button__label--hidden" : ""}`, children })
|
|
1226
1255
|
]
|
|
1227
1256
|
}
|
|
1228
1257
|
);
|
|
@@ -1230,7 +1259,7 @@ function Button({ variant = "primary", size = "default", elementKey, loading, ch
|
|
|
1230
1259
|
|
|
1231
1260
|
// src/react/components/primitives/Field.tsx
|
|
1232
1261
|
import { Children, Fragment, useId } from "react";
|
|
1233
|
-
import { jsx as
|
|
1262
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1234
1263
|
function Field(props) {
|
|
1235
1264
|
const a = useAppearance();
|
|
1236
1265
|
const base = useId();
|
|
@@ -1238,13 +1267,13 @@ function Field(props) {
|
|
|
1238
1267
|
const hintId = `${base}-hint`;
|
|
1239
1268
|
const errorId = `${base}-error`;
|
|
1240
1269
|
const describedBy = [props.hint ? hintId : null, props.error ? errorId : null].filter(Boolean).join(" ");
|
|
1241
|
-
const label = /* @__PURE__ */
|
|
1270
|
+
const label = /* @__PURE__ */ jsx7("label", { ...a.el("field.label", "throttle-field__label"), htmlFor: inputId, children: props.label });
|
|
1242
1271
|
return /* @__PURE__ */ jsxs3("div", { ...a.el(props.elementKey ?? "field", "throttle-field"), children: [
|
|
1243
1272
|
props.labelExtra ? /* @__PURE__ */ jsxs3("div", { className: "throttle-field__labelrow", children: [
|
|
1244
1273
|
label,
|
|
1245
1274
|
props.labelExtra
|
|
1246
1275
|
] }) : label,
|
|
1247
|
-
/* @__PURE__ */
|
|
1276
|
+
/* @__PURE__ */ jsx7(
|
|
1248
1277
|
"input",
|
|
1249
1278
|
{
|
|
1250
1279
|
...a.el("field.input", `throttle-field__input${props.grouped ? " throttle-field__input--grouped" : ""}`),
|
|
@@ -1260,26 +1289,26 @@ function Field(props) {
|
|
|
1260
1289
|
onChange: (e) => props.onChange(e.target.value)
|
|
1261
1290
|
}
|
|
1262
1291
|
),
|
|
1263
|
-
props.hint ? /* @__PURE__ */
|
|
1264
|
-
/* @__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 ?? "" })
|
|
1265
1294
|
] });
|
|
1266
1295
|
}
|
|
1267
1296
|
function FieldGroup(props) {
|
|
1268
1297
|
const a = useAppearance();
|
|
1269
1298
|
const items = Children.toArray(props.children).filter(Boolean);
|
|
1270
|
-
return /* @__PURE__ */
|
|
1271
|
-
i > 0 ? /* @__PURE__ */
|
|
1272
|
-
/* @__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 })
|
|
1273
1302
|
] }, i)) });
|
|
1274
1303
|
}
|
|
1275
1304
|
|
|
1276
1305
|
// src/react/components/primitives/Alert.tsx
|
|
1277
|
-
import { jsx as
|
|
1306
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1278
1307
|
function Alert(props) {
|
|
1279
1308
|
const a = useAppearance();
|
|
1280
1309
|
const Slot = a.slots.Alert;
|
|
1281
|
-
if (Slot) return /* @__PURE__ */
|
|
1282
|
-
return /* @__PURE__ */
|
|
1310
|
+
if (Slot) return /* @__PURE__ */ jsx8(Slot, { tone: props.tone, children: props.children });
|
|
1311
|
+
return /* @__PURE__ */ jsx8(
|
|
1283
1312
|
"p",
|
|
1284
1313
|
{
|
|
1285
1314
|
...a.el("alert", `throttle-alert throttle-alert--${props.tone}`),
|
|
@@ -1290,16 +1319,32 @@ function Alert(props) {
|
|
|
1290
1319
|
}
|
|
1291
1320
|
|
|
1292
1321
|
// src/react/components/primitives/Skeleton.tsx
|
|
1293
|
-
import { jsx as
|
|
1322
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1294
1323
|
function Skeleton(props) {
|
|
1295
1324
|
const a = useAppearance();
|
|
1296
1325
|
const rows = Array.from({ length: props.count ?? 1 });
|
|
1297
|
-
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)) });
|
|
1298
1327
|
}
|
|
1299
1328
|
|
|
1300
1329
|
// src/react/components/primitives/Modal.tsx
|
|
1301
1330
|
import { useEffect, useRef, useState } from "react";
|
|
1302
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
|
|
1303
1348
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1304
1349
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1305
1350
|
function Modal(props) {
|
|
@@ -1389,15 +1434,68 @@ function Modal(props) {
|
|
|
1389
1434
|
);
|
|
1390
1435
|
}
|
|
1391
1436
|
|
|
1392
|
-
// src/react/components/primitives/
|
|
1393
|
-
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";
|
|
1394
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";
|
|
1395
1493
|
function Dropdown(props) {
|
|
1396
1494
|
const a = useAppearance();
|
|
1397
|
-
const [open, setOpen] =
|
|
1398
|
-
const root =
|
|
1399
|
-
const trigger =
|
|
1400
|
-
const menu =
|
|
1495
|
+
const [open, setOpen] = useState3(false);
|
|
1496
|
+
const root = useRef3(null);
|
|
1497
|
+
const trigger = useRef3(null);
|
|
1498
|
+
const menu = useRef3(null);
|
|
1401
1499
|
useEffect2(() => {
|
|
1402
1500
|
if (!open) return;
|
|
1403
1501
|
menu.current?.querySelector('[role="menuitem"]')?.focus();
|
|
@@ -1424,8 +1522,8 @@ function Dropdown(props) {
|
|
|
1424
1522
|
const next = (at + delta + items.length) % items.length;
|
|
1425
1523
|
items[next < 0 ? items.length - 1 : next].focus();
|
|
1426
1524
|
};
|
|
1427
|
-
return /* @__PURE__ */
|
|
1428
|
-
/* @__PURE__ */
|
|
1525
|
+
return /* @__PURE__ */ jsxs6("div", { ref: root, style: { position: "relative", display: "inline-block" }, children: [
|
|
1526
|
+
/* @__PURE__ */ jsx13(
|
|
1429
1527
|
"button",
|
|
1430
1528
|
{
|
|
1431
1529
|
ref: trigger,
|
|
@@ -1438,7 +1536,7 @@ function Dropdown(props) {
|
|
|
1438
1536
|
children: props.trigger
|
|
1439
1537
|
}
|
|
1440
1538
|
),
|
|
1441
|
-
open ? /* @__PURE__ */
|
|
1539
|
+
open ? /* @__PURE__ */ jsx13(
|
|
1442
1540
|
"div",
|
|
1443
1541
|
{
|
|
1444
1542
|
ref: menu,
|
|
@@ -1464,24 +1562,24 @@ function DropdownItem(props) {
|
|
|
1464
1562
|
const a = useAppearance();
|
|
1465
1563
|
const attrs = a.el(props.itemKey ?? "dropdown.item", "throttle-dropdown__item");
|
|
1466
1564
|
if (props.href) {
|
|
1467
|
-
return /* @__PURE__ */
|
|
1565
|
+
return /* @__PURE__ */ jsx13("a", { ...attrs, role: "menuitem", href: props.href, tabIndex: -1, children: props.children });
|
|
1468
1566
|
}
|
|
1469
|
-
return /* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ jsx13("button", { ...attrs, role: "menuitem", type: "button", tabIndex: -1, onClick: props.onClick, children: props.children });
|
|
1470
1568
|
}
|
|
1471
1569
|
function DropdownSeparator() {
|
|
1472
1570
|
const a = useAppearance();
|
|
1473
|
-
return /* @__PURE__ */
|
|
1571
|
+
return /* @__PURE__ */ jsx13("hr", { ...a.el("dropdown.separator", "throttle-dropdown__separator") });
|
|
1474
1572
|
}
|
|
1475
1573
|
|
|
1476
1574
|
// src/react/components/primitives/Tabs.tsx
|
|
1477
|
-
import { jsx as
|
|
1575
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1478
1576
|
function Tabs(props) {
|
|
1479
1577
|
const a = useAppearance();
|
|
1480
1578
|
const at = props.tabs.findIndex((t) => t.id === props.active);
|
|
1481
1579
|
const vertical = props.orientation === "vertical";
|
|
1482
1580
|
const listClass = vertical ? "throttle-tabs__rail" : "throttle-tabs__list";
|
|
1483
1581
|
const itemClass = vertical ? "throttle-tabs__railitem" : "throttle-tabs__tab";
|
|
1484
|
-
return /* @__PURE__ */
|
|
1582
|
+
return /* @__PURE__ */ jsx14(
|
|
1485
1583
|
"div",
|
|
1486
1584
|
{
|
|
1487
1585
|
...a.el("tabs.list", listClass),
|
|
@@ -1500,7 +1598,7 @@ function Tabs(props) {
|
|
|
1500
1598
|
children: props.tabs.map((tab) => {
|
|
1501
1599
|
const selected = tab.id === props.active;
|
|
1502
1600
|
const { className, ...rest } = a.el("tabs.tab", itemClass);
|
|
1503
|
-
return /* @__PURE__ */
|
|
1601
|
+
return /* @__PURE__ */ jsxs7(
|
|
1504
1602
|
"button",
|
|
1505
1603
|
{
|
|
1506
1604
|
...rest,
|
|
@@ -1525,16 +1623,16 @@ function Tabs(props) {
|
|
|
1525
1623
|
}
|
|
1526
1624
|
|
|
1527
1625
|
// src/react/components/primitives/DataTable.tsx
|
|
1528
|
-
import { jsx as
|
|
1626
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1529
1627
|
function DataTable(props) {
|
|
1530
1628
|
const a = useAppearance();
|
|
1531
1629
|
const clickable = Boolean(props.onRowClick);
|
|
1532
1630
|
return (
|
|
1533
1631
|
// Tables are the one thing allowed to be wider than the panel; it scrolls
|
|
1534
1632
|
// rather than forcing the whole page to.
|
|
1535
|
-
/* @__PURE__ */
|
|
1536
|
-
/* @__PURE__ */
|
|
1537
|
-
/* @__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(
|
|
1538
1636
|
"tr",
|
|
1539
1637
|
{
|
|
1540
1638
|
...a.el(props.rowElementKey ?? "table.row", "throttle-table__row"),
|
|
@@ -1546,7 +1644,7 @@ function DataTable(props) {
|
|
|
1546
1644
|
props.onRowClick(row);
|
|
1547
1645
|
}
|
|
1548
1646
|
} : void 0,
|
|
1549
|
-
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))
|
|
1550
1648
|
},
|
|
1551
1649
|
props.rowKey(row)
|
|
1552
1650
|
)) })
|
|
@@ -1555,48 +1653,49 @@ function DataTable(props) {
|
|
|
1555
1653
|
}
|
|
1556
1654
|
|
|
1557
1655
|
// src/react/components/primitives/EmptyState.tsx
|
|
1558
|
-
import { jsx as
|
|
1656
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1559
1657
|
function EmptyState(props) {
|
|
1560
1658
|
const a = useAppearance();
|
|
1561
1659
|
const Slot = a.slots.EmptyState;
|
|
1562
|
-
if (Slot) return /* @__PURE__ */
|
|
1563
|
-
return /* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1565
|
-
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
|
|
1566
1664
|
] });
|
|
1567
1665
|
}
|
|
1568
1666
|
|
|
1569
1667
|
// src/react/components/primitives/Avatar.tsx
|
|
1570
|
-
import { jsx as
|
|
1668
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1571
1669
|
function Avatar(props) {
|
|
1572
1670
|
const a = useAppearance();
|
|
1573
1671
|
const Slot = a.slots.Avatar;
|
|
1574
|
-
if (Slot) return /* @__PURE__ */
|
|
1672
|
+
if (Slot) return /* @__PURE__ */ jsx17(Slot, { name: props.name, email: props.email });
|
|
1575
1673
|
const initials = props.name.split(" ").map((part) => part.trim()[0]).filter(Boolean).slice(0, 2).join("") || props.email.trim()[0] || "?";
|
|
1576
|
-
return /* @__PURE__ */
|
|
1674
|
+
return /* @__PURE__ */ jsx17("span", { ...a.el("avatar", "throttle-avatar"), title: props.email, children: initials.toUpperCase() });
|
|
1577
1675
|
}
|
|
1578
1676
|
|
|
1579
1677
|
// src/react/components/primitives/Badge.tsx
|
|
1580
|
-
import { jsx as
|
|
1678
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1581
1679
|
function Badge(props) {
|
|
1582
1680
|
const a = useAppearance();
|
|
1583
1681
|
const tone = props.tone ?? "neutral";
|
|
1584
1682
|
const base = tone === "neutral" ? "throttle-badge" : `throttle-badge throttle-badge--${tone}`;
|
|
1585
|
-
return /* @__PURE__ */
|
|
1683
|
+
return /* @__PURE__ */ jsx18("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
|
|
1586
1684
|
}
|
|
1587
1685
|
|
|
1588
1686
|
// src/react/components/auth/StepUpDialog.tsx
|
|
1589
|
-
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";
|
|
1590
1689
|
function StepUpDialog(props) {
|
|
1591
1690
|
const a = useAppearance();
|
|
1592
1691
|
const cardClass = useCardClass();
|
|
1593
1692
|
const { t } = useCopy();
|
|
1594
|
-
const [password, setPassword] =
|
|
1595
|
-
const titleId =
|
|
1693
|
+
const [password, setPassword] = useState4("");
|
|
1694
|
+
const titleId = useId3();
|
|
1596
1695
|
useEffect3(() => {
|
|
1597
1696
|
if (!props.open) setPassword("");
|
|
1598
1697
|
}, [props.open]);
|
|
1599
|
-
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(
|
|
1600
1699
|
"form",
|
|
1601
1700
|
{
|
|
1602
1701
|
onSubmit: (e) => {
|
|
@@ -1604,12 +1703,12 @@ function StepUpDialog(props) {
|
|
|
1604
1703
|
props.onResolve(password);
|
|
1605
1704
|
},
|
|
1606
1705
|
children: [
|
|
1607
|
-
/* @__PURE__ */
|
|
1608
|
-
/* @__PURE__ */
|
|
1609
|
-
/* @__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 })
|
|
1610
1709
|
] }),
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ jsxs10(CardBody, { children: [
|
|
1711
|
+
/* @__PURE__ */ jsx19(
|
|
1613
1712
|
Field,
|
|
1614
1713
|
{
|
|
1615
1714
|
label: t.stepUp.password,
|
|
@@ -1621,8 +1720,8 @@ function StepUpDialog(props) {
|
|
|
1621
1720
|
elementKey: "stepUp.passwordField"
|
|
1622
1721
|
}
|
|
1623
1722
|
),
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
/* @__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 })
|
|
1626
1725
|
] })
|
|
1627
1726
|
]
|
|
1628
1727
|
}
|
|
@@ -1630,23 +1729,23 @@ function StepUpDialog(props) {
|
|
|
1630
1729
|
}
|
|
1631
1730
|
|
|
1632
1731
|
// src/react/components/auth/AuthModal.tsx
|
|
1633
|
-
import { useId as
|
|
1732
|
+
import { useId as useId4 } from "react";
|
|
1634
1733
|
|
|
1635
1734
|
// src/react/components/auth/AuthFlow.tsx
|
|
1636
|
-
import { useEffect as useEffect5, useState as
|
|
1735
|
+
import { useEffect as useEffect5, useState as useState11 } from "react";
|
|
1637
1736
|
|
|
1638
1737
|
// src/react/components/auth/SignIn.tsx
|
|
1639
|
-
import { useState as
|
|
1738
|
+
import { useState as useState6 } from "react";
|
|
1640
1739
|
|
|
1641
1740
|
// src/react/components/useAction.ts
|
|
1642
|
-
import { useCallback, useRef as
|
|
1741
|
+
import { useCallback as useCallback2, useRef as useRef4, useState as useState5 } from "react";
|
|
1643
1742
|
function useAction() {
|
|
1644
1743
|
const { errorMessage } = useCopy();
|
|
1645
|
-
const [submitting, setSubmitting] =
|
|
1646
|
-
const [error, setError] =
|
|
1647
|
-
const [notice, setNotice] =
|
|
1648
|
-
const inFlight =
|
|
1649
|
-
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(
|
|
1650
1749
|
async (fn) => {
|
|
1651
1750
|
if (inFlight.current) return;
|
|
1652
1751
|
inFlight.current = true;
|
|
@@ -1669,7 +1768,7 @@ function useAction() {
|
|
|
1669
1768
|
}
|
|
1670
1769
|
|
|
1671
1770
|
// src/react/components/auth/SignIn.tsx
|
|
1672
|
-
import { Fragment as Fragment2, jsx as
|
|
1771
|
+
import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1673
1772
|
function SignIn(props) {
|
|
1674
1773
|
const a = useAppearance(props.appearance);
|
|
1675
1774
|
const cardClass = useCardClass();
|
|
@@ -1677,14 +1776,14 @@ function SignIn(props) {
|
|
|
1677
1776
|
const { t } = useCopy(props.localization);
|
|
1678
1777
|
const { auth } = useAuth();
|
|
1679
1778
|
const { submitting, error, run } = useAction();
|
|
1680
|
-
const [email, setEmail] =
|
|
1681
|
-
const [password, setPassword] =
|
|
1779
|
+
const [email, setEmail] = useState6("");
|
|
1780
|
+
const [password, setPassword] = useState6("");
|
|
1682
1781
|
const variant = props.variant ?? "quiet";
|
|
1683
1782
|
const branded = variant === "branded";
|
|
1684
1783
|
const grouped = variant === "grouped";
|
|
1685
1784
|
const logo = useBrandLogo(props.logo);
|
|
1686
|
-
const forgotLink = props.onForgotPassword ? /* @__PURE__ */
|
|
1687
|
-
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(
|
|
1688
1787
|
Field,
|
|
1689
1788
|
{
|
|
1690
1789
|
label: t.signIn.email,
|
|
@@ -1697,7 +1796,7 @@ function SignIn(props) {
|
|
|
1697
1796
|
grouped
|
|
1698
1797
|
}
|
|
1699
1798
|
);
|
|
1700
|
-
const passwordField = /* @__PURE__ */
|
|
1799
|
+
const passwordField = /* @__PURE__ */ jsx20(
|
|
1701
1800
|
Field,
|
|
1702
1801
|
{
|
|
1703
1802
|
label: t.signIn.password,
|
|
@@ -1711,7 +1810,7 @@ function SignIn(props) {
|
|
|
1711
1810
|
labelExtra: grouped ? void 0 : forgotLink
|
|
1712
1811
|
}
|
|
1713
1812
|
);
|
|
1714
|
-
return /* @__PURE__ */
|
|
1813
|
+
return /* @__PURE__ */ jsx20(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx20("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs11(
|
|
1715
1814
|
"form",
|
|
1716
1815
|
{
|
|
1717
1816
|
...a.el("signIn.root", cardClass),
|
|
@@ -1723,7 +1822,7 @@ function SignIn(props) {
|
|
|
1723
1822
|
});
|
|
1724
1823
|
},
|
|
1725
1824
|
children: [
|
|
1726
|
-
/* @__PURE__ */
|
|
1825
|
+
/* @__PURE__ */ jsx20(
|
|
1727
1826
|
CardHeader,
|
|
1728
1827
|
{
|
|
1729
1828
|
title: t.signIn.title,
|
|
@@ -1734,24 +1833,24 @@ function SignIn(props) {
|
|
|
1734
1833
|
branded
|
|
1735
1834
|
}
|
|
1736
1835
|
),
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
grouped ? /* @__PURE__ */
|
|
1836
|
+
/* @__PURE__ */ jsxs11(CardBody, { children: [
|
|
1837
|
+
grouped ? /* @__PURE__ */ jsxs11(FieldGroup, { children: [
|
|
1739
1838
|
emailField,
|
|
1740
1839
|
passwordField
|
|
1741
|
-
] }) : /* @__PURE__ */
|
|
1840
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
1742
1841
|
emailField,
|
|
1743
1842
|
passwordField
|
|
1744
1843
|
] }),
|
|
1745
|
-
grouped && forgotLink ? /* @__PURE__ */
|
|
1746
|
-
error ? /* @__PURE__ */
|
|
1747
|
-
/* @__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 })
|
|
1748
1847
|
] }),
|
|
1749
|
-
props.onSignUp ? /* @__PURE__ */
|
|
1750
|
-
/* @__PURE__ */
|
|
1848
|
+
props.onSignUp ? /* @__PURE__ */ jsxs11(CardFooter, { ruled: !branded, children: [
|
|
1849
|
+
/* @__PURE__ */ jsxs11("span", { className: "throttle-muted", children: [
|
|
1751
1850
|
t.signIn.switchPrompt,
|
|
1752
1851
|
" "
|
|
1753
1852
|
] }),
|
|
1754
|
-
/* @__PURE__ */
|
|
1853
|
+
/* @__PURE__ */ jsx20(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
|
|
1755
1854
|
] }) : null
|
|
1756
1855
|
]
|
|
1757
1856
|
}
|
|
@@ -1759,8 +1858,8 @@ function SignIn(props) {
|
|
|
1759
1858
|
}
|
|
1760
1859
|
|
|
1761
1860
|
// src/react/components/auth/SignUp.tsx
|
|
1762
|
-
import { useState as
|
|
1763
|
-
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";
|
|
1764
1863
|
function SignUp(props) {
|
|
1765
1864
|
const a = useAppearance(props.appearance);
|
|
1766
1865
|
const cardClass = useCardClass();
|
|
@@ -1768,13 +1867,13 @@ function SignUp(props) {
|
|
|
1768
1867
|
const { t } = useCopy(props.localization);
|
|
1769
1868
|
const { auth } = useAuth();
|
|
1770
1869
|
const { submitting, error, notice, run } = useAction();
|
|
1771
|
-
const [email, setEmail] =
|
|
1772
|
-
const [password, setPassword] =
|
|
1870
|
+
const [email, setEmail] = useState7("");
|
|
1871
|
+
const [password, setPassword] = useState7("");
|
|
1773
1872
|
const variant = props.variant ?? "quiet";
|
|
1774
1873
|
const branded = variant === "branded";
|
|
1775
1874
|
const grouped = variant === "grouped";
|
|
1776
1875
|
const logo = useBrandLogo(props.logo);
|
|
1777
|
-
const emailField = /* @__PURE__ */
|
|
1876
|
+
const emailField = /* @__PURE__ */ jsx21(
|
|
1778
1877
|
Field,
|
|
1779
1878
|
{
|
|
1780
1879
|
label: t.signUp.email,
|
|
@@ -1787,7 +1886,7 @@ function SignUp(props) {
|
|
|
1787
1886
|
grouped
|
|
1788
1887
|
}
|
|
1789
1888
|
);
|
|
1790
|
-
const passwordField = /* @__PURE__ */
|
|
1889
|
+
const passwordField = /* @__PURE__ */ jsx21(
|
|
1791
1890
|
Field,
|
|
1792
1891
|
{
|
|
1793
1892
|
label: t.signUp.password,
|
|
@@ -1800,7 +1899,7 @@ function SignUp(props) {
|
|
|
1800
1899
|
grouped
|
|
1801
1900
|
}
|
|
1802
1901
|
);
|
|
1803
|
-
return /* @__PURE__ */
|
|
1902
|
+
return /* @__PURE__ */ jsx21(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx21("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs12(
|
|
1804
1903
|
"form",
|
|
1805
1904
|
{
|
|
1806
1905
|
...a.el("signUp.root", cardClass),
|
|
@@ -1816,7 +1915,7 @@ function SignUp(props) {
|
|
|
1816
1915
|
});
|
|
1817
1916
|
},
|
|
1818
1917
|
children: [
|
|
1819
|
-
/* @__PURE__ */
|
|
1918
|
+
/* @__PURE__ */ jsx21(
|
|
1820
1919
|
CardHeader,
|
|
1821
1920
|
{
|
|
1822
1921
|
title: t.signUp.title,
|
|
@@ -1827,24 +1926,24 @@ function SignUp(props) {
|
|
|
1827
1926
|
branded
|
|
1828
1927
|
}
|
|
1829
1928
|
),
|
|
1830
|
-
/* @__PURE__ */
|
|
1831
|
-
grouped ? /* @__PURE__ */
|
|
1929
|
+
/* @__PURE__ */ jsxs12(CardBody, { children: [
|
|
1930
|
+
grouped ? /* @__PURE__ */ jsxs12(FieldGroup, { children: [
|
|
1832
1931
|
emailField,
|
|
1833
1932
|
passwordField
|
|
1834
|
-
] }) : /* @__PURE__ */
|
|
1933
|
+
] }) : /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
1835
1934
|
emailField,
|
|
1836
1935
|
passwordField
|
|
1837
1936
|
] }),
|
|
1838
|
-
error ? /* @__PURE__ */
|
|
1839
|
-
notice ? /* @__PURE__ */
|
|
1840
|
-
/* @__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 })
|
|
1841
1940
|
] }),
|
|
1842
|
-
props.onSignIn ? /* @__PURE__ */
|
|
1843
|
-
/* @__PURE__ */
|
|
1941
|
+
props.onSignIn ? /* @__PURE__ */ jsxs12(CardFooter, { ruled: !branded, children: [
|
|
1942
|
+
/* @__PURE__ */ jsxs12("span", { className: "throttle-muted", children: [
|
|
1844
1943
|
t.signUp.switchPrompt,
|
|
1845
1944
|
" "
|
|
1846
1945
|
] }),
|
|
1847
|
-
/* @__PURE__ */
|
|
1946
|
+
/* @__PURE__ */ jsx21(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
|
|
1848
1947
|
] }) : null
|
|
1849
1948
|
]
|
|
1850
1949
|
}
|
|
@@ -1852,8 +1951,8 @@ function SignUp(props) {
|
|
|
1852
1951
|
}
|
|
1853
1952
|
|
|
1854
1953
|
// src/react/components/auth/ForgotPassword.tsx
|
|
1855
|
-
import { useState as
|
|
1856
|
-
import { jsx as
|
|
1954
|
+
import { useState as useState8 } from "react";
|
|
1955
|
+
import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1857
1956
|
function ForgotPassword(props) {
|
|
1858
1957
|
const a = useAppearance(props.appearance);
|
|
1859
1958
|
const cardClass = useCardClass();
|
|
@@ -1861,10 +1960,10 @@ function ForgotPassword(props) {
|
|
|
1861
1960
|
const { t } = useCopy(props.localization);
|
|
1862
1961
|
const { auth } = useAuth();
|
|
1863
1962
|
const { submitting, error, notice, run } = useAction();
|
|
1864
|
-
const [email, setEmail] =
|
|
1963
|
+
const [email, setEmail] = useState8("");
|
|
1865
1964
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1866
1965
|
const logo = useBrandLogo(props.logo);
|
|
1867
|
-
return /* @__PURE__ */
|
|
1966
|
+
return /* @__PURE__ */ jsx22(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsx22("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs13(
|
|
1868
1967
|
"form",
|
|
1869
1968
|
{
|
|
1870
1969
|
...a.el("forgotPassword.root", cardClass),
|
|
@@ -1876,7 +1975,7 @@ function ForgotPassword(props) {
|
|
|
1876
1975
|
});
|
|
1877
1976
|
},
|
|
1878
1977
|
children: [
|
|
1879
|
-
/* @__PURE__ */
|
|
1978
|
+
/* @__PURE__ */ jsx22(
|
|
1880
1979
|
CardHeader,
|
|
1881
1980
|
{
|
|
1882
1981
|
title: t.forgotPassword.title,
|
|
@@ -1887,8 +1986,8 @@ function ForgotPassword(props) {
|
|
|
1887
1986
|
branded
|
|
1888
1987
|
}
|
|
1889
1988
|
),
|
|
1890
|
-
/* @__PURE__ */
|
|
1891
|
-
/* @__PURE__ */
|
|
1989
|
+
/* @__PURE__ */ jsxs13(CardBody, { children: [
|
|
1990
|
+
/* @__PURE__ */ jsx22(
|
|
1892
1991
|
Field,
|
|
1893
1992
|
{
|
|
1894
1993
|
label: t.forgotPassword.email,
|
|
@@ -1900,19 +1999,19 @@ function ForgotPassword(props) {
|
|
|
1900
1999
|
elementKey: "forgotPassword.emailField"
|
|
1901
2000
|
}
|
|
1902
2001
|
),
|
|
1903
|
-
error ? /* @__PURE__ */
|
|
1904
|
-
notice ? /* @__PURE__ */
|
|
1905
|
-
/* @__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 })
|
|
1906
2005
|
] }),
|
|
1907
|
-
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
|
|
1908
2007
|
]
|
|
1909
2008
|
}
|
|
1910
2009
|
) }) });
|
|
1911
2010
|
}
|
|
1912
2011
|
|
|
1913
2012
|
// src/react/components/auth/ResetPassword.tsx
|
|
1914
|
-
import { useState as
|
|
1915
|
-
import { jsx as
|
|
2013
|
+
import { useState as useState9 } from "react";
|
|
2014
|
+
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1916
2015
|
function ResetPassword(props) {
|
|
1917
2016
|
const a = useAppearance(props.appearance);
|
|
1918
2017
|
const cardClass = useCardClass();
|
|
@@ -1920,11 +2019,11 @@ function ResetPassword(props) {
|
|
|
1920
2019
|
const { t } = useCopy(props.localization);
|
|
1921
2020
|
const { auth } = useAuth();
|
|
1922
2021
|
const { submitting, error, notice, run } = useAction();
|
|
1923
|
-
const [password, setPassword] =
|
|
2022
|
+
const [password, setPassword] = useState9("");
|
|
1924
2023
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1925
2024
|
const logo = useBrandLogo(props.logo);
|
|
1926
|
-
return /* @__PURE__ */
|
|
1927
|
-
/* @__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(
|
|
1928
2027
|
CardHeader,
|
|
1929
2028
|
{
|
|
1930
2029
|
title: t.resetPassword.title,
|
|
@@ -1934,11 +2033,11 @@ function ResetPassword(props) {
|
|
|
1934
2033
|
branded
|
|
1935
2034
|
}
|
|
1936
2035
|
),
|
|
1937
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ jsx23(CardBody, { children: !props.token ? (
|
|
1938
2037
|
// No form at all without a token. A submit button that can only
|
|
1939
2038
|
// fail is worse than an explanation.
|
|
1940
|
-
/* @__PURE__ */
|
|
1941
|
-
) : /* @__PURE__ */
|
|
2039
|
+
/* @__PURE__ */ jsx23(Alert, { tone: "error", children: t.resetPassword.missingToken })
|
|
2040
|
+
) : /* @__PURE__ */ jsx23(
|
|
1942
2041
|
"form",
|
|
1943
2042
|
{
|
|
1944
2043
|
onSubmit: (e) => {
|
|
@@ -1949,8 +2048,8 @@ function ResetPassword(props) {
|
|
|
1949
2048
|
return t.resetPassword.doneNotice;
|
|
1950
2049
|
});
|
|
1951
2050
|
},
|
|
1952
|
-
children: /* @__PURE__ */
|
|
1953
|
-
/* @__PURE__ */
|
|
2051
|
+
children: /* @__PURE__ */ jsxs14("div", { className: "throttle-stack", children: [
|
|
2052
|
+
/* @__PURE__ */ jsx23(
|
|
1954
2053
|
Field,
|
|
1955
2054
|
{
|
|
1956
2055
|
label: t.resetPassword.password,
|
|
@@ -1962,9 +2061,9 @@ function ResetPassword(props) {
|
|
|
1962
2061
|
elementKey: "resetPassword.passwordField"
|
|
1963
2062
|
}
|
|
1964
2063
|
),
|
|
1965
|
-
error ? /* @__PURE__ */
|
|
1966
|
-
notice ? /* @__PURE__ */
|
|
1967
|
-
/* @__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 })
|
|
1968
2067
|
] })
|
|
1969
2068
|
}
|
|
1970
2069
|
) })
|
|
@@ -1972,8 +2071,8 @@ function ResetPassword(props) {
|
|
|
1972
2071
|
}
|
|
1973
2072
|
|
|
1974
2073
|
// src/react/components/auth/VerifyEmail.tsx
|
|
1975
|
-
import { useEffect as useEffect4, useRef as
|
|
1976
|
-
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";
|
|
1977
2076
|
function VerifyEmail(props) {
|
|
1978
2077
|
const a = useAppearance(props.appearance);
|
|
1979
2078
|
const cardClass = useCardClass();
|
|
@@ -1981,11 +2080,11 @@ function VerifyEmail(props) {
|
|
|
1981
2080
|
const { t, errorMessage } = useCopy(props.localization);
|
|
1982
2081
|
const { auth } = useAuth();
|
|
1983
2082
|
const { submitting, notice, run } = useAction();
|
|
1984
|
-
const [state, setState] =
|
|
1985
|
-
const [error, setError] =
|
|
2083
|
+
const [state, setState] = useState10(props.token ? "verifying" : "idle");
|
|
2084
|
+
const [error, setError] = useState10(null);
|
|
1986
2085
|
const branded = (props.variant ?? "quiet") === "branded";
|
|
1987
2086
|
const logo = useBrandLogo(props.logo);
|
|
1988
|
-
const attempted =
|
|
2087
|
+
const attempted = useRef5(null);
|
|
1989
2088
|
useEffect4(() => {
|
|
1990
2089
|
const token = props.token;
|
|
1991
2090
|
if (!token || attempted.current === token) return;
|
|
@@ -1999,8 +2098,8 @@ function VerifyEmail(props) {
|
|
|
1999
2098
|
setState("failed");
|
|
2000
2099
|
});
|
|
2001
2100
|
}, [props.token, auth]);
|
|
2002
|
-
return /* @__PURE__ */
|
|
2003
|
-
/* @__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(
|
|
2004
2103
|
CardHeader,
|
|
2005
2104
|
{
|
|
2006
2105
|
title: t.verifyEmail.title,
|
|
@@ -2010,17 +2109,17 @@ function VerifyEmail(props) {
|
|
|
2010
2109
|
branded
|
|
2011
2110
|
}
|
|
2012
2111
|
),
|
|
2013
|
-
/* @__PURE__ */
|
|
2014
|
-
state === "verifying" ? /* @__PURE__ */
|
|
2015
|
-
/* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ jsxs15(CardBody, { children: [
|
|
2113
|
+
state === "verifying" ? /* @__PURE__ */ jsxs15("p", { children: [
|
|
2114
|
+
/* @__PURE__ */ jsx24(Spinner, {}),
|
|
2016
2115
|
" ",
|
|
2017
2116
|
t.verifyEmail.verifying
|
|
2018
2117
|
] }) : null,
|
|
2019
|
-
state === "done" ? /* @__PURE__ */
|
|
2020
|
-
state === "failed" && error ? /* @__PURE__ */
|
|
2021
|
-
state === "idle" ? /* @__PURE__ */
|
|
2022
|
-
notice ? /* @__PURE__ */
|
|
2023
|
-
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(
|
|
2024
2123
|
Button,
|
|
2025
2124
|
{
|
|
2026
2125
|
variant: "secondary",
|
|
@@ -2038,7 +2137,7 @@ function VerifyEmail(props) {
|
|
|
2038
2137
|
}
|
|
2039
2138
|
|
|
2040
2139
|
// src/react/components/auth/AuthFlow.tsx
|
|
2041
|
-
import { jsx as
|
|
2140
|
+
import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2042
2141
|
var HASH_FOR = {
|
|
2043
2142
|
signIn: "#/sign-in",
|
|
2044
2143
|
signUp: "#/sign-up",
|
|
@@ -2064,8 +2163,8 @@ function readLocation() {
|
|
|
2064
2163
|
function AuthFlow(props) {
|
|
2065
2164
|
const a = useAppearance(props.appearance);
|
|
2066
2165
|
const controlled = props.view !== void 0;
|
|
2067
|
-
const [internal, setInternal] =
|
|
2068
|
-
const [urlToken, setUrlToken] =
|
|
2166
|
+
const [internal, setInternal] = useState11(props.initialView ?? "signIn");
|
|
2167
|
+
const [urlToken, setUrlToken] = useState11(void 0);
|
|
2069
2168
|
useEffect5(() => {
|
|
2070
2169
|
const found = readLocation();
|
|
2071
2170
|
if (found.token) setUrlToken(found.token);
|
|
@@ -2096,8 +2195,8 @@ function AuthFlow(props) {
|
|
|
2096
2195
|
return () => window.removeEventListener("hashchange", onHashChange);
|
|
2097
2196
|
}, [props.routing, controlled]);
|
|
2098
2197
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
2099
|
-
return /* @__PURE__ */
|
|
2100
|
-
view === "signIn" ? /* @__PURE__ */
|
|
2198
|
+
return /* @__PURE__ */ jsx25("div", { ...a.rootProps, children: /* @__PURE__ */ jsxs16("div", { ...a.el("authFlow.root"), children: [
|
|
2199
|
+
view === "signIn" ? /* @__PURE__ */ jsx25(
|
|
2101
2200
|
SignIn,
|
|
2102
2201
|
{
|
|
2103
2202
|
...shared,
|
|
@@ -2106,19 +2205,19 @@ function AuthFlow(props) {
|
|
|
2106
2205
|
onSignUp: () => go("signUp")
|
|
2107
2206
|
}
|
|
2108
2207
|
) : null,
|
|
2109
|
-
view === "signUp" ? /* @__PURE__ */
|
|
2110
|
-
view === "forgotPassword" ? /* @__PURE__ */
|
|
2111
|
-
view === "resetPassword" ? /* @__PURE__ */
|
|
2112
|
-
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
|
|
2113
2212
|
] }) });
|
|
2114
2213
|
}
|
|
2115
2214
|
|
|
2116
2215
|
// src/react/components/auth/AuthModal.tsx
|
|
2117
|
-
import { jsx as
|
|
2216
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2118
2217
|
function AuthModal(props) {
|
|
2119
2218
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2120
|
-
const titleId =
|
|
2121
|
-
return /* @__PURE__ */
|
|
2219
|
+
const titleId = useId4();
|
|
2220
|
+
return /* @__PURE__ */ jsx26(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsxs17(
|
|
2122
2221
|
Modal,
|
|
2123
2222
|
{
|
|
2124
2223
|
open: props.open,
|
|
@@ -2128,8 +2227,8 @@ function AuthModal(props) {
|
|
|
2128
2227
|
overlayKey: "authModal.overlay",
|
|
2129
2228
|
containerKey: "authModal.container",
|
|
2130
2229
|
children: [
|
|
2131
|
-
/* @__PURE__ */
|
|
2132
|
-
/* @__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(
|
|
2133
2232
|
AuthFlow,
|
|
2134
2233
|
{
|
|
2135
2234
|
initialView: props.initialView,
|
|
@@ -2145,14 +2244,14 @@ function AuthModal(props) {
|
|
|
2145
2244
|
}
|
|
2146
2245
|
|
|
2147
2246
|
// src/react/components/account/AccountModal.tsx
|
|
2148
|
-
import { useId as
|
|
2247
|
+
import { useId as useId7 } from "react";
|
|
2149
2248
|
|
|
2150
2249
|
// src/react/components/account/AccountDashboard.tsx
|
|
2151
|
-
import { useEffect as useEffect9, useId as
|
|
2250
|
+
import { useEffect as useEffect9, useId as useId6, useState as useState21 } from "react";
|
|
2152
2251
|
|
|
2153
2252
|
// src/react/components/account/VerifyEmailBanner.tsx
|
|
2154
|
-
import { useState as
|
|
2155
|
-
import { jsx as
|
|
2253
|
+
import { useState as useState12 } from "react";
|
|
2254
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2156
2255
|
var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
|
|
2157
2256
|
function readDismissed() {
|
|
2158
2257
|
try {
|
|
@@ -2173,14 +2272,14 @@ function VerifyEmailBanner(props) {
|
|
|
2173
2272
|
const { t } = useCopy(props.localization);
|
|
2174
2273
|
const { auth, status, emailVerified } = useAuth();
|
|
2175
2274
|
const { submitting, notice, error, run } = useAction();
|
|
2176
|
-
const [dismissed, setDismissed] =
|
|
2275
|
+
const [dismissed, setDismissed] = useState12(readDismissed);
|
|
2177
2276
|
if (status !== "authenticated" || emailVerified || dismissed) return null;
|
|
2178
|
-
return /* @__PURE__ */
|
|
2179
|
-
/* @__PURE__ */
|
|
2180
|
-
notice ? /* @__PURE__ */
|
|
2181
|
-
error ? /* @__PURE__ */
|
|
2182
|
-
/* @__PURE__ */
|
|
2183
|
-
/* @__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(
|
|
2184
2283
|
Button,
|
|
2185
2284
|
{
|
|
2186
2285
|
variant: "secondary",
|
|
@@ -2193,7 +2292,7 @@ function VerifyEmailBanner(props) {
|
|
|
2193
2292
|
children: t.verifyBanner.resendButton
|
|
2194
2293
|
}
|
|
2195
2294
|
),
|
|
2196
|
-
/* @__PURE__ */
|
|
2295
|
+
/* @__PURE__ */ jsx27(
|
|
2197
2296
|
Button,
|
|
2198
2297
|
{
|
|
2199
2298
|
variant: "link",
|
|
@@ -2210,9 +2309,9 @@ function VerifyEmailBanner(props) {
|
|
|
2210
2309
|
}
|
|
2211
2310
|
|
|
2212
2311
|
// src/react/components/account/icons.tsx
|
|
2213
|
-
import { jsx as
|
|
2312
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2214
2313
|
function Glyph(props) {
|
|
2215
|
-
return /* @__PURE__ */
|
|
2314
|
+
return /* @__PURE__ */ jsx28(
|
|
2216
2315
|
"svg",
|
|
2217
2316
|
{
|
|
2218
2317
|
className: "throttle-tabs__railicon",
|
|
@@ -2231,68 +2330,68 @@ function Glyph(props) {
|
|
|
2231
2330
|
);
|
|
2232
2331
|
}
|
|
2233
2332
|
var ACCOUNT_ICONS = {
|
|
2234
|
-
profile: /* @__PURE__ */
|
|
2235
|
-
/* @__PURE__ */
|
|
2236
|
-
/* @__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" })
|
|
2237
2336
|
] }),
|
|
2238
|
-
addresses: /* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2240
|
-
/* @__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" })
|
|
2241
2340
|
] }),
|
|
2242
|
-
paymentMethods: /* @__PURE__ */
|
|
2243
|
-
/* @__PURE__ */
|
|
2244
|
-
/* @__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" })
|
|
2245
2344
|
] }),
|
|
2246
|
-
orders: /* @__PURE__ */
|
|
2247
|
-
/* @__PURE__ */
|
|
2248
|
-
/* @__PURE__ */
|
|
2249
|
-
/* @__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" })
|
|
2250
2349
|
] }),
|
|
2251
|
-
invoices: /* @__PURE__ */
|
|
2252
|
-
/* @__PURE__ */
|
|
2253
|
-
/* @__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" })
|
|
2254
2353
|
] }),
|
|
2255
|
-
subscriptions: /* @__PURE__ */
|
|
2256
|
-
/* @__PURE__ */
|
|
2257
|
-
/* @__PURE__ */
|
|
2258
|
-
/* @__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" })
|
|
2259
2358
|
] }),
|
|
2260
|
-
security: /* @__PURE__ */
|
|
2261
|
-
/* @__PURE__ */
|
|
2262
|
-
/* @__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" })
|
|
2263
2362
|
] })
|
|
2264
2363
|
};
|
|
2265
2364
|
|
|
2266
2365
|
// src/react/components/account/ProfilePanel.tsx
|
|
2267
|
-
import { useEffect as useEffect6, useState as
|
|
2366
|
+
import { useEffect as useEffect6, useState as useState13, useRef as useRef6 } from "react";
|
|
2268
2367
|
|
|
2269
2368
|
// src/react/components/account/PanelState.tsx
|
|
2270
|
-
import { Fragment as Fragment4, jsx as
|
|
2369
|
+
import { Fragment as Fragment4, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2271
2370
|
function PanelState(props) {
|
|
2272
2371
|
const { t, errorMessage } = useCopy();
|
|
2273
2372
|
const { data, isLoading, error, refetch } = props.resource;
|
|
2274
2373
|
const empty = props.isEmpty(data);
|
|
2275
|
-
if (isLoading && empty) return /* @__PURE__ */
|
|
2276
|
-
const errorBanner = error ? /* @__PURE__ */
|
|
2277
|
-
/* @__PURE__ */
|
|
2278
|
-
/* @__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 })
|
|
2279
2378
|
] }) : null;
|
|
2280
2379
|
const gatedByVerification = error?.code === "verification_required";
|
|
2281
2380
|
if (gatedByVerification && empty) {
|
|
2282
|
-
return /* @__PURE__ */
|
|
2381
|
+
return /* @__PURE__ */ jsx29(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
|
|
2283
2382
|
}
|
|
2284
2383
|
if (error && empty) return errorBanner;
|
|
2285
2384
|
if (empty) {
|
|
2286
|
-
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 });
|
|
2287
2386
|
}
|
|
2288
|
-
return /* @__PURE__ */
|
|
2387
|
+
return /* @__PURE__ */ jsxs20(Fragment4, { children: [
|
|
2289
2388
|
errorBanner,
|
|
2290
2389
|
props.children(data)
|
|
2291
2390
|
] });
|
|
2292
2391
|
}
|
|
2293
2392
|
|
|
2294
2393
|
// src/react/components/account/ProfilePanel.tsx
|
|
2295
|
-
import { jsx as
|
|
2394
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2296
2395
|
function ProfilePanel(props) {
|
|
2297
2396
|
const a = useAppearance(props.appearance);
|
|
2298
2397
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2300,8 +2399,8 @@ function ProfilePanel(props) {
|
|
|
2300
2399
|
const { status } = useAuth();
|
|
2301
2400
|
const resource = useCustomer();
|
|
2302
2401
|
const { submitting, error, notice, run } = useAction();
|
|
2303
|
-
const [form, setForm] =
|
|
2304
|
-
const edited =
|
|
2402
|
+
const [form, setForm] = useState13({ firstName: "", lastName: "", phone: "", company: "" });
|
|
2403
|
+
const edited = useRef6(false);
|
|
2305
2404
|
useEffect6(() => {
|
|
2306
2405
|
const c = resource.data;
|
|
2307
2406
|
if (!c || edited.current) return;
|
|
@@ -2313,14 +2412,14 @@ function ProfilePanel(props) {
|
|
|
2313
2412
|
});
|
|
2314
2413
|
}, [resource.data]);
|
|
2315
2414
|
if (status === "unauthenticated") return null;
|
|
2316
|
-
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(
|
|
2317
2416
|
PanelState,
|
|
2318
2417
|
{
|
|
2319
2418
|
resource,
|
|
2320
2419
|
isEmpty: (c) => c === null,
|
|
2321
2420
|
emptyTitle: t.common.somethingWentWrong,
|
|
2322
2421
|
skeletonRows: 4,
|
|
2323
|
-
children: (customer) => /* @__PURE__ */
|
|
2422
|
+
children: (customer) => /* @__PURE__ */ jsxs21(
|
|
2324
2423
|
"form",
|
|
2325
2424
|
{
|
|
2326
2425
|
...a.el("profilePanel.form", "throttle-stack"),
|
|
@@ -2338,7 +2437,7 @@ function ProfilePanel(props) {
|
|
|
2338
2437
|
});
|
|
2339
2438
|
},
|
|
2340
2439
|
children: [
|
|
2341
|
-
/* @__PURE__ */
|
|
2440
|
+
/* @__PURE__ */ jsx30(
|
|
2342
2441
|
Field,
|
|
2343
2442
|
{
|
|
2344
2443
|
label: t.profile.email,
|
|
@@ -2350,7 +2449,7 @@ function ProfilePanel(props) {
|
|
|
2350
2449
|
hint: t.profile.emailReadOnly
|
|
2351
2450
|
}
|
|
2352
2451
|
),
|
|
2353
|
-
/* @__PURE__ */
|
|
2452
|
+
/* @__PURE__ */ jsx30(
|
|
2354
2453
|
Field,
|
|
2355
2454
|
{
|
|
2356
2455
|
label: t.profile.firstName,
|
|
@@ -2362,7 +2461,7 @@ function ProfilePanel(props) {
|
|
|
2362
2461
|
}
|
|
2363
2462
|
}
|
|
2364
2463
|
),
|
|
2365
|
-
/* @__PURE__ */
|
|
2464
|
+
/* @__PURE__ */ jsx30(
|
|
2366
2465
|
Field,
|
|
2367
2466
|
{
|
|
2368
2467
|
label: t.profile.lastName,
|
|
@@ -2374,7 +2473,7 @@ function ProfilePanel(props) {
|
|
|
2374
2473
|
}
|
|
2375
2474
|
}
|
|
2376
2475
|
),
|
|
2377
|
-
/* @__PURE__ */
|
|
2476
|
+
/* @__PURE__ */ jsx30(
|
|
2378
2477
|
Field,
|
|
2379
2478
|
{
|
|
2380
2479
|
label: t.profile.phone,
|
|
@@ -2387,7 +2486,7 @@ function ProfilePanel(props) {
|
|
|
2387
2486
|
}
|
|
2388
2487
|
}
|
|
2389
2488
|
),
|
|
2390
|
-
/* @__PURE__ */
|
|
2489
|
+
/* @__PURE__ */ jsx30(
|
|
2391
2490
|
Field,
|
|
2392
2491
|
{
|
|
2393
2492
|
label: t.profile.company,
|
|
@@ -2399,9 +2498,9 @@ function ProfilePanel(props) {
|
|
|
2399
2498
|
}
|
|
2400
2499
|
}
|
|
2401
2500
|
),
|
|
2402
|
-
error ? /* @__PURE__ */
|
|
2403
|
-
notice ? /* @__PURE__ */
|
|
2404
|
-
/* @__PURE__ */
|
|
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 })
|
|
2405
2504
|
]
|
|
2406
2505
|
}
|
|
2407
2506
|
)
|
|
@@ -2410,16 +2509,16 @@ function ProfilePanel(props) {
|
|
|
2410
2509
|
}
|
|
2411
2510
|
|
|
2412
2511
|
// src/react/components/account/AddressesPanel.tsx
|
|
2413
|
-
import { useState as
|
|
2512
|
+
import { useState as useState15 } from "react";
|
|
2414
2513
|
|
|
2415
2514
|
// src/react/components/account/AddressForm.tsx
|
|
2416
|
-
import { useState as
|
|
2417
|
-
import { jsx as
|
|
2515
|
+
import { useState as useState14 } from "react";
|
|
2516
|
+
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2418
2517
|
function AddressForm(props) {
|
|
2419
2518
|
const a = useAppearance();
|
|
2420
2519
|
const { t } = useCopy();
|
|
2421
2520
|
const i = props.initial;
|
|
2422
|
-
const [form, setForm] =
|
|
2521
|
+
const [form, setForm] = useState14({
|
|
2423
2522
|
label: i?.label ?? "",
|
|
2424
2523
|
firstName: i?.firstName ?? "",
|
|
2425
2524
|
lastName: i?.lastName ?? "",
|
|
@@ -2433,7 +2532,7 @@ function AddressForm(props) {
|
|
|
2433
2532
|
phone: i?.phone ?? ""
|
|
2434
2533
|
});
|
|
2435
2534
|
const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
|
|
2436
|
-
return /* @__PURE__ */
|
|
2535
|
+
return /* @__PURE__ */ jsxs22(
|
|
2437
2536
|
"form",
|
|
2438
2537
|
{
|
|
2439
2538
|
...a.el("addressesPanel.form", "throttle-stack"),
|
|
@@ -2455,11 +2554,11 @@ function AddressForm(props) {
|
|
|
2455
2554
|
});
|
|
2456
2555
|
},
|
|
2457
2556
|
children: [
|
|
2458
|
-
/* @__PURE__ */
|
|
2459
|
-
/* @__PURE__ */
|
|
2460
|
-
/* @__PURE__ */
|
|
2461
|
-
/* @__PURE__ */
|
|
2462
|
-
/* @__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(
|
|
2463
2562
|
Field,
|
|
2464
2563
|
{
|
|
2465
2564
|
label: t.addresses.addressLine1,
|
|
@@ -2469,7 +2568,7 @@ function AddressForm(props) {
|
|
|
2469
2568
|
autoComplete: "address-line1"
|
|
2470
2569
|
}
|
|
2471
2570
|
),
|
|
2472
|
-
/* @__PURE__ */
|
|
2571
|
+
/* @__PURE__ */ jsx31(
|
|
2473
2572
|
Field,
|
|
2474
2573
|
{
|
|
2475
2574
|
label: t.addresses.addressLine2,
|
|
@@ -2478,8 +2577,8 @@ function AddressForm(props) {
|
|
|
2478
2577
|
autoComplete: "address-line2"
|
|
2479
2578
|
}
|
|
2480
2579
|
),
|
|
2481
|
-
/* @__PURE__ */
|
|
2482
|
-
/* @__PURE__ */
|
|
2580
|
+
/* @__PURE__ */ jsx31(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
|
|
2581
|
+
/* @__PURE__ */ jsx31(
|
|
2483
2582
|
Field,
|
|
2484
2583
|
{
|
|
2485
2584
|
label: t.addresses.stateProvince,
|
|
@@ -2488,7 +2587,7 @@ function AddressForm(props) {
|
|
|
2488
2587
|
autoComplete: "address-level1"
|
|
2489
2588
|
}
|
|
2490
2589
|
),
|
|
2491
|
-
/* @__PURE__ */
|
|
2590
|
+
/* @__PURE__ */ jsx31(
|
|
2492
2591
|
Field,
|
|
2493
2592
|
{
|
|
2494
2593
|
label: t.addresses.postalCode,
|
|
@@ -2497,7 +2596,7 @@ function AddressForm(props) {
|
|
|
2497
2596
|
autoComplete: "postal-code"
|
|
2498
2597
|
}
|
|
2499
2598
|
),
|
|
2500
|
-
/* @__PURE__ */
|
|
2599
|
+
/* @__PURE__ */ jsx31(
|
|
2501
2600
|
Field,
|
|
2502
2601
|
{
|
|
2503
2602
|
label: t.addresses.countryCode,
|
|
@@ -2508,11 +2607,11 @@ function AddressForm(props) {
|
|
|
2508
2607
|
hint: "ISO 3166-1 alpha-2, e.g. GB"
|
|
2509
2608
|
}
|
|
2510
2609
|
),
|
|
2511
|
-
/* @__PURE__ */
|
|
2512
|
-
props.error ? /* @__PURE__ */
|
|
2513
|
-
/* @__PURE__ */
|
|
2514
|
-
/* @__PURE__ */
|
|
2515
|
-
/* @__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 })
|
|
2516
2615
|
] })
|
|
2517
2616
|
]
|
|
2518
2617
|
}
|
|
@@ -2520,14 +2619,15 @@ function AddressForm(props) {
|
|
|
2520
2619
|
}
|
|
2521
2620
|
|
|
2522
2621
|
// src/react/components/account/AddressesPanel.tsx
|
|
2523
|
-
import { Fragment as Fragment5, jsx as
|
|
2622
|
+
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2524
2623
|
function AddressesPanel(props) {
|
|
2525
2624
|
const a = useAppearance(props.appearance);
|
|
2526
2625
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2527
2626
|
const { t } = useCopy(props.localization);
|
|
2528
2627
|
const resource = useAddresses();
|
|
2529
2628
|
const { submitting, error, run } = useAction();
|
|
2530
|
-
const
|
|
2629
|
+
const confirm = useConfirm();
|
|
2630
|
+
const [editing, setEditing] = useState15(null);
|
|
2531
2631
|
const variant = props.variant ?? "rows";
|
|
2532
2632
|
const rowsVariant = variant === "rows";
|
|
2533
2633
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -2535,9 +2635,9 @@ function AddressesPanel(props) {
|
|
|
2535
2635
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
2536
2636
|
const close = () => setEditing(null);
|
|
2537
2637
|
const formatAddress = (address) => [address.addressLine2, address.city, address.stateProvince, address.postalCode, address.countryCode].filter(Boolean).join(", ");
|
|
2538
|
-
return /* @__PURE__ */
|
|
2539
|
-
!editing && error ? /* @__PURE__ */
|
|
2540
|
-
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(
|
|
2541
2641
|
AddressForm,
|
|
2542
2642
|
{
|
|
2543
2643
|
initial: editing === "new" ? void 0 : editing,
|
|
@@ -2550,16 +2650,16 @@ function AddressesPanel(props) {
|
|
|
2550
2650
|
close();
|
|
2551
2651
|
})
|
|
2552
2652
|
}
|
|
2553
|
-
) : /* @__PURE__ */
|
|
2554
|
-
/* @__PURE__ */
|
|
2555
|
-
/* @__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(
|
|
2556
2656
|
PanelState,
|
|
2557
2657
|
{
|
|
2558
2658
|
resource,
|
|
2559
2659
|
isEmpty: (rows) => rows.length === 0,
|
|
2560
2660
|
emptyTitle: t.addresses.empty,
|
|
2561
2661
|
emptyDescription: t.addresses.emptyDescription,
|
|
2562
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
2662
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx32(
|
|
2563
2663
|
DataTable,
|
|
2564
2664
|
{
|
|
2565
2665
|
tableKey: "addressesPanel.table",
|
|
@@ -2568,13 +2668,13 @@ function AddressesPanel(props) {
|
|
|
2568
2668
|
rows,
|
|
2569
2669
|
columns: [
|
|
2570
2670
|
{ key: "label", label: t.addresses.label, render: (address) => address.label || address.addressLine1 },
|
|
2571
|
-
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */
|
|
2671
|
+
{ key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
2572
2672
|
address.addressLine1,
|
|
2573
2673
|
formatAddress(address) ? `, ${formatAddress(address)}` : ""
|
|
2574
2674
|
] }) },
|
|
2575
|
-
{ key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */
|
|
2576
|
-
{ key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */
|
|
2577
|
-
!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(
|
|
2578
2678
|
Button,
|
|
2579
2679
|
{
|
|
2580
2680
|
variant: "secondary",
|
|
@@ -2583,7 +2683,7 @@ function AddressesPanel(props) {
|
|
|
2583
2683
|
children: t.addresses.makeDefault
|
|
2584
2684
|
}
|
|
2585
2685
|
) : null,
|
|
2586
|
-
/* @__PURE__ */
|
|
2686
|
+
/* @__PURE__ */ jsx32(
|
|
2587
2687
|
Button,
|
|
2588
2688
|
{
|
|
2589
2689
|
variant: "secondary",
|
|
@@ -2592,14 +2692,14 @@ function AddressesPanel(props) {
|
|
|
2592
2692
|
children: t.common.edit
|
|
2593
2693
|
}
|
|
2594
2694
|
),
|
|
2595
|
-
/* @__PURE__ */
|
|
2695
|
+
/* @__PURE__ */ jsx32(
|
|
2596
2696
|
Button,
|
|
2597
2697
|
{
|
|
2598
2698
|
variant: "danger",
|
|
2599
2699
|
elementKey: "addressesPanel.deleteButton",
|
|
2600
2700
|
disabled: submitting,
|
|
2601
|
-
onClick: () => {
|
|
2602
|
-
if (!
|
|
2701
|
+
onClick: async () => {
|
|
2702
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
2603
2703
|
void run(() => resource.remove(address.id));
|
|
2604
2704
|
},
|
|
2605
2705
|
children: t.common.delete
|
|
@@ -2608,17 +2708,17 @@ function AddressesPanel(props) {
|
|
|
2608
2708
|
] }) }
|
|
2609
2709
|
]
|
|
2610
2710
|
}
|
|
2611
|
-
) : /* @__PURE__ */
|
|
2612
|
-
/* @__PURE__ */
|
|
2613
|
-
/* @__PURE__ */
|
|
2614
|
-
/* @__PURE__ */
|
|
2615
|
-
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
|
|
2616
2716
|
] }),
|
|
2617
|
-
/* @__PURE__ */
|
|
2618
|
-
/* @__PURE__ */
|
|
2717
|
+
/* @__PURE__ */ jsx32("p", { className: "throttle-muted", children: address.addressLine1 }),
|
|
2718
|
+
/* @__PURE__ */ jsx32("p", { className: "throttle-muted", children: formatAddress(address) })
|
|
2619
2719
|
] }),
|
|
2620
|
-
/* @__PURE__ */
|
|
2621
|
-
!address.isDefault ? /* @__PURE__ */
|
|
2720
|
+
/* @__PURE__ */ jsxs23("div", { className: "throttle-actions", children: [
|
|
2721
|
+
!address.isDefault ? /* @__PURE__ */ jsx32(
|
|
2622
2722
|
Button,
|
|
2623
2723
|
{
|
|
2624
2724
|
variant: actionVariant("secondary"),
|
|
@@ -2627,7 +2727,7 @@ function AddressesPanel(props) {
|
|
|
2627
2727
|
children: t.addresses.makeDefault
|
|
2628
2728
|
}
|
|
2629
2729
|
) : null,
|
|
2630
|
-
/* @__PURE__ */
|
|
2730
|
+
/* @__PURE__ */ jsx32(
|
|
2631
2731
|
Button,
|
|
2632
2732
|
{
|
|
2633
2733
|
variant: actionVariant("secondary"),
|
|
@@ -2636,14 +2736,14 @@ function AddressesPanel(props) {
|
|
|
2636
2736
|
children: t.common.edit
|
|
2637
2737
|
}
|
|
2638
2738
|
),
|
|
2639
|
-
/* @__PURE__ */
|
|
2739
|
+
/* @__PURE__ */ jsx32(
|
|
2640
2740
|
Button,
|
|
2641
2741
|
{
|
|
2642
2742
|
variant: actionVariant("danger"),
|
|
2643
2743
|
elementKey: "addressesPanel.deleteButton",
|
|
2644
2744
|
disabled: submitting,
|
|
2645
|
-
onClick: () => {
|
|
2646
|
-
if (!
|
|
2745
|
+
onClick: async () => {
|
|
2746
|
+
if (!await confirm({ title: t.addresses.deleteConfirm, confirmLabel: t.addresses.deleteConfirmAction, tone: "danger" })) return;
|
|
2647
2747
|
void run(() => resource.remove(address.id));
|
|
2648
2748
|
},
|
|
2649
2749
|
children: t.common.delete
|
|
@@ -2658,20 +2758,20 @@ function AddressesPanel(props) {
|
|
|
2658
2758
|
}
|
|
2659
2759
|
|
|
2660
2760
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2661
|
-
import { useState as
|
|
2761
|
+
import { useState as useState17 } from "react";
|
|
2662
2762
|
|
|
2663
2763
|
// src/react/components/account/AddCardDialog.tsx
|
|
2664
|
-
import { useEffect as useEffect7, useId as
|
|
2665
|
-
import { jsx as
|
|
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";
|
|
2666
2766
|
function AddCardDialog(props) {
|
|
2667
2767
|
const { account } = useAuth();
|
|
2668
|
-
const titleId =
|
|
2768
|
+
const titleId = useId5();
|
|
2669
2769
|
const { t } = useCopy(props.localization);
|
|
2670
|
-
const [src, setSrc] =
|
|
2671
|
-
const [error, setError] =
|
|
2672
|
-
const [busy, setBusy] =
|
|
2673
|
-
const onAdded =
|
|
2674
|
-
const onClose =
|
|
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);
|
|
2675
2775
|
onAdded.current = props.onAdded;
|
|
2676
2776
|
onClose.current = props.onClose;
|
|
2677
2777
|
useEffect7(() => {
|
|
@@ -2737,23 +2837,25 @@ function AddCardDialog(props) {
|
|
|
2737
2837
|
return () => window.removeEventListener("message", onMessage);
|
|
2738
2838
|
}, [src, account, t]);
|
|
2739
2839
|
if (!props.open) return null;
|
|
2740
|
-
return /* @__PURE__ */
|
|
2741
|
-
/* @__PURE__ */
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
"
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
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
|
+
] })
|
|
2752
2854
|
] });
|
|
2753
2855
|
}
|
|
2754
2856
|
|
|
2755
2857
|
// src/react/components/account/PaymentMethodsPanel.tsx
|
|
2756
|
-
import { jsx as
|
|
2858
|
+
import { jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2757
2859
|
function PaymentMethodsPanel(props) {
|
|
2758
2860
|
const a = useAppearance(props.appearance);
|
|
2759
2861
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -2761,7 +2863,8 @@ function PaymentMethodsPanel(props) {
|
|
|
2761
2863
|
const { emailVerified } = useAuth();
|
|
2762
2864
|
const resource = useSavedCards();
|
|
2763
2865
|
const { submitting, error, run } = useAction();
|
|
2764
|
-
const
|
|
2866
|
+
const confirm = useConfirm();
|
|
2867
|
+
const [adding, setAdding] = useState17(false);
|
|
2765
2868
|
const variant = props.variant ?? "rows";
|
|
2766
2869
|
const rowsVariant = variant === "rows";
|
|
2767
2870
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
@@ -2769,10 +2872,10 @@ function PaymentMethodsPanel(props) {
|
|
|
2769
2872
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
2770
2873
|
const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
|
|
2771
2874
|
const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
|
|
2772
|
-
return /* @__PURE__ */
|
|
2773
|
-
error ? /* @__PURE__ */
|
|
2774
|
-
emailVerified ? /* @__PURE__ */
|
|
2775
|
-
/* @__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(
|
|
2776
2879
|
AddCardDialog,
|
|
2777
2880
|
{
|
|
2778
2881
|
open: adding,
|
|
@@ -2783,7 +2886,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2783
2886
|
localization: props.localization
|
|
2784
2887
|
}
|
|
2785
2888
|
),
|
|
2786
|
-
/* @__PURE__ */
|
|
2889
|
+
/* @__PURE__ */ jsx34(
|
|
2787
2890
|
PanelState,
|
|
2788
2891
|
{
|
|
2789
2892
|
resource,
|
|
@@ -2792,7 +2895,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2792
2895
|
isEmpty: (rows) => rows.length === 0,
|
|
2793
2896
|
emptyTitle: t.paymentMethods.empty,
|
|
2794
2897
|
emptyDescription: t.paymentMethods.emptyDescription,
|
|
2795
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
2898
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx34(
|
|
2796
2899
|
DataTable,
|
|
2797
2900
|
{
|
|
2798
2901
|
tableKey: "paymentMethodsPanel.table",
|
|
@@ -2802,9 +2905,9 @@ function PaymentMethodsPanel(props) {
|
|
|
2802
2905
|
columns: [
|
|
2803
2906
|
{ key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
|
|
2804
2907
|
{ key: "expires", label: t.paymentMethods.expires, render: (card) => expiryLabel(card) },
|
|
2805
|
-
{ key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */
|
|
2806
|
-
{ key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */
|
|
2807
|
-
!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(
|
|
2808
2911
|
Button,
|
|
2809
2912
|
{
|
|
2810
2913
|
variant: "secondary",
|
|
@@ -2814,14 +2917,14 @@ function PaymentMethodsPanel(props) {
|
|
|
2814
2917
|
children: t.paymentMethods.makeDefault
|
|
2815
2918
|
}
|
|
2816
2919
|
) : null,
|
|
2817
|
-
/* @__PURE__ */
|
|
2920
|
+
/* @__PURE__ */ jsx34(
|
|
2818
2921
|
Button,
|
|
2819
2922
|
{
|
|
2820
2923
|
variant: "danger",
|
|
2821
2924
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
2822
2925
|
disabled: submitting,
|
|
2823
|
-
onClick: () => {
|
|
2824
|
-
if (!
|
|
2926
|
+
onClick: async () => {
|
|
2927
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
2825
2928
|
void run(() => resource.remove(card.id));
|
|
2826
2929
|
},
|
|
2827
2930
|
children: t.common.delete
|
|
@@ -2830,13 +2933,13 @@ function PaymentMethodsPanel(props) {
|
|
|
2830
2933
|
] }) }
|
|
2831
2934
|
]
|
|
2832
2935
|
}
|
|
2833
|
-
) : /* @__PURE__ */
|
|
2834
|
-
/* @__PURE__ */
|
|
2835
|
-
/* @__PURE__ */
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
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
|
|
2838
2941
|
] }),
|
|
2839
|
-
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */
|
|
2942
|
+
card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ jsxs25("p", { className: "throttle-muted", children: [
|
|
2840
2943
|
t.paymentMethods.expires,
|
|
2841
2944
|
" ",
|
|
2842
2945
|
String(card.cardExpMonth).padStart(2, "0"),
|
|
@@ -2844,8 +2947,8 @@ function PaymentMethodsPanel(props) {
|
|
|
2844
2947
|
card.cardExpYear
|
|
2845
2948
|
] }) : null
|
|
2846
2949
|
] }),
|
|
2847
|
-
/* @__PURE__ */
|
|
2848
|
-
!card.isDefault ? /* @__PURE__ */
|
|
2950
|
+
/* @__PURE__ */ jsxs25("div", { className: "throttle-actions", children: [
|
|
2951
|
+
!card.isDefault ? /* @__PURE__ */ jsx34(
|
|
2849
2952
|
Button,
|
|
2850
2953
|
{
|
|
2851
2954
|
variant: actionVariant("secondary"),
|
|
@@ -2855,14 +2958,14 @@ function PaymentMethodsPanel(props) {
|
|
|
2855
2958
|
children: t.paymentMethods.makeDefault
|
|
2856
2959
|
}
|
|
2857
2960
|
) : null,
|
|
2858
|
-
/* @__PURE__ */
|
|
2961
|
+
/* @__PURE__ */ jsx34(
|
|
2859
2962
|
Button,
|
|
2860
2963
|
{
|
|
2861
2964
|
variant: actionVariant("danger"),
|
|
2862
2965
|
elementKey: "paymentMethodsPanel.deleteButton",
|
|
2863
2966
|
disabled: submitting,
|
|
2864
|
-
onClick: () => {
|
|
2865
|
-
if (!
|
|
2967
|
+
onClick: async () => {
|
|
2968
|
+
if (!await confirm({ title: t.paymentMethods.deleteConfirm, confirmLabel: t.paymentMethods.deleteConfirmAction, tone: "danger" })) return;
|
|
2866
2969
|
void run(() => resource.remove(card.id));
|
|
2867
2970
|
},
|
|
2868
2971
|
children: t.common.delete
|
|
@@ -2876,7 +2979,7 @@ function PaymentMethodsPanel(props) {
|
|
|
2876
2979
|
}
|
|
2877
2980
|
|
|
2878
2981
|
// src/react/components/account/OrdersPanel.tsx
|
|
2879
|
-
import { useState as
|
|
2982
|
+
import { useState as useState18 } from "react";
|
|
2880
2983
|
|
|
2881
2984
|
// src/react/components/format.ts
|
|
2882
2985
|
function formatMoney(minorUnits, currency, locale) {
|
|
@@ -2908,7 +3011,7 @@ function formatDate(value, locale) {
|
|
|
2908
3011
|
}
|
|
2909
3012
|
|
|
2910
3013
|
// src/react/components/account/OrderStatus.tsx
|
|
2911
|
-
import { Fragment as Fragment6, jsx as
|
|
3014
|
+
import { Fragment as Fragment6, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2912
3015
|
function copyKey(wire) {
|
|
2913
3016
|
return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
2914
3017
|
}
|
|
@@ -2916,25 +3019,76 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
|
|
|
2916
3019
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
|
|
2917
3020
|
function StatusBadge(props) {
|
|
2918
3021
|
const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2919
|
-
return /* @__PURE__ */
|
|
3022
|
+
return /* @__PURE__ */ jsx35(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
|
|
2920
3023
|
}
|
|
2921
3024
|
function OrderStatus(props) {
|
|
2922
3025
|
const labels = props.t.orders.statusLabels;
|
|
2923
3026
|
const payLabels = props.t.orders.paymentLabels;
|
|
2924
3027
|
const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
|
|
2925
3028
|
const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
|
|
2926
|
-
return /* @__PURE__ */
|
|
2927
|
-
/* @__PURE__ */
|
|
2928
|
-
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}`))
|
|
2929
3081
|
] });
|
|
2930
3082
|
}
|
|
2931
3083
|
|
|
2932
3084
|
// src/react/components/account/OrderDetail.tsx
|
|
2933
|
-
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"]);
|
|
2934
3088
|
function Line(props) {
|
|
2935
|
-
return /* @__PURE__ */
|
|
2936
|
-
/* @__PURE__ */
|
|
2937
|
-
/* @__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 })
|
|
2938
3092
|
] });
|
|
2939
3093
|
}
|
|
2940
3094
|
function OrderDetail(props) {
|
|
@@ -2942,7 +3096,7 @@ function OrderDetail(props) {
|
|
|
2942
3096
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
2943
3097
|
const { t, locale } = useCopy(props.localization);
|
|
2944
3098
|
const resource = useOrder(props.orderId);
|
|
2945
|
-
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: [
|
|
2946
3100
|
props.onBack ? (
|
|
2947
3101
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
2948
3102
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -2950,27 +3104,27 @@ function OrderDetail(props) {
|
|
|
2950
3104
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
2951
3105
|
// its own width. A CSS fix would need a compound selector, and
|
|
2952
3106
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
2953
|
-
/* @__PURE__ */
|
|
3107
|
+
/* @__PURE__ */ jsx38("div", { children: /* @__PURE__ */ jsx38(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
2954
3108
|
) : null,
|
|
2955
|
-
/* @__PURE__ */
|
|
3109
|
+
/* @__PURE__ */ jsx38(
|
|
2956
3110
|
PanelState,
|
|
2957
3111
|
{
|
|
2958
3112
|
resource,
|
|
2959
3113
|
isEmpty: (o) => o === null,
|
|
2960
3114
|
emptyTitle: t.orders.empty,
|
|
2961
3115
|
skeletonRows: 5,
|
|
2962
|
-
children: (order) => /* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
2964
|
-
/* @__PURE__ */
|
|
2965
|
-
/* @__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 })
|
|
2966
3120
|
] }),
|
|
2967
|
-
/* @__PURE__ */
|
|
2968
|
-
/* @__PURE__ */
|
|
2969
|
-
item.imageUrl ? /* @__PURE__ */
|
|
2970
|
-
/* @__PURE__ */
|
|
2971
|
-
/* @__PURE__ */
|
|
2972
|
-
item.description ? /* @__PURE__ */
|
|
2973
|
-
/* @__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: [
|
|
2974
3128
|
t.orders.quantity,
|
|
2975
3129
|
" ",
|
|
2976
3130
|
item.quantity,
|
|
@@ -2978,16 +3132,87 @@ function OrderDetail(props) {
|
|
|
2978
3132
|
formatMoney(item.unitPrice, order.currency, locale)
|
|
2979
3133
|
] })
|
|
2980
3134
|
] }),
|
|
2981
|
-
/* @__PURE__ */
|
|
3135
|
+
/* @__PURE__ */ jsx38("span", { children: formatMoney(item.total, order.currency, locale) })
|
|
2982
3136
|
] }, item.id)) }),
|
|
2983
|
-
/* @__PURE__ */
|
|
2984
|
-
/* @__PURE__ */
|
|
2985
|
-
order.discountTotal ? /* @__PURE__ */
|
|
2986
|
-
/* @__PURE__ */
|
|
2987
|
-
/* @__PURE__ */
|
|
2988
|
-
/* @__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
|
+
)
|
|
2989
3161
|
] }),
|
|
2990
|
-
|
|
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
|
+
})()
|
|
2991
3216
|
] })
|
|
2992
3217
|
}
|
|
2993
3218
|
)
|
|
@@ -2995,31 +3220,34 @@ function OrderDetail(props) {
|
|
|
2995
3220
|
}
|
|
2996
3221
|
|
|
2997
3222
|
// src/react/components/account/OrdersPanel.tsx
|
|
2998
|
-
import { jsx as
|
|
3223
|
+
import { jsx as jsx39, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2999
3224
|
function OrdersPanel(props) {
|
|
3000
3225
|
const a = useAppearance(props.appearance);
|
|
3001
3226
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3002
3227
|
const { t, locale } = useCopy(props.localization);
|
|
3003
3228
|
const { emailVerified } = useAuth();
|
|
3004
3229
|
const resource = useOrders();
|
|
3005
|
-
const [openId, setOpenId] =
|
|
3230
|
+
const [openId, setOpenId] = useState18(null);
|
|
3006
3231
|
const variant = props.variant ?? "table";
|
|
3007
3232
|
const rowsVariant = variant === "rows";
|
|
3008
3233
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3009
3234
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3010
3235
|
if (openId) {
|
|
3011
|
-
return /* @__PURE__ */
|
|
3236
|
+
return /* @__PURE__ */ jsx39(
|
|
3012
3237
|
OrderDetail,
|
|
3013
3238
|
{
|
|
3014
3239
|
orderId: openId,
|
|
3015
3240
|
onBack: () => setOpenId(null),
|
|
3241
|
+
onPayNow: props.onPayNow,
|
|
3242
|
+
onReorder: props.onReorder,
|
|
3243
|
+
onTrackShipment: props.onTrackShipment,
|
|
3016
3244
|
onViewSubscription: props.onViewSubscription,
|
|
3017
3245
|
appearance: props.appearance,
|
|
3018
3246
|
localization: props.localization
|
|
3019
3247
|
}
|
|
3020
3248
|
);
|
|
3021
3249
|
}
|
|
3022
|
-
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(
|
|
3023
3251
|
PanelState,
|
|
3024
3252
|
{
|
|
3025
3253
|
resource,
|
|
@@ -3028,7 +3256,7 @@ function OrdersPanel(props) {
|
|
|
3028
3256
|
isEmpty: (rows) => rows.length === 0,
|
|
3029
3257
|
emptyTitle: t.orders.empty,
|
|
3030
3258
|
emptyDescription: t.orders.emptyDescription,
|
|
3031
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3259
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx39(
|
|
3032
3260
|
DataTable,
|
|
3033
3261
|
{
|
|
3034
3262
|
tableKey: "ordersPanel.table",
|
|
@@ -3042,25 +3270,25 @@ function OrdersPanel(props) {
|
|
|
3042
3270
|
{
|
|
3043
3271
|
key: "status",
|
|
3044
3272
|
label: t.orders.status,
|
|
3045
|
-
render: (o) => /* @__PURE__ */
|
|
3273
|
+
render: (o) => /* @__PURE__ */ jsx39(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
|
|
3046
3274
|
},
|
|
3047
3275
|
{
|
|
3048
3276
|
key: "total",
|
|
3049
3277
|
label: t.orders.total,
|
|
3050
|
-
render: (o) => /* @__PURE__ */
|
|
3278
|
+
render: (o) => /* @__PURE__ */ jsx39("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
|
|
3051
3279
|
}
|
|
3052
3280
|
]
|
|
3053
3281
|
}
|
|
3054
|
-
) : /* @__PURE__ */
|
|
3055
|
-
/* @__PURE__ */
|
|
3056
|
-
/* @__PURE__ */
|
|
3057
|
-
/* @__PURE__ */
|
|
3058
|
-
/* @__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 })
|
|
3059
3287
|
] }),
|
|
3060
|
-
/* @__PURE__ */
|
|
3061
|
-
/* @__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) })
|
|
3062
3290
|
] }),
|
|
3063
|
-
/* @__PURE__ */
|
|
3291
|
+
/* @__PURE__ */ jsx39("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx39(
|
|
3064
3292
|
Button,
|
|
3065
3293
|
{
|
|
3066
3294
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3075,14 +3303,14 @@ function OrdersPanel(props) {
|
|
|
3075
3303
|
}
|
|
3076
3304
|
|
|
3077
3305
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3078
|
-
import { useState as
|
|
3306
|
+
import { useState as useState19 } from "react";
|
|
3079
3307
|
|
|
3080
3308
|
// src/react/components/account/InvoiceDetail.tsx
|
|
3081
|
-
import { Fragment as Fragment8, jsx as
|
|
3309
|
+
import { Fragment as Fragment8, jsx as jsx40, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3082
3310
|
function Line2(props) {
|
|
3083
|
-
return /* @__PURE__ */
|
|
3084
|
-
/* @__PURE__ */
|
|
3085
|
-
/* @__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 })
|
|
3086
3314
|
] });
|
|
3087
3315
|
}
|
|
3088
3316
|
function InvoiceDetail(props) {
|
|
@@ -3092,7 +3320,7 @@ function InvoiceDetail(props) {
|
|
|
3092
3320
|
const { account } = useAuth();
|
|
3093
3321
|
const resource = useInvoice(props.invoiceId);
|
|
3094
3322
|
const { submitting, error, run } = useAction();
|
|
3095
|
-
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: [
|
|
3096
3324
|
props.onBack ? (
|
|
3097
3325
|
// Wrapped on purpose. The panel is a column flex container, so a
|
|
3098
3326
|
// direct child stretches to its full width however `width: auto`
|
|
@@ -3100,25 +3328,25 @@ function InvoiceDetail(props) {
|
|
|
3100
3328
|
// centred label. The wrapper takes the stretch; the button keeps
|
|
3101
3329
|
// its own width. A CSS fix would need a compound selector, and
|
|
3102
3330
|
// those outrank the merchant overrides in `appearance.elements`.
|
|
3103
|
-
/* @__PURE__ */
|
|
3331
|
+
/* @__PURE__ */ jsx40("div", { children: /* @__PURE__ */ jsx40(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
|
|
3104
3332
|
) : null,
|
|
3105
|
-
/* @__PURE__ */
|
|
3106
|
-
/* @__PURE__ */
|
|
3107
|
-
/* @__PURE__ */
|
|
3108
|
-
/* @__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 })
|
|
3109
3337
|
] }),
|
|
3110
|
-
/* @__PURE__ */
|
|
3111
|
-
/* @__PURE__ */
|
|
3112
|
-
invoice.dueAt ? /* @__PURE__ */
|
|
3113
|
-
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(
|
|
3114
3342
|
Line2,
|
|
3115
3343
|
{
|
|
3116
3344
|
label: t.invoices.period,
|
|
3117
3345
|
value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
|
|
3118
3346
|
}
|
|
3119
3347
|
) : null,
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
invoice.amountRefunded ? /* @__PURE__ */
|
|
3348
|
+
/* @__PURE__ */ jsx40(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
|
|
3349
|
+
invoice.amountRefunded ? /* @__PURE__ */ jsx40(
|
|
3122
3350
|
Line2,
|
|
3123
3351
|
{
|
|
3124
3352
|
label: t.invoices.refunded,
|
|
@@ -3126,8 +3354,8 @@ function InvoiceDetail(props) {
|
|
|
3126
3354
|
}
|
|
3127
3355
|
) : null
|
|
3128
3356
|
] }),
|
|
3129
|
-
error ? /* @__PURE__ */
|
|
3130
|
-
/* @__PURE__ */
|
|
3357
|
+
error ? /* @__PURE__ */ jsx40(Alert, { tone: "error", children: error }) : null,
|
|
3358
|
+
/* @__PURE__ */ jsx40(
|
|
3131
3359
|
Button,
|
|
3132
3360
|
{
|
|
3133
3361
|
variant: "secondary",
|
|
@@ -3146,20 +3374,20 @@ function InvoiceDetail(props) {
|
|
|
3146
3374
|
}
|
|
3147
3375
|
|
|
3148
3376
|
// src/react/components/account/InvoicesPanel.tsx
|
|
3149
|
-
import { jsx as
|
|
3377
|
+
import { jsx as jsx41, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3150
3378
|
function InvoicesPanel(props) {
|
|
3151
3379
|
const a = useAppearance(props.appearance);
|
|
3152
3380
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3153
3381
|
const { t, locale } = useCopy(props.localization);
|
|
3154
3382
|
const { emailVerified } = useAuth();
|
|
3155
3383
|
const resource = useInvoices();
|
|
3156
|
-
const [openId, setOpenId] =
|
|
3384
|
+
const [openId, setOpenId] = useState19(null);
|
|
3157
3385
|
const variant = props.variant ?? "table";
|
|
3158
3386
|
const rowsVariant = variant === "rows";
|
|
3159
3387
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3160
3388
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3161
3389
|
if (openId) {
|
|
3162
|
-
return /* @__PURE__ */
|
|
3390
|
+
return /* @__PURE__ */ jsx41(
|
|
3163
3391
|
InvoiceDetail,
|
|
3164
3392
|
{
|
|
3165
3393
|
invoiceId: openId,
|
|
@@ -3169,7 +3397,7 @@ function InvoicesPanel(props) {
|
|
|
3169
3397
|
}
|
|
3170
3398
|
);
|
|
3171
3399
|
}
|
|
3172
|
-
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(
|
|
3173
3401
|
PanelState,
|
|
3174
3402
|
{
|
|
3175
3403
|
resource,
|
|
@@ -3178,7 +3406,7 @@ function InvoicesPanel(props) {
|
|
|
3178
3406
|
isEmpty: (rows) => rows.length === 0,
|
|
3179
3407
|
emptyTitle: t.invoices.empty,
|
|
3180
3408
|
emptyDescription: t.invoices.emptyDescription,
|
|
3181
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3409
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx41(
|
|
3182
3410
|
DataTable,
|
|
3183
3411
|
{
|
|
3184
3412
|
tableKey: "invoicesPanel.table",
|
|
@@ -3189,24 +3417,24 @@ function InvoicesPanel(props) {
|
|
|
3189
3417
|
columns: [
|
|
3190
3418
|
{ key: "number", label: t.invoices.number },
|
|
3191
3419
|
{ key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
|
|
3192
|
-
{ 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 }) },
|
|
3193
3421
|
{
|
|
3194
3422
|
key: "total",
|
|
3195
3423
|
label: t.invoices.total,
|
|
3196
|
-
render: (i) => /* @__PURE__ */
|
|
3424
|
+
render: (i) => /* @__PURE__ */ jsx41("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
|
|
3197
3425
|
}
|
|
3198
3426
|
]
|
|
3199
3427
|
}
|
|
3200
|
-
) : /* @__PURE__ */
|
|
3201
|
-
/* @__PURE__ */
|
|
3202
|
-
/* @__PURE__ */
|
|
3203
|
-
/* @__PURE__ */
|
|
3204
|
-
/* @__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 })
|
|
3205
3433
|
] }),
|
|
3206
|
-
/* @__PURE__ */
|
|
3207
|
-
/* @__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) })
|
|
3208
3436
|
] }),
|
|
3209
|
-
/* @__PURE__ */
|
|
3437
|
+
/* @__PURE__ */ jsx41("div", { className: "throttle-actions", children: /* @__PURE__ */ jsx41(
|
|
3210
3438
|
Button,
|
|
3211
3439
|
{
|
|
3212
3440
|
variant: rowsVariant ? "link" : "secondary",
|
|
@@ -3221,7 +3449,7 @@ function InvoicesPanel(props) {
|
|
|
3221
3449
|
}
|
|
3222
3450
|
|
|
3223
3451
|
// src/react/components/account/SubscriptionsPanel.tsx
|
|
3224
|
-
import { jsx as
|
|
3452
|
+
import { jsx as jsx42, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
3225
3453
|
var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
|
|
3226
3454
|
var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
|
|
3227
3455
|
var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
|
|
@@ -3232,62 +3460,79 @@ function SubscriptionsPanel(props) {
|
|
|
3232
3460
|
const { emailVerified } = useAuth();
|
|
3233
3461
|
const resource = useSubscriptions();
|
|
3234
3462
|
const { submitting, error, run } = useAction();
|
|
3463
|
+
const confirm = useConfirm();
|
|
3235
3464
|
const variant = props.variant ?? "rows";
|
|
3236
3465
|
const rowsVariant = variant === "rows";
|
|
3237
3466
|
const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
|
|
3238
3467
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3239
3468
|
const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
|
|
3240
|
-
const confirmThen = (fn) => () => {
|
|
3241
|
-
|
|
3242
|
-
|
|
3469
|
+
const confirmThen = (fn, ask) => () => {
|
|
3470
|
+
void (async () => {
|
|
3471
|
+
if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
|
|
3472
|
+
await run(fn);
|
|
3473
|
+
})();
|
|
3243
3474
|
};
|
|
3244
3475
|
const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
|
|
3245
3476
|
const renewsLabel = (sub) => formatDate(sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd, locale);
|
|
3246
|
-
const lifecycleActions = (sub, variantFor) => /* @__PURE__ */
|
|
3247
|
-
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(
|
|
3248
3479
|
Button,
|
|
3249
3480
|
{
|
|
3250
3481
|
variant: variantFor("secondary"),
|
|
3251
3482
|
loading: submitting,
|
|
3252
3483
|
elementKey: "subscriptionsPanel.pauseButton",
|
|
3253
|
-
onClick: (
|
|
3484
|
+
onClick: confirmThen(() => resource.pause(sub.id), {
|
|
3485
|
+
title: t.subscriptions.pauseConfirm,
|
|
3486
|
+
confirmLabel: t.subscriptions.pauseButton
|
|
3487
|
+
}),
|
|
3254
3488
|
children: t.subscriptions.pauseButton
|
|
3255
3489
|
}
|
|
3256
3490
|
) : null,
|
|
3257
|
-
CAN_RESUME.has(sub.status) ? /* @__PURE__ */
|
|
3491
|
+
CAN_RESUME.has(sub.status) ? /* @__PURE__ */ jsx42(
|
|
3258
3492
|
Button,
|
|
3259
3493
|
{
|
|
3260
3494
|
variant: variantFor("secondary"),
|
|
3261
3495
|
loading: submitting,
|
|
3262
3496
|
elementKey: "subscriptionsPanel.resumeButton",
|
|
3263
|
-
onClick: (
|
|
3497
|
+
onClick: confirmThen(() => resource.resume(sub.id), {
|
|
3498
|
+
title: t.subscriptions.resumeConfirm,
|
|
3499
|
+
confirmLabel: t.subscriptions.resumeButton
|
|
3500
|
+
}),
|
|
3264
3501
|
children: t.subscriptions.resumeButton
|
|
3265
3502
|
}
|
|
3266
3503
|
) : null,
|
|
3267
|
-
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3504
|
+
CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx42(
|
|
3268
3505
|
Button,
|
|
3269
3506
|
{
|
|
3270
3507
|
variant: variantFor("secondary"),
|
|
3271
3508
|
elementKey: "subscriptionsPanel.cancelButton",
|
|
3272
3509
|
disabled: submitting,
|
|
3273
|
-
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
|
+
}),
|
|
3274
3515
|
children: t.subscriptions.cancelAtPeriodEnd
|
|
3275
3516
|
}
|
|
3276
3517
|
) : null,
|
|
3277
|
-
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */
|
|
3518
|
+
CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ jsx42(
|
|
3278
3519
|
Button,
|
|
3279
3520
|
{
|
|
3280
3521
|
variant: variantFor("danger"),
|
|
3281
3522
|
elementKey: "subscriptionsPanel.cancelNowButton",
|
|
3282
3523
|
disabled: submitting,
|
|
3283
|
-
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
|
+
}),
|
|
3284
3529
|
children: t.subscriptions.cancelNow
|
|
3285
3530
|
}
|
|
3286
3531
|
) : null
|
|
3287
3532
|
] });
|
|
3288
|
-
return /* @__PURE__ */
|
|
3289
|
-
error ? /* @__PURE__ */
|
|
3290
|
-
/* @__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(
|
|
3291
3536
|
PanelState,
|
|
3292
3537
|
{
|
|
3293
3538
|
resource,
|
|
@@ -3296,7 +3541,7 @@ function SubscriptionsPanel(props) {
|
|
|
3296
3541
|
isEmpty: (rows) => rows.length === 0,
|
|
3297
3542
|
emptyTitle: t.subscriptions.empty,
|
|
3298
3543
|
emptyDescription: t.subscriptions.emptyDescription,
|
|
3299
|
-
children: (rows) => variant === "table" ? /* @__PURE__ */
|
|
3544
|
+
children: (rows) => variant === "table" ? /* @__PURE__ */ jsx42(
|
|
3300
3545
|
DataTable,
|
|
3301
3546
|
{
|
|
3302
3547
|
tableKey: "subscriptionsPanel.table",
|
|
@@ -3305,42 +3550,42 @@ function SubscriptionsPanel(props) {
|
|
|
3305
3550
|
rows,
|
|
3306
3551
|
columns: [
|
|
3307
3552
|
{ key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
|
|
3308
|
-
{ 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) }) },
|
|
3309
3554
|
{ key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
|
|
3310
|
-
{ key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */
|
|
3311
|
-
/* @__PURE__ */
|
|
3312
|
-
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
|
|
3313
3558
|
] }) },
|
|
3314
3559
|
{ key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
|
|
3315
3560
|
]
|
|
3316
3561
|
}
|
|
3317
|
-
) : /* @__PURE__ */
|
|
3318
|
-
/* @__PURE__ */
|
|
3319
|
-
/* @__PURE__ */
|
|
3320
|
-
/* @__PURE__ */
|
|
3321
|
-
/* @__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 })
|
|
3322
3567
|
] }),
|
|
3323
|
-
/* @__PURE__ */
|
|
3568
|
+
/* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3324
3569
|
formatMoney(sub.amount, sub.currency, locale),
|
|
3325
3570
|
" / ",
|
|
3326
3571
|
sub.interval,
|
|
3327
3572
|
sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
|
|
3328
3573
|
] }),
|
|
3329
|
-
sub.status === "cancelled" ? /* @__PURE__ */
|
|
3574
|
+
sub.status === "cancelled" ? /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3330
3575
|
t.subscriptions.cancelledOn,
|
|
3331
3576
|
" ",
|
|
3332
3577
|
formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
|
|
3333
|
-
] }) : /* @__PURE__ */
|
|
3578
|
+
] }) : /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3334
3579
|
sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
|
|
3335
3580
|
" ",
|
|
3336
3581
|
formatDate(sub.currentPeriodEnd, locale)
|
|
3337
3582
|
] }),
|
|
3338
|
-
sub.trialEnd ? /* @__PURE__ */
|
|
3583
|
+
sub.trialEnd ? /* @__PURE__ */ jsxs33("p", { className: "throttle-muted", children: [
|
|
3339
3584
|
t.subscriptions.trialEnds,
|
|
3340
3585
|
" ",
|
|
3341
3586
|
formatDate(sub.trialEnd, locale)
|
|
3342
3587
|
] }) : null,
|
|
3343
|
-
sub.cancelAtPeriodEnd ? /* @__PURE__ */
|
|
3588
|
+
sub.cancelAtPeriodEnd ? /* @__PURE__ */ jsx42(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
|
|
3344
3589
|
] }),
|
|
3345
3590
|
lifecycleActions(sub, actionVariant)
|
|
3346
3591
|
] }, sub.id)) })
|
|
@@ -3350,7 +3595,7 @@ function SubscriptionsPanel(props) {
|
|
|
3350
3595
|
}
|
|
3351
3596
|
|
|
3352
3597
|
// src/react/components/account/SecurityPanel.tsx
|
|
3353
|
-
import { useCallback as
|
|
3598
|
+
import { useCallback as useCallback3, useEffect as useEffect8, useRef as useRef8, useState as useState20 } from "react";
|
|
3354
3599
|
|
|
3355
3600
|
// src/react/components/account/device.ts
|
|
3356
3601
|
var BROWSERS = [
|
|
@@ -3383,7 +3628,7 @@ function describeDevice(userAgent) {
|
|
|
3383
3628
|
}
|
|
3384
3629
|
|
|
3385
3630
|
// src/react/components/account/SecurityPanel.tsx
|
|
3386
|
-
import { Fragment as Fragment9, jsx as
|
|
3631
|
+
import { Fragment as Fragment9, jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3387
3632
|
function SecurityPanel(props) {
|
|
3388
3633
|
const a = useAppearance(props.appearance);
|
|
3389
3634
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
@@ -3393,16 +3638,16 @@ function SecurityPanel(props) {
|
|
|
3393
3638
|
const rowsVariant = variant === "rows";
|
|
3394
3639
|
const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
|
|
3395
3640
|
const revokeVariant = rowsVariant ? "linkDanger" : "danger";
|
|
3396
|
-
const [password, setPassword] =
|
|
3641
|
+
const [password, setPassword] = useState20("");
|
|
3397
3642
|
const passwordAction = useAction();
|
|
3398
3643
|
const sessionAction = useAction();
|
|
3399
|
-
const [sessions, setSessions] =
|
|
3400
|
-
const [listError, setListError] =
|
|
3401
|
-
const errorMessageRef =
|
|
3644
|
+
const [sessions, setSessions] = useState20(null);
|
|
3645
|
+
const [listError, setListError] = useState20(null);
|
|
3646
|
+
const errorMessageRef = useRef8(errorMessage);
|
|
3402
3647
|
useEffect8(() => {
|
|
3403
3648
|
errorMessageRef.current = errorMessage;
|
|
3404
3649
|
});
|
|
3405
|
-
const load =
|
|
3650
|
+
const load = useCallback3(async () => {
|
|
3406
3651
|
try {
|
|
3407
3652
|
setSessions(await auth.listSessions());
|
|
3408
3653
|
setListError(null);
|
|
@@ -3414,8 +3659,8 @@ function SecurityPanel(props) {
|
|
|
3414
3659
|
void load();
|
|
3415
3660
|
}, [load]);
|
|
3416
3661
|
const others = (sessions ?? []).filter((s) => !s.current);
|
|
3417
|
-
return /* @__PURE__ */
|
|
3418
|
-
/* @__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(
|
|
3419
3664
|
"form",
|
|
3420
3665
|
{
|
|
3421
3666
|
...a.el("securityPanel.passwordForm", "throttle-stack"),
|
|
@@ -3428,8 +3673,8 @@ function SecurityPanel(props) {
|
|
|
3428
3673
|
});
|
|
3429
3674
|
},
|
|
3430
3675
|
children: [
|
|
3431
|
-
/* @__PURE__ */
|
|
3432
|
-
/* @__PURE__ */
|
|
3676
|
+
/* @__PURE__ */ jsx43("h3", { children: t.security.passwordTitle }),
|
|
3677
|
+
/* @__PURE__ */ jsx43(
|
|
3433
3678
|
Field,
|
|
3434
3679
|
{
|
|
3435
3680
|
label: t.security.newPassword,
|
|
@@ -3440,21 +3685,21 @@ function SecurityPanel(props) {
|
|
|
3440
3685
|
onChange: setPassword
|
|
3441
3686
|
}
|
|
3442
3687
|
),
|
|
3443
|
-
passwordAction.error ? /* @__PURE__ */
|
|
3444
|
-
passwordAction.notice ? /* @__PURE__ */
|
|
3445
|
-
/* @__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 })
|
|
3446
3691
|
]
|
|
3447
3692
|
}
|
|
3448
3693
|
),
|
|
3449
|
-
/* @__PURE__ */
|
|
3450
|
-
/* @__PURE__ */
|
|
3451
|
-
listError ? /* @__PURE__ */
|
|
3452
|
-
/* @__PURE__ */
|
|
3453
|
-
/* @__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 })
|
|
3454
3699
|
] }) : null,
|
|
3455
|
-
sessionAction.error ? /* @__PURE__ */
|
|
3456
|
-
sessions === null && !listError ? /* @__PURE__ */
|
|
3457
|
-
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(
|
|
3458
3703
|
DataTable,
|
|
3459
3704
|
{
|
|
3460
3705
|
tableKey: "securityPanel.table",
|
|
@@ -3462,12 +3707,12 @@ function SecurityPanel(props) {
|
|
|
3462
3707
|
rowKey: (session) => session.id,
|
|
3463
3708
|
rows: sessions,
|
|
3464
3709
|
columns: [
|
|
3465
|
-
{ key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */
|
|
3466
|
-
/* @__PURE__ */
|
|
3467
|
-
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
|
|
3468
3713
|
] }) },
|
|
3469
3714
|
{ key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
|
|
3470
|
-
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */
|
|
3715
|
+
{ key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ jsx43(
|
|
3471
3716
|
Button,
|
|
3472
3717
|
{
|
|
3473
3718
|
variant: "danger",
|
|
@@ -3482,19 +3727,19 @@ function SecurityPanel(props) {
|
|
|
3482
3727
|
) : null }
|
|
3483
3728
|
]
|
|
3484
3729
|
}
|
|
3485
|
-
) : (sessions ?? []).map((session) => /* @__PURE__ */
|
|
3486
|
-
/* @__PURE__ */
|
|
3487
|
-
/* @__PURE__ */
|
|
3488
|
-
/* @__PURE__ */
|
|
3489
|
-
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
|
|
3490
3735
|
] }),
|
|
3491
|
-
/* @__PURE__ */
|
|
3736
|
+
/* @__PURE__ */ jsxs34("p", { className: "throttle-muted", children: [
|
|
3492
3737
|
t.security.lastActive,
|
|
3493
3738
|
" ",
|
|
3494
3739
|
formatDate(session.lastUsedAt, locale)
|
|
3495
3740
|
] })
|
|
3496
3741
|
] }),
|
|
3497
|
-
!session.current ? /* @__PURE__ */
|
|
3742
|
+
!session.current ? /* @__PURE__ */ jsx43(
|
|
3498
3743
|
Button,
|
|
3499
3744
|
{
|
|
3500
3745
|
variant: revokeVariant,
|
|
@@ -3508,8 +3753,8 @@ function SecurityPanel(props) {
|
|
|
3508
3753
|
}
|
|
3509
3754
|
) : null
|
|
3510
3755
|
] }, session.id)),
|
|
3511
|
-
sessions !== null && others.length === 0 ? /* @__PURE__ */
|
|
3512
|
-
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(
|
|
3513
3758
|
Button,
|
|
3514
3759
|
{
|
|
3515
3760
|
variant: "danger",
|
|
@@ -3529,7 +3774,7 @@ function SecurityPanel(props) {
|
|
|
3529
3774
|
}
|
|
3530
3775
|
|
|
3531
3776
|
// src/react/components/account/AccountDashboard.tsx
|
|
3532
|
-
import { Fragment as Fragment10, jsx as
|
|
3777
|
+
import { Fragment as Fragment10, jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3533
3778
|
var ACCOUNT_TABS = [
|
|
3534
3779
|
"profile",
|
|
3535
3780
|
"addresses",
|
|
@@ -3558,8 +3803,8 @@ function AccountDashboard(props) {
|
|
|
3558
3803
|
const { status } = useAuth();
|
|
3559
3804
|
const shown = props.tabs ?? [...ACCOUNT_TABS];
|
|
3560
3805
|
const controlled = props.tab !== void 0;
|
|
3561
|
-
const [internal, setInternal] =
|
|
3562
|
-
const idBase =
|
|
3806
|
+
const [internal, setInternal] = useState21(shown[0] ?? "profile");
|
|
3807
|
+
const idBase = useId6();
|
|
3563
3808
|
useEffect9(() => {
|
|
3564
3809
|
if (props.routing !== "hash" || typeof window === "undefined") return;
|
|
3565
3810
|
const apply = () => {
|
|
@@ -3581,7 +3826,7 @@ function AccountDashboard(props) {
|
|
|
3581
3826
|
};
|
|
3582
3827
|
const shared = { appearance: props.appearance, localization: props.localization };
|
|
3583
3828
|
const sidebar = (props.layout ?? "sidebar") === "sidebar";
|
|
3584
|
-
const nav = /* @__PURE__ */
|
|
3829
|
+
const nav = /* @__PURE__ */ jsx44(
|
|
3585
3830
|
Tabs,
|
|
3586
3831
|
{
|
|
3587
3832
|
idBase,
|
|
@@ -3597,7 +3842,7 @@ function AccountDashboard(props) {
|
|
|
3597
3842
|
}))
|
|
3598
3843
|
}
|
|
3599
3844
|
);
|
|
3600
|
-
const panel = /* @__PURE__ */
|
|
3845
|
+
const panel = /* @__PURE__ */ jsxs35(
|
|
3601
3846
|
"div",
|
|
3602
3847
|
{
|
|
3603
3848
|
...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
|
|
@@ -3606,36 +3851,46 @@ function AccountDashboard(props) {
|
|
|
3606
3851
|
"aria-labelledby": `${idBase}-tab-${active}`,
|
|
3607
3852
|
tabIndex: 0,
|
|
3608
3853
|
children: [
|
|
3609
|
-
active === "profile" ? /* @__PURE__ */
|
|
3610
|
-
active === "addresses" ? /* @__PURE__ */
|
|
3611
|
-
active === "paymentMethods" ? /* @__PURE__ */
|
|
3612
|
-
active === "orders" ? /* @__PURE__ */
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
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
|
|
3616
3871
|
]
|
|
3617
3872
|
}
|
|
3618
3873
|
);
|
|
3619
|
-
return /* @__PURE__ */
|
|
3620
|
-
/* @__PURE__ */
|
|
3621
|
-
sidebar ? /* @__PURE__ */
|
|
3622
|
-
/* @__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 }),
|
|
3623
3878
|
panel
|
|
3624
|
-
] }) : /* @__PURE__ */
|
|
3625
|
-
/* @__PURE__ */
|
|
3879
|
+
] }) : /* @__PURE__ */ jsxs35(Fragment10, { children: [
|
|
3880
|
+
/* @__PURE__ */ jsx44("div", { ...a.el("accountDashboard.tabs"), children: nav }),
|
|
3626
3881
|
panel
|
|
3627
3882
|
] })
|
|
3628
3883
|
] }) }) });
|
|
3629
3884
|
}
|
|
3630
3885
|
|
|
3631
3886
|
// src/react/components/account/AccountModal.tsx
|
|
3632
|
-
import { jsx as
|
|
3887
|
+
import { jsx as jsx45, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
3633
3888
|
function AccountModal(props) {
|
|
3634
3889
|
const a = useAppearance(props.appearance);
|
|
3635
3890
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3636
3891
|
const { t } = useCopy(props.localization);
|
|
3637
|
-
const titleId =
|
|
3638
|
-
return /* @__PURE__ */
|
|
3892
|
+
const titleId = useId7();
|
|
3893
|
+
return /* @__PURE__ */ jsx45(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ jsxs36(
|
|
3639
3894
|
Modal,
|
|
3640
3895
|
{
|
|
3641
3896
|
open: props.open,
|
|
@@ -3645,15 +3900,15 @@ function AccountModal(props) {
|
|
|
3645
3900
|
overlayKey: "accountModal.overlay",
|
|
3646
3901
|
containerKey: "accountModal.container",
|
|
3647
3902
|
children: [
|
|
3648
|
-
/* @__PURE__ */
|
|
3649
|
-
/* @__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 }) })
|
|
3650
3905
|
]
|
|
3651
3906
|
}
|
|
3652
3907
|
) });
|
|
3653
3908
|
}
|
|
3654
3909
|
|
|
3655
3910
|
// src/react/components/provider.tsx
|
|
3656
|
-
import { jsx as
|
|
3911
|
+
import { jsx as jsx46, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
3657
3912
|
var warned = /* @__PURE__ */ new Set();
|
|
3658
3913
|
function warnOnce(key, message) {
|
|
3659
3914
|
if (process.env.NODE_ENV === "production") return;
|
|
@@ -3661,9 +3916,9 @@ function warnOnce(key, message) {
|
|
|
3661
3916
|
warned.add(key);
|
|
3662
3917
|
console.warn(`[@usethrottle/auth] ${message}`);
|
|
3663
3918
|
}
|
|
3664
|
-
var ThrottleUIContext =
|
|
3919
|
+
var ThrottleUIContext = createContext6(null);
|
|
3665
3920
|
function useThrottle() {
|
|
3666
|
-
const ctx =
|
|
3921
|
+
const ctx = useContext6(ThrottleUIContext);
|
|
3667
3922
|
if (!ctx) {
|
|
3668
3923
|
warnOnce(
|
|
3669
3924
|
"use-throttle-no-provider",
|
|
@@ -3698,51 +3953,51 @@ function ThrottleProvider(props) {
|
|
|
3698
3953
|
__captureStepUp
|
|
3699
3954
|
} = props;
|
|
3700
3955
|
useInjectStyles(injectStyles);
|
|
3701
|
-
const [stepUpOpen, setStepUpOpen] =
|
|
3702
|
-
const resolveStepUp =
|
|
3703
|
-
const claimRef =
|
|
3956
|
+
const [stepUpOpen, setStepUpOpen] = useState22(false);
|
|
3957
|
+
const resolveStepUp = useRef9(null);
|
|
3958
|
+
const claimRef = useRef9(claimCartOnSignIn);
|
|
3704
3959
|
claimRef.current = claimCartOnSignIn;
|
|
3705
|
-
const [overlay, setOverlay] =
|
|
3706
|
-
const overlayRestoreFocus =
|
|
3707
|
-
const [accountTabs, setAccountTabs] =
|
|
3708
|
-
const onOverlaySuccess =
|
|
3709
|
-
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) => {
|
|
3710
3965
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
3711
3966
|
setOverlay("signIn");
|
|
3712
3967
|
}, []);
|
|
3713
|
-
const openSignUp =
|
|
3968
|
+
const openSignUp = useCallback4((onSuccess) => {
|
|
3714
3969
|
onOverlaySuccess.current = onSuccess ?? null;
|
|
3715
3970
|
setOverlay("signUp");
|
|
3716
3971
|
}, []);
|
|
3717
|
-
const openAccount =
|
|
3972
|
+
const openAccount = useCallback4((opts) => {
|
|
3718
3973
|
onOverlaySuccess.current = null;
|
|
3719
3974
|
overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
|
|
3720
3975
|
setAccountTabs(opts?.tabs);
|
|
3721
3976
|
setOverlay("account");
|
|
3722
3977
|
}, []);
|
|
3723
|
-
const closeOverlay =
|
|
3978
|
+
const closeOverlay = useCallback4(() => {
|
|
3724
3979
|
onOverlaySuccess.current = null;
|
|
3725
3980
|
overlayRestoreFocus.current = null;
|
|
3726
3981
|
setOverlay(null);
|
|
3727
3982
|
}, []);
|
|
3728
|
-
const handleOverlaySuccess =
|
|
3983
|
+
const handleOverlaySuccess = useCallback4(() => {
|
|
3729
3984
|
const fn = onOverlaySuccess.current;
|
|
3730
3985
|
onOverlaySuccess.current = null;
|
|
3731
3986
|
setOverlay(null);
|
|
3732
3987
|
fn?.();
|
|
3733
3988
|
}, []);
|
|
3734
|
-
const ui =
|
|
3989
|
+
const ui = useMemo4(
|
|
3735
3990
|
() => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
|
|
3736
3991
|
[overlay, openSignIn, openSignUp, openAccount, closeOverlay]
|
|
3737
3992
|
);
|
|
3738
|
-
const askForStepUp =
|
|
3993
|
+
const askForStepUp = useCallback4(
|
|
3739
3994
|
() => new Promise((resolve) => {
|
|
3740
3995
|
resolveStepUp.current = resolve;
|
|
3741
3996
|
setStepUpOpen(true);
|
|
3742
3997
|
}),
|
|
3743
3998
|
[]
|
|
3744
3999
|
);
|
|
3745
|
-
const auth =
|
|
4000
|
+
const auth = useMemo4(() => {
|
|
3746
4001
|
__captureStepUp?.(askForStepUp);
|
|
3747
4002
|
const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
|
|
3748
4003
|
const account = createAccount(client);
|
|
@@ -3775,10 +4030,10 @@ function ThrottleProvider(props) {
|
|
|
3775
4030
|
resolve?.(password);
|
|
3776
4031
|
};
|
|
3777
4032
|
const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
|
|
3778
|
-
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: [
|
|
3779
4034
|
children,
|
|
3780
|
-
/* @__PURE__ */
|
|
3781
|
-
/* @__PURE__ */
|
|
4035
|
+
/* @__PURE__ */ jsx46(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
|
|
4036
|
+
/* @__PURE__ */ jsx46(
|
|
3782
4037
|
AuthModal,
|
|
3783
4038
|
{
|
|
3784
4039
|
open: authOverlayOpen,
|
|
@@ -3789,23 +4044,23 @@ function ThrottleProvider(props) {
|
|
|
3789
4044
|
},
|
|
3790
4045
|
overlay === "signUp" ? "signUp" : "signIn"
|
|
3791
4046
|
),
|
|
3792
|
-
/* @__PURE__ */
|
|
3793
|
-
] }) }) }) }) });
|
|
4047
|
+
/* @__PURE__ */ jsx46(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
|
|
4048
|
+
] }) }) }) }) }) });
|
|
3794
4049
|
}
|
|
3795
4050
|
|
|
3796
4051
|
// src/react/components/auth/SignInButton.tsx
|
|
3797
|
-
import { cloneElement, isValidElement, useContext as
|
|
3798
|
-
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";
|
|
3799
4054
|
function SignInButton(props) {
|
|
3800
4055
|
const a = useAppearance(props.appearance);
|
|
3801
4056
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3802
4057
|
const { t } = useCopy(props.localization);
|
|
3803
|
-
const ui =
|
|
3804
|
-
const [localOpen, setLocalOpen] =
|
|
4058
|
+
const ui = useContext7(ThrottleUIContext);
|
|
4059
|
+
const [localOpen, setLocalOpen] = useState23(false);
|
|
3805
4060
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3806
4061
|
const label = props.children ?? t.signIn.submitButton;
|
|
3807
4062
|
if (props.mode === "redirect") {
|
|
3808
|
-
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 }) }) });
|
|
3809
4064
|
}
|
|
3810
4065
|
const openModal = () => {
|
|
3811
4066
|
if (useShared) ui.openSignIn(props.afterSignIn);
|
|
@@ -3815,10 +4070,10 @@ function SignInButton(props) {
|
|
|
3815
4070
|
if (useShared) ui.close();
|
|
3816
4071
|
else setLocalOpen(false);
|
|
3817
4072
|
};
|
|
3818
|
-
const trigger = props.asChild && isValidElement(props.children) ? cloneElement(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3819
|
-
return /* @__PURE__ */
|
|
3820
|
-
/* @__PURE__ */
|
|
3821
|
-
!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(
|
|
3822
4077
|
AuthModal,
|
|
3823
4078
|
{
|
|
3824
4079
|
open: localOpen,
|
|
@@ -3836,18 +4091,18 @@ function SignInButton(props) {
|
|
|
3836
4091
|
}
|
|
3837
4092
|
|
|
3838
4093
|
// src/react/components/auth/SignUpButton.tsx
|
|
3839
|
-
import { cloneElement as cloneElement2, isValidElement as isValidElement2, useContext as
|
|
3840
|
-
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";
|
|
3841
4096
|
function SignUpButton(props) {
|
|
3842
4097
|
const a = useAppearance(props.appearance);
|
|
3843
4098
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3844
4099
|
const { t } = useCopy(props.localization);
|
|
3845
|
-
const ui =
|
|
3846
|
-
const [localOpen, setLocalOpen] =
|
|
4100
|
+
const ui = useContext8(ThrottleUIContext);
|
|
4101
|
+
const [localOpen, setLocalOpen] = useState24(false);
|
|
3847
4102
|
const useShared = ui !== null && props.initialView === void 0;
|
|
3848
4103
|
const label = props.children ?? t.signUp.submitButton;
|
|
3849
4104
|
if (props.mode === "redirect") {
|
|
3850
|
-
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 }) }) });
|
|
3851
4106
|
}
|
|
3852
4107
|
const openModal = () => {
|
|
3853
4108
|
if (useShared) ui.openSignUp(props.afterSignUp);
|
|
@@ -3857,10 +4112,10 @@ function SignUpButton(props) {
|
|
|
3857
4112
|
if (useShared) ui.close();
|
|
3858
4113
|
else setLocalOpen(false);
|
|
3859
4114
|
};
|
|
3860
|
-
const trigger = props.asChild && isValidElement2(props.children) ? cloneElement2(props.children, { onClick: openModal }) : /* @__PURE__ */
|
|
3861
|
-
return /* @__PURE__ */
|
|
3862
|
-
/* @__PURE__ */
|
|
3863
|
-
!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(
|
|
3864
4119
|
AuthModal,
|
|
3865
4120
|
{
|
|
3866
4121
|
open: localOpen,
|
|
@@ -3878,14 +4133,14 @@ function SignUpButton(props) {
|
|
|
3878
4133
|
}
|
|
3879
4134
|
|
|
3880
4135
|
// src/react/components/auth/SignOutButton.tsx
|
|
3881
|
-
import { jsx as
|
|
4136
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
3882
4137
|
function SignOutButton(props) {
|
|
3883
4138
|
const a = useAppearance();
|
|
3884
4139
|
const { auth } = useAuth();
|
|
3885
4140
|
const { t } = useCopy(props.localization);
|
|
3886
4141
|
const { submitting, run } = useAction();
|
|
3887
4142
|
const label = props.children ?? (props.everywhere ? t.userButton.signOutAll : t.userButton.signOut);
|
|
3888
|
-
return /* @__PURE__ */
|
|
4143
|
+
return /* @__PURE__ */ jsx49("span", { ...a.rootProps, children: /* @__PURE__ */ jsx49(
|
|
3889
4144
|
Button,
|
|
3890
4145
|
{
|
|
3891
4146
|
variant: "secondary",
|
|
@@ -3902,13 +4157,13 @@ function SignOutButton(props) {
|
|
|
3902
4157
|
}
|
|
3903
4158
|
|
|
3904
4159
|
// src/react/components/auth/SignInPage.tsx
|
|
3905
|
-
import { jsx as
|
|
4160
|
+
import { jsx as jsx50, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
3906
4161
|
function SignInPage(props) {
|
|
3907
4162
|
const a = useAppearance(props.appearance);
|
|
3908
4163
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3909
|
-
return /* @__PURE__ */
|
|
3910
|
-
props.logo ? /* @__PURE__ */
|
|
3911
|
-
/* @__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(
|
|
3912
4167
|
SignIn,
|
|
3913
4168
|
{
|
|
3914
4169
|
onSuccess: props.onSuccess,
|
|
@@ -3918,18 +4173,18 @@ function SignInPage(props) {
|
|
|
3918
4173
|
localization: props.localization
|
|
3919
4174
|
}
|
|
3920
4175
|
),
|
|
3921
|
-
props.footer ? /* @__PURE__ */
|
|
4176
|
+
props.footer ? /* @__PURE__ */ jsx50("div", { ...a.el("signInPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3922
4177
|
] }) }) });
|
|
3923
4178
|
}
|
|
3924
4179
|
|
|
3925
4180
|
// src/react/components/auth/SignUpPage.tsx
|
|
3926
|
-
import { jsx as
|
|
4181
|
+
import { jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
3927
4182
|
function SignUpPage(props) {
|
|
3928
4183
|
const a = useAppearance(props.appearance);
|
|
3929
4184
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3930
|
-
return /* @__PURE__ */
|
|
3931
|
-
props.logo ? /* @__PURE__ */
|
|
3932
|
-
/* @__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(
|
|
3933
4188
|
SignUp,
|
|
3934
4189
|
{
|
|
3935
4190
|
onSuccess: props.onSuccess,
|
|
@@ -3938,42 +4193,42 @@ function SignUpPage(props) {
|
|
|
3938
4193
|
localization: props.localization
|
|
3939
4194
|
}
|
|
3940
4195
|
),
|
|
3941
|
-
props.footer ? /* @__PURE__ */
|
|
4196
|
+
props.footer ? /* @__PURE__ */ jsx51("div", { ...a.el("signUpPage.footer", "throttle-page__footer"), children: props.footer }) : null
|
|
3942
4197
|
] }) }) });
|
|
3943
4198
|
}
|
|
3944
4199
|
|
|
3945
4200
|
// src/react/components/guards.tsx
|
|
3946
|
-
import { Fragment as Fragment11, jsx as
|
|
4201
|
+
import { Fragment as Fragment11, jsx as jsx52 } from "react/jsx-runtime";
|
|
3947
4202
|
function SignedIn(props) {
|
|
3948
4203
|
const { status } = useAuth();
|
|
3949
|
-
return status === "authenticated" ? /* @__PURE__ */
|
|
4204
|
+
return status === "authenticated" ? /* @__PURE__ */ jsx52(Fragment11, { children: props.children }) : null;
|
|
3950
4205
|
}
|
|
3951
4206
|
function SignedOut(props) {
|
|
3952
4207
|
const { status } = useAuth();
|
|
3953
|
-
return status === "unauthenticated" ? /* @__PURE__ */
|
|
4208
|
+
return status === "unauthenticated" ? /* @__PURE__ */ jsx52(Fragment11, { children: props.children }) : null;
|
|
3954
4209
|
}
|
|
3955
4210
|
function Protect(props) {
|
|
3956
4211
|
const { status, emailVerified } = useAuth();
|
|
3957
4212
|
if (status === "loading") return null;
|
|
3958
|
-
if (status !== "authenticated") return /* @__PURE__ */
|
|
3959
|
-
if (props.requireVerified && !emailVerified) return /* @__PURE__ */
|
|
3960
|
-
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 });
|
|
3961
4216
|
}
|
|
3962
4217
|
|
|
3963
4218
|
// src/react/components/UserButton.tsx
|
|
3964
|
-
import { useContext as
|
|
3965
|
-
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";
|
|
3966
4221
|
function UserButtonRoot(props) {
|
|
3967
4222
|
const a = useAppearance(props.appearance);
|
|
3968
4223
|
const scoped = useAppearanceProviderValue(props.appearance);
|
|
3969
4224
|
const { t } = useCopy(props.localization);
|
|
3970
4225
|
const { auth, status, customer, emailVerified } = useAuth();
|
|
3971
|
-
const ui =
|
|
3972
|
-
const [localOpen, setLocalOpen] =
|
|
4226
|
+
const ui = useContext9(ThrottleUIContext);
|
|
4227
|
+
const [localOpen, setLocalOpen] = useState25(false);
|
|
3973
4228
|
const accountOpen = ui ? false : localOpen;
|
|
3974
|
-
const titleId =
|
|
3975
|
-
const rootRef =
|
|
3976
|
-
const openerRef =
|
|
4229
|
+
const titleId = useId8();
|
|
4230
|
+
const rootRef = useRef10(null);
|
|
4231
|
+
const openerRef = useRef10(null);
|
|
3977
4232
|
const openAccount = () => {
|
|
3978
4233
|
const opener = rootRef.current?.querySelector('button[aria-haspopup="menu"]') ?? null;
|
|
3979
4234
|
openerRef.current = opener;
|
|
@@ -3982,25 +4237,25 @@ function UserButtonRoot(props) {
|
|
|
3982
4237
|
};
|
|
3983
4238
|
if (status !== "authenticated" || !customer) return null;
|
|
3984
4239
|
const name = [customer.firstName, customer.lastName].filter(Boolean).join(" ");
|
|
3985
|
-
return /* @__PURE__ */
|
|
3986
|
-
/* @__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(
|
|
3987
4242
|
Dropdown,
|
|
3988
4243
|
{
|
|
3989
4244
|
label: t.userButton.openMenu,
|
|
3990
4245
|
triggerKey: "userButton.trigger",
|
|
3991
4246
|
menuKey: "userButton.menu",
|
|
3992
|
-
trigger: /* @__PURE__ */
|
|
4247
|
+
trigger: /* @__PURE__ */ jsx53(Avatar, { name, email: customer.email }),
|
|
3993
4248
|
children: [
|
|
3994
|
-
/* @__PURE__ */
|
|
3995
|
-
/* @__PURE__ */
|
|
3996
|
-
/* @__PURE__ */
|
|
3997
|
-
/* @__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 })
|
|
3998
4253
|
] }) }),
|
|
3999
|
-
/* @__PURE__ */
|
|
4000
|
-
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 }),
|
|
4001
4256
|
props.children,
|
|
4002
|
-
/* @__PURE__ */
|
|
4003
|
-
/* @__PURE__ */
|
|
4257
|
+
/* @__PURE__ */ jsx53(DropdownSeparator, {}),
|
|
4258
|
+
/* @__PURE__ */ jsx53(
|
|
4004
4259
|
DropdownItem,
|
|
4005
4260
|
{
|
|
4006
4261
|
itemKey: "userButton.signOutButton",
|
|
@@ -4008,7 +4263,7 @@ function UserButtonRoot(props) {
|
|
|
4008
4263
|
children: t.userButton.signOut
|
|
4009
4264
|
}
|
|
4010
4265
|
),
|
|
4011
|
-
/* @__PURE__ */
|
|
4266
|
+
/* @__PURE__ */ jsx53(
|
|
4012
4267
|
DropdownItem,
|
|
4013
4268
|
{
|
|
4014
4269
|
itemKey: "userButton.signOutAllButton",
|
|
@@ -4019,7 +4274,7 @@ function UserButtonRoot(props) {
|
|
|
4019
4274
|
]
|
|
4020
4275
|
}
|
|
4021
4276
|
),
|
|
4022
|
-
props.mode !== "navigate" && !ui ? /* @__PURE__ */
|
|
4277
|
+
props.mode !== "navigate" && !ui ? /* @__PURE__ */ jsxs42(
|
|
4023
4278
|
Modal,
|
|
4024
4279
|
{
|
|
4025
4280
|
open: accountOpen,
|
|
@@ -4027,8 +4282,8 @@ function UserButtonRoot(props) {
|
|
|
4027
4282
|
labelledBy: titleId,
|
|
4028
4283
|
restoreFocusTo: openerRef.current,
|
|
4029
4284
|
children: [
|
|
4030
|
-
/* @__PURE__ */
|
|
4031
|
-
/* @__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(
|
|
4032
4287
|
AccountDashboard,
|
|
4033
4288
|
{
|
|
4034
4289
|
tabs: props.tabs,
|
|
@@ -4042,13 +4297,13 @@ function UserButtonRoot(props) {
|
|
|
4042
4297
|
] }) }) });
|
|
4043
4298
|
}
|
|
4044
4299
|
function UserButtonLink(props) {
|
|
4045
|
-
return /* @__PURE__ */
|
|
4300
|
+
return /* @__PURE__ */ jsxs42(DropdownItem, { itemKey: "userButton.item", href: props.href, children: [
|
|
4046
4301
|
props.icon,
|
|
4047
4302
|
props.label
|
|
4048
4303
|
] });
|
|
4049
4304
|
}
|
|
4050
4305
|
function UserButtonAction(props) {
|
|
4051
|
-
return /* @__PURE__ */
|
|
4306
|
+
return /* @__PURE__ */ jsxs42(DropdownItem, { itemKey: "userButton.item", onClick: props.onClick, children: [
|
|
4052
4307
|
props.icon,
|
|
4053
4308
|
props.label
|
|
4054
4309
|
] });
|