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