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