@atlasauth/react 0.1.18 → 0.1.19
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/AtlasProvider.d.ts +9 -0
- package/dist/AtlasProvider.js +2 -0
- package/dist/AtlasProvider.js.map +1 -1
- package/dist/account.d.ts +66 -0
- package/dist/account.js +223 -0
- package/dist/account.js.map +1 -0
- package/dist/auth-buttons.d.ts +29 -0
- package/dist/auth-buttons.js +43 -0
- package/dist/auth-buttons.js.map +1 -0
- package/dist/billing.d.ts +127 -0
- package/dist/billing.js +235 -0
- package/dist/billing.js.map +1 -0
- package/dist/components-shared.d.ts +22 -0
- package/dist/components-shared.js +70 -0
- package/dist/components-shared.js.map +1 -0
- package/dist/components.d.ts +29 -433
- package/dist/components.js +68 -1223
- package/dist/components.js.map +1 -1
- package/dist/control-components.d.ts +46 -0
- package/dist/control-components.js +69 -0
- package/dist/control-components.js.map +1 -0
- package/dist/flow.d.ts +81 -0
- package/dist/flow.js +319 -0
- package/dist/flow.js.map +1 -0
- package/dist/organization.d.ts +37 -0
- package/dist/organization.js +111 -0
- package/dist/organization.js.map +1 -0
- package/dist/reverification.d.ts +21 -0
- package/dist/reverification.js +74 -0
- package/dist/reverification.js.map +1 -0
- package/dist/sign-in.d.ts +42 -0
- package/dist/sign-in.js +91 -0
- package/dist/sign-in.js.map +1 -0
- package/dist/sign-up.d.ts +18 -0
- package/dist/sign-up.js +37 -0
- package/dist/sign-up.js.map +1 -0
- package/dist/user-button.d.ts +54 -0
- package/dist/user-button.js +75 -0
- package/dist/user-button.js.map +1 -0
- package/dist/waitlist.d.ts +15 -0
- package/dist/waitlist.js +52 -0
- package/dist/waitlist.js.map +1 -0
- package/package.json +2 -2
package/dist/billing.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBilling = useBilling;
|
|
4
|
+
exports.useCheckout = useCheckout;
|
|
5
|
+
exports.useSubscription = useSubscription;
|
|
6
|
+
exports.useInvoices = useInvoices;
|
|
7
|
+
exports.usePaymentMethods = usePaymentMethods;
|
|
8
|
+
exports.PricingTable = PricingTable;
|
|
9
|
+
exports.Invoices = Invoices;
|
|
10
|
+
exports.EmbeddedCheckout = EmbeddedCheckout;
|
|
11
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const AtlasProvider_1 = require("./AtlasProvider");
|
|
14
|
+
const components_shared_1 = require("./components-shared");
|
|
15
|
+
/**
|
|
16
|
+
* §commerce headless billing (Clerk `useCheckout`/subscription hooks combined).
|
|
17
|
+
* Loads the instance's plans and — when signed in — the subject's subscription,
|
|
18
|
+
* and exposes `checkout()` and `openPortal()`. Pass `{ orgId }` to operate on an
|
|
19
|
+
* organization the user administers instead of on the user.
|
|
20
|
+
*/
|
|
21
|
+
function useBilling(opts = {}) {
|
|
22
|
+
const { status } = (0, AtlasProvider_1.useAtlas)();
|
|
23
|
+
const client = (0, components_shared_1.useMeClient)();
|
|
24
|
+
const orgId = opts.orgId;
|
|
25
|
+
const [plans, setPlans] = (0, react_1.useState)([]);
|
|
26
|
+
const [subscription, setSubscription] = (0, react_1.useState)(null);
|
|
27
|
+
const [invoices, setInvoices] = (0, react_1.useState)([]);
|
|
28
|
+
const [paymentMethod, setPaymentMethod] = (0, react_1.useState)(null);
|
|
29
|
+
const [isLoaded, setIsLoaded] = (0, react_1.useState)(false);
|
|
30
|
+
const reload = (0, react_1.useCallback)(async () => {
|
|
31
|
+
const orgQuery = orgId ? `?org_id=${encodeURIComponent(orgId)}` : '';
|
|
32
|
+
const plansRes = await client.get('/v1/client/billing/plans');
|
|
33
|
+
if (plansRes.ok && plansRes.data)
|
|
34
|
+
setPlans(plansRes.data.data ?? []);
|
|
35
|
+
// Subscription, invoices and payment method are subject-scoped — signed in only.
|
|
36
|
+
if (status === 'signed_in') {
|
|
37
|
+
const [subRes, invRes, pmRes] = await Promise.all([
|
|
38
|
+
client.get(`/v1/client/billing/subscription${orgQuery}`),
|
|
39
|
+
client.get(`/v1/client/billing/invoices${orgQuery}`),
|
|
40
|
+
client.get(`/v1/client/billing/payment_method${orgQuery}`),
|
|
41
|
+
]);
|
|
42
|
+
if (subRes.ok)
|
|
43
|
+
setSubscription(subRes.data ?? null);
|
|
44
|
+
if (invRes.ok && invRes.data)
|
|
45
|
+
setInvoices(invRes.data.data ?? []);
|
|
46
|
+
if (pmRes.ok)
|
|
47
|
+
setPaymentMethod(pmRes.data?.payment_method ?? null);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setSubscription(null);
|
|
51
|
+
setInvoices([]);
|
|
52
|
+
setPaymentMethod(null);
|
|
53
|
+
}
|
|
54
|
+
setIsLoaded(true);
|
|
55
|
+
}, [client, status, orgId]);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
void reload();
|
|
58
|
+
}, [reload]);
|
|
59
|
+
const checkout = (0, react_1.useCallback)(async (params) => {
|
|
60
|
+
const res = await client.post('/v1/client/billing/checkout', {
|
|
61
|
+
plan_id: params.planId,
|
|
62
|
+
org_id: params.orgId ?? orgId,
|
|
63
|
+
success_url: params.successUrl ?? (0, components_shared_1.currentUrl)(),
|
|
64
|
+
cancel_url: params.cancelUrl ?? (0, components_shared_1.currentUrl)(),
|
|
65
|
+
});
|
|
66
|
+
if (res.ok && res.data?.url && params.redirect !== false)
|
|
67
|
+
(0, components_shared_1.navigateTo)(res.data.url);
|
|
68
|
+
return res;
|
|
69
|
+
}, [client, orgId]);
|
|
70
|
+
const openPortal = (0, react_1.useCallback)(async (params = {}) => {
|
|
71
|
+
const res = await client.post('/v1/client/billing/portal', {
|
|
72
|
+
org_id: params.orgId ?? orgId,
|
|
73
|
+
return_url: params.returnUrl ?? (0, components_shared_1.currentUrl)(),
|
|
74
|
+
});
|
|
75
|
+
if (res.ok && res.data?.url && params.redirect !== false)
|
|
76
|
+
(0, components_shared_1.navigateTo)(res.data.url);
|
|
77
|
+
return res;
|
|
78
|
+
}, [client, orgId]);
|
|
79
|
+
return { isLoaded, plans, subscription, invoices, paymentMethod, checkout, openPortal, reload };
|
|
80
|
+
}
|
|
81
|
+
/** §commerce Clerk-parity alias — just the `checkout` action from {@link useBilling}. */
|
|
82
|
+
function useCheckout(opts = {}) {
|
|
83
|
+
const { checkout } = useBilling(opts);
|
|
84
|
+
return { checkout };
|
|
85
|
+
}
|
|
86
|
+
/** §commerce Clerk-parity alias — the subject's subscription from {@link useBilling}. */
|
|
87
|
+
function useSubscription(opts = {}) {
|
|
88
|
+
const { isLoaded, subscription, openPortal, reload } = useBilling(opts);
|
|
89
|
+
return { isLoaded, subscription, openPortal, reload };
|
|
90
|
+
}
|
|
91
|
+
/** §commerce Clerk-parity alias — the subject's invoices from {@link useBilling}. */
|
|
92
|
+
function useInvoices(opts = {}) {
|
|
93
|
+
const { isLoaded, invoices, reload } = useBilling(opts);
|
|
94
|
+
return { isLoaded, invoices, reload };
|
|
95
|
+
}
|
|
96
|
+
/** §commerce Clerk-parity alias — the subject's default payment method + Portal to change it. */
|
|
97
|
+
function usePaymentMethods(opts = {}) {
|
|
98
|
+
const { isLoaded, paymentMethod, openPortal, reload } = useBilling(opts);
|
|
99
|
+
return { isLoaded, paymentMethod, openPortal, reload };
|
|
100
|
+
}
|
|
101
|
+
/** Format a minor-unit amount (cents) as a currency string, best-effort. */
|
|
102
|
+
function formatPrice(amount, currency) {
|
|
103
|
+
try {
|
|
104
|
+
return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(amount / 100);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return `${(amount / 100).toFixed(2)} ${currency.toUpperCase()}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* §commerce (Clerk `<PricingTable>`). Renders the instance's plans as cards with
|
|
112
|
+
* price + features and a subscribe button that starts a real Stripe Checkout.
|
|
113
|
+
* The plan the subject is currently on is marked as current (its button is
|
|
114
|
+
* disabled and an "Manage billing" action opens the Billing Portal instead).
|
|
115
|
+
*/
|
|
116
|
+
function PricingTable({ orgId } = {}) {
|
|
117
|
+
const { isLoaded, plans, subscription, checkout, openPortal } = useBilling({ orgId });
|
|
118
|
+
const { status } = (0, AtlasProvider_1.useAtlas)();
|
|
119
|
+
const t = (0, components_shared_1.useText)();
|
|
120
|
+
const cardClass = (0, components_shared_1.useClass)('card', 'atlas-card');
|
|
121
|
+
const buttonClass = (0, components_shared_1.useClass)('formButtonPrimary', 'atlas-button');
|
|
122
|
+
const [busyPlan, setBusyPlan] = (0, react_1.useState)(null);
|
|
123
|
+
const currentPlanId = subscription?.plan?.id ?? null;
|
|
124
|
+
if (!isLoaded)
|
|
125
|
+
return (0, jsx_runtime_1.jsx)("div", { "data-atlas": "pricing-table", "aria-busy": "true" });
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "atlas-pricing-table", "data-atlas": "pricing-table", children: plans.map((plan) => {
|
|
127
|
+
const isCurrent = plan.id === currentPlanId;
|
|
128
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: cardClass, "data-atlas": "pricing-plan", "data-current": isCurrent, children: [(0, jsx_runtime_1.jsx)("h3", { children: plan.name }), (0, jsx_runtime_1.jsxs)("p", { className: "atlas-price", children: [formatPrice(plan.amount, plan.currency), (0, jsx_runtime_1.jsxs)("span", { className: "atlas-interval", children: [" / ", plan.interval] })] }), plan.features.length ? ((0, jsx_runtime_1.jsx)("ul", { children: plan.features.map((f, i) => ((0, jsx_runtime_1.jsx)("li", { children: f }, i))) })) : null, isCurrent ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: buttonClass, "data-atlas": "manage-billing", onClick: () => void openPortal(), children: t('commerce.manage') })) : ((0, jsx_runtime_1.jsx)("button", { type: "button", className: buttonClass, disabled: status !== 'signed_in' || busyPlan === plan.id, onClick: () => {
|
|
129
|
+
setBusyPlan(plan.id);
|
|
130
|
+
void checkout({ planId: plan.id }).finally(() => setBusyPlan(null));
|
|
131
|
+
}, children: t('commerce.subscribe') }))] }, plan.id));
|
|
132
|
+
}) }));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* §commerce (Clerk `<Invoices>`). The subject's billing history — number, status,
|
|
136
|
+
* amount, and a link to Stripe's hosted invoice / PDF. Renders nothing until
|
|
137
|
+
* loaded, and an empty state when there are no invoices yet.
|
|
138
|
+
*/
|
|
139
|
+
function Invoices({ orgId } = {}) {
|
|
140
|
+
const { isLoaded, invoices } = useInvoices({ orgId });
|
|
141
|
+
const t = (0, components_shared_1.useText)();
|
|
142
|
+
const cardClass = (0, components_shared_1.useClass)('card', 'atlas-card');
|
|
143
|
+
if (!isLoaded)
|
|
144
|
+
return (0, jsx_runtime_1.jsx)("div", { "data-atlas": "invoices", "aria-busy": "true" });
|
|
145
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: cardClass, "data-atlas": "invoices", children: [(0, jsx_runtime_1.jsx)("h3", { children: t('commerce.invoices') }), invoices.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { "data-atlas": "invoices-empty", children: t('commerce.noInvoices') })) : ((0, jsx_runtime_1.jsx)("ul", { children: invoices.map((inv) => ((0, jsx_runtime_1.jsxs)("li", { "data-atlas": "invoice", "data-status": inv.status, children: [(0, jsx_runtime_1.jsx)("span", { children: inv.number ?? inv.id }), ' ', (0, jsx_runtime_1.jsx)("span", { children: formatPrice(inv.amount_paid || inv.amount_due, inv.currency) }), ' ', (0, jsx_runtime_1.jsx)("span", { children: inv.status }), ' ', inv.hosted_invoice_url ? ((0, jsx_runtime_1.jsx)("a", { href: inv.hosted_invoice_url, target: "_blank", rel: "noreferrer", children: t('commerce.viewInvoice') })) : null] }, inv.id))) }))] }));
|
|
146
|
+
}
|
|
147
|
+
/** Lazily inject Stripe.js once and resolve the global `Stripe` factory. */
|
|
148
|
+
let stripeJsPromise = null;
|
|
149
|
+
function loadStripeJs() {
|
|
150
|
+
if (typeof window === 'undefined')
|
|
151
|
+
return Promise.resolve(null);
|
|
152
|
+
const w = window;
|
|
153
|
+
if (w.Stripe)
|
|
154
|
+
return Promise.resolve(w.Stripe);
|
|
155
|
+
if (stripeJsPromise)
|
|
156
|
+
return stripeJsPromise;
|
|
157
|
+
stripeJsPromise = new Promise((resolve, reject) => {
|
|
158
|
+
const script = document.createElement('script');
|
|
159
|
+
script.src = 'https://js.stripe.com/v3';
|
|
160
|
+
script.async = true;
|
|
161
|
+
script.onload = () => resolve(window.Stripe ?? null);
|
|
162
|
+
script.onerror = () => reject(new Error('Failed to load Stripe.js'));
|
|
163
|
+
document.head.appendChild(script);
|
|
164
|
+
});
|
|
165
|
+
return stripeJsPromise;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* §commerce (Clerk `<EmbeddedCheckout>`). In-page checkout for a plan: mounts
|
|
169
|
+
* Stripe's own Embedded Checkout iframe — Stripe.js owns the card fields, so no
|
|
170
|
+
* PCI-scoped data ever touches Atlas. Fetches the instance's Stripe publishable
|
|
171
|
+
* key from `/billing/config`; when embedded checkout is not configured it renders
|
|
172
|
+
* `fallback` (default: a hosted-redirect button) rather than a broken frame.
|
|
173
|
+
*/
|
|
174
|
+
function EmbeddedCheckout({ planId, orgId, returnUrl, fallback, }) {
|
|
175
|
+
const client = (0, components_shared_1.useMeClient)();
|
|
176
|
+
const { checkout } = useBilling({ orgId });
|
|
177
|
+
const t = (0, components_shared_1.useText)();
|
|
178
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
179
|
+
const [unavailable, setUnavailable] = (0, react_1.useState)(false);
|
|
180
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
181
|
+
(0, react_1.useEffect)(() => {
|
|
182
|
+
let cancelled = false;
|
|
183
|
+
let embedded = null;
|
|
184
|
+
void (async () => {
|
|
185
|
+
// 1) Is embedded checkout configured on this instance?
|
|
186
|
+
const cfg = await client.get('/v1/client/billing/config');
|
|
187
|
+
const pk = cfg.ok ? cfg.data?.stripe_publishable_key : null;
|
|
188
|
+
if (!pk) {
|
|
189
|
+
if (!cancelled)
|
|
190
|
+
setUnavailable(true);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// 2) Create an embedded Checkout Session → client_secret.
|
|
194
|
+
const res = await client.post('/v1/client/billing/checkout', {
|
|
195
|
+
plan_id: planId,
|
|
196
|
+
org_id: orgId,
|
|
197
|
+
ui_mode: 'embedded',
|
|
198
|
+
return_url: returnUrl ?? (0, components_shared_1.currentUrl)(),
|
|
199
|
+
});
|
|
200
|
+
if (!res.ok || !res.data?.client_secret) {
|
|
201
|
+
if (!cancelled)
|
|
202
|
+
setError(res.errors[0]?.message ?? t('error.generic'));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// 3) Mount Stripe's Embedded Checkout.
|
|
206
|
+
const factory = (await loadStripeJs());
|
|
207
|
+
if (!factory || cancelled)
|
|
208
|
+
return;
|
|
209
|
+
const stripe = factory(pk);
|
|
210
|
+
const instance = await stripe.initEmbeddedCheckout({ clientSecret: res.data.client_secret });
|
|
211
|
+
if (cancelled) {
|
|
212
|
+
instance.destroy();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
embedded = instance;
|
|
216
|
+
if (containerRef.current)
|
|
217
|
+
instance.mount(containerRef.current);
|
|
218
|
+
})();
|
|
219
|
+
return () => {
|
|
220
|
+
cancelled = true;
|
|
221
|
+
try {
|
|
222
|
+
embedded?.destroy();
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
/* already gone */
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
// planId/orgId/returnUrl identify the session to create; client is stable.
|
|
229
|
+
}, [client, planId, orgId, returnUrl, t]);
|
|
230
|
+
if (unavailable) {
|
|
231
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fallback ?? ((0, jsx_runtime_1.jsx)("button", { type: "button", "data-atlas": "checkout-fallback", onClick: () => void checkout({ planId, orgId }), children: t('commerce.subscribe') })) }));
|
|
232
|
+
}
|
|
233
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-atlas": "embedded-checkout", children: [error ? (0, jsx_runtime_1.jsx)("p", { role: "alert", children: error }) : null, (0, jsx_runtime_1.jsx)("div", { ref: containerRef })] }));
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../src/billing.tsx"],"names":[],"mappings":";;AAsCA,gCAoEC;AAGD,kCAGC;AAGD,0CAGC;AAGD,kCAGC;AAGD,8CAGC;AAiBD,oCA0DC;AAOD,4BA8BC;AA2BD,4CAoGC;;AAjXD,iCAAiF;AACjF,mDAA2C;AAC3C,2DAA6F;AA8B7F;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAA2B,EAAE;IACtD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,wBAAQ,GAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAA,+BAAW,GAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAEzB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAkC,IAAI,CAAC,CAAC;IACxF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAwB,EAAE,CAAC,CAAC;IACpE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAA4B,IAAI,CAAC,CAAC;IACpF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACpC,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AAoB,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;YAC7F,IAAI,SAAS,EAAE,CAAC;gBACd,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YACD,QAAQ,GAAG,QAAQ,CAAC;YACpB,IAAI,YAAY,CAAC,OAAO;gBAAE,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACjE,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC;gBACH,QAAQ,EAAE,OAAO,EAAE,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACP,kBAAkB;YACpB,CAAC;QACH,CAAC,CAAC;QACF,2EAA2E;IAC7E,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CACL,2DACG,QAAQ,IAAI,CACX,mCACE,IAAI,EAAC,QAAQ,gBACF,mBAAmB,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,YAE9C,CAAC,CAAC,oBAAoB,CAAC,GACjB,CACV,GACA,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,CACL,+CAAgB,mBAAmB,aAChC,KAAK,CAAC,CAAC,CAAC,8BAAG,IAAI,EAAC,OAAO,YAAE,KAAK,GAAK,CAAC,CAAC,CAAC,IAAI,EAC3C,gCAAK,GAAG,EAAE,YAAY,GAAI,IACtB,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { FapiClient } from './fapi';
|
|
3
|
+
import { classFor } from './appearance';
|
|
4
|
+
/**
|
|
5
|
+
* Internal helpers shared by more than one component in the @atlasauth/react
|
|
6
|
+
* library. Nothing here is part of the package's public API — the public
|
|
7
|
+
* components live in their own sibling files and re-export through
|
|
8
|
+
* `components.tsx`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useClass(appearanceKey: Parameters<typeof classFor>[0], base: string): string;
|
|
11
|
+
export declare function useText(): (key: string, vars?: Record<string, string>) => string;
|
|
12
|
+
/** §2 A FapiClient bound to this instance, for the `/v1/client/me` + session
|
|
13
|
+
* account-management calls (all cookie-authenticated, credentials:'include'). */
|
|
14
|
+
export declare function useMeClient(): FapiClient;
|
|
15
|
+
/** Navigate the whole document. Guarded for SSR; `replace` for redirect helpers. */
|
|
16
|
+
export declare function navigateTo(url: string, replace?: boolean): void;
|
|
17
|
+
/** Append `?redirect_url=` (where to land after auth), preserving any existing query. */
|
|
18
|
+
export declare function withRedirect(url: string, redirectUrl?: string): string;
|
|
19
|
+
/** The current page URL, guarded for SSR. */
|
|
20
|
+
export declare function currentUrl(): string | undefined;
|
|
21
|
+
/** Walk a children tree and collect the extension descriptors matching `types`. */
|
|
22
|
+
export declare function collectByType<T>(children: ReactNode, match: (el: ReactElement) => T | undefined, out?: T[]): T[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useClass = useClass;
|
|
4
|
+
exports.useText = useText;
|
|
5
|
+
exports.useMeClient = useMeClient;
|
|
6
|
+
exports.navigateTo = navigateTo;
|
|
7
|
+
exports.withRedirect = withRedirect;
|
|
8
|
+
exports.currentUrl = currentUrl;
|
|
9
|
+
exports.collectByType = collectByType;
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const AtlasProvider_1 = require("./AtlasProvider");
|
|
12
|
+
const fapi_1 = require("./fapi");
|
|
13
|
+
const appearance_1 = require("./appearance");
|
|
14
|
+
const i18n_1 = require("./i18n");
|
|
15
|
+
/**
|
|
16
|
+
* Internal helpers shared by more than one component in the @atlasauth/react
|
|
17
|
+
* library. Nothing here is part of the package's public API — the public
|
|
18
|
+
* components live in their own sibling files and re-export through
|
|
19
|
+
* `components.tsx`.
|
|
20
|
+
*/
|
|
21
|
+
function useClass(appearanceKey, base) {
|
|
22
|
+
const { appearance } = (0, AtlasProvider_1.useAtlas)();
|
|
23
|
+
return (0, appearance_1.classFor)(appearanceKey, appearance, base);
|
|
24
|
+
}
|
|
25
|
+
function useText() {
|
|
26
|
+
const { catalog } = (0, AtlasProvider_1.useAtlas)();
|
|
27
|
+
return (key, vars) => (0, i18n_1.translate)(catalog, key, vars);
|
|
28
|
+
}
|
|
29
|
+
/** §2 A FapiClient bound to this instance, for the `/v1/client/me` + session
|
|
30
|
+
* account-management calls (all cookie-authenticated, credentials:'include'). */
|
|
31
|
+
function useMeClient() {
|
|
32
|
+
const { publishableKey, frontendApi } = (0, AtlasProvider_1.useAtlas)();
|
|
33
|
+
return (0, react_1.useMemo)(() => new fapi_1.FapiClient({ publishableKey, baseUrl: frontendApi }), [publishableKey, frontendApi]);
|
|
34
|
+
}
|
|
35
|
+
/** Navigate the whole document. Guarded for SSR; `replace` for redirect helpers. */
|
|
36
|
+
function navigateTo(url, replace = false) {
|
|
37
|
+
if (typeof window === 'undefined')
|
|
38
|
+
return;
|
|
39
|
+
if (replace)
|
|
40
|
+
window.location.replace(url);
|
|
41
|
+
else
|
|
42
|
+
window.location.assign(url);
|
|
43
|
+
}
|
|
44
|
+
/** Append `?redirect_url=` (where to land after auth), preserving any existing query. */
|
|
45
|
+
function withRedirect(url, redirectUrl) {
|
|
46
|
+
if (!redirectUrl)
|
|
47
|
+
return url;
|
|
48
|
+
const sep = url.includes('?') ? '&' : '?';
|
|
49
|
+
return `${url}${sep}redirect_url=${encodeURIComponent(redirectUrl)}`;
|
|
50
|
+
}
|
|
51
|
+
/** The current page URL, guarded for SSR. */
|
|
52
|
+
function currentUrl() {
|
|
53
|
+
return typeof window === 'undefined' ? undefined : window.location.href;
|
|
54
|
+
}
|
|
55
|
+
/** Walk a children tree and collect the extension descriptors matching `types`. */
|
|
56
|
+
function collectByType(children, match, out = []) {
|
|
57
|
+
react_1.Children.forEach(children, (child) => {
|
|
58
|
+
if (!(0, react_1.isValidElement)(child))
|
|
59
|
+
return;
|
|
60
|
+
const hit = match(child);
|
|
61
|
+
if (hit)
|
|
62
|
+
out.push(hit);
|
|
63
|
+
// Descend so `<Action>` inside `<MenuItems>` (or any wrapper) is still found.
|
|
64
|
+
const nested = child.props?.children;
|
|
65
|
+
if (nested)
|
|
66
|
+
collectByType(nested, match, out);
|
|
67
|
+
});
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=components-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-shared.js","sourceRoot":"","sources":["../src/components-shared.tsx"],"names":[],"mappings":";;AAaA,4BAGC;AAED,0BAGC;AAID,kCAMC;AAGD,gCAIC;AAGD,oCAIC;AAGD,gCAEC;AAGD,sCAcC;AAnED,iCAA6F;AAC7F,mDAA2C;AAC3C,iCAAoC;AACpC,6CAAwC;AACxC,iCAAmC;AAEnC;;;;;GAKG;AAEH,SAAgB,QAAQ,CAAC,aAA6C,EAAE,IAAY;IAClF,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,wBAAQ,GAAE,CAAC;IAClC,OAAO,IAAA,qBAAQ,EAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,SAAgB,OAAO;IACrB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,wBAAQ,GAAE,CAAC;IAC/B,OAAO,CAAC,GAAW,EAAE,IAA6B,EAAE,EAAE,CAAC,IAAA,gBAAS,EAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACvF,CAAC;AAED;kFACkF;AAClF,SAAgB,WAAW;IACzB,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,IAAA,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