@busiverse/ui 0.2.21 → 0.2.22
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.
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
2
|
+
export interface PageErrorBoundaryProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/** Where a person is pointed when a fault keeps coming back. */
|
|
5
|
+
supportEmail?: string;
|
|
6
|
+
/** Where "start over" lands once what this browser kept has been cleared. */
|
|
7
|
+
startOverPath?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PageErrorBoundaryState {
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What a console shows when a page fails while drawing, instead of an empty screen.
|
|
14
|
+
*
|
|
15
|
+
* A render fault unmounts everything beneath the nearest boundary, and with none the person is left
|
|
16
|
+
* with the page background and no idea what happened. This says the page stopped, shows the fault's
|
|
17
|
+
* name and message for support (code, never data), and offers a reload or a fresh start. Starting
|
|
18
|
+
* over clears this tab's session storage, which is where the sign-in is kept, so a fault that
|
|
19
|
+
* follows the page through a reload cannot hold anyone in a loop.
|
|
20
|
+
*/
|
|
21
|
+
export declare class PageErrorBoundary extends Component<PageErrorBoundaryProps, PageErrorBoundaryState> {
|
|
22
|
+
state: PageErrorBoundaryState;
|
|
23
|
+
static getDerivedStateFromError(error: Error): PageErrorBoundaryState;
|
|
24
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
25
|
+
private reload;
|
|
26
|
+
private startOver;
|
|
27
|
+
render(): ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=ErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACvF,KAAK,EAAE,sBAAsB,CAAmB;WAEzC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,sBAAsB;IAIrE,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAI7D,OAAO,CAAC,MAAM,CAEZ;IAEF,OAAO,CAAC,SAAS,CAOf;IAEK,MAAM,IAAI,SAAS;CAsC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/feedback/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -284,6 +284,63 @@ function ForbiddenState({ description = "You do not have permission to access th
|
|
|
284
284
|
return /* @__PURE__ */ jsx12(ErrorState, { title: "Access denied", description, action: /* @__PURE__ */ jsx12(Button, { variant: "secondary", children: "Go back" }) });
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
// src/components/feedback/ErrorBoundary.tsx
|
|
288
|
+
import { Component } from "react";
|
|
289
|
+
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
290
|
+
var PageErrorBoundary = class extends Component {
|
|
291
|
+
state = { error: null };
|
|
292
|
+
static getDerivedStateFromError(error) {
|
|
293
|
+
return { error };
|
|
294
|
+
}
|
|
295
|
+
componentDidCatch(error, info) {
|
|
296
|
+
console.error("A page stopped working:", error, info.componentStack);
|
|
297
|
+
}
|
|
298
|
+
reload = () => {
|
|
299
|
+
window.location.reload();
|
|
300
|
+
};
|
|
301
|
+
startOver = () => {
|
|
302
|
+
try {
|
|
303
|
+
sessionStorage.clear();
|
|
304
|
+
} catch {
|
|
305
|
+
}
|
|
306
|
+
window.location.assign(this.props.startOverPath ?? "/");
|
|
307
|
+
};
|
|
308
|
+
render() {
|
|
309
|
+
const { error } = this.state;
|
|
310
|
+
if (!error) return this.props.children;
|
|
311
|
+
const supportEmail = this.props.supportEmail ?? "support@busiversehq.com";
|
|
312
|
+
return /* @__PURE__ */ jsx13("div", { role: "alert", className: "flex min-h-screen items-center justify-center bg-background px-4", children: /* @__PURE__ */ jsxs6("div", { className: "busiverse-card max-w-md text-center", children: [
|
|
313
|
+
/* @__PURE__ */ jsx13("h1", { className: "font-heading text-2xl font-bold text-foreground", children: "This page stopped working" }),
|
|
314
|
+
/* @__PURE__ */ jsxs6("p", { className: "mt-3 leading-relaxed text-muted-foreground", children: [
|
|
315
|
+
"Nothing you were doing has been lost. Reloading usually clears it; if it keeps happening, tell us at",
|
|
316
|
+
" ",
|
|
317
|
+
/* @__PURE__ */ jsx13("a", { href: `mailto:${supportEmail}`, className: "text-primary underline-offset-4 hover:underline", children: supportEmail }),
|
|
318
|
+
"."
|
|
319
|
+
] }),
|
|
320
|
+
/* @__PURE__ */ jsxs6("details", { className: "mt-6 rounded-xl border border-destructive/30 bg-destructive/10 p-4 text-left", children: [
|
|
321
|
+
/* @__PURE__ */ jsx13("summary", { className: "cursor-pointer text-sm font-medium text-foreground", children: "Technical details" }),
|
|
322
|
+
/* @__PURE__ */ jsxs6("p", { className: "mt-2 break-words font-mono text-xs text-muted-foreground", children: [
|
|
323
|
+
error.name,
|
|
324
|
+
": ",
|
|
325
|
+
error.message
|
|
326
|
+
] })
|
|
327
|
+
] }),
|
|
328
|
+
/* @__PURE__ */ jsxs6("div", { className: "mt-8 flex flex-col items-center gap-3", children: [
|
|
329
|
+
/* @__PURE__ */ jsx13(
|
|
330
|
+
"button",
|
|
331
|
+
{
|
|
332
|
+
type: "button",
|
|
333
|
+
onClick: this.reload,
|
|
334
|
+
className: "rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground",
|
|
335
|
+
children: "Reload the page"
|
|
336
|
+
}
|
|
337
|
+
),
|
|
338
|
+
/* @__PURE__ */ jsx13("button", { type: "button", onClick: this.startOver, className: "text-sm text-primary underline-offset-4 hover:underline", children: "Start over and sign in again" })
|
|
339
|
+
] })
|
|
340
|
+
] }) });
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
287
344
|
// src/api/assertGatewayBaseUrl.ts
|
|
288
345
|
var GATEWAY_PUBLIC_HOST = "api.busiversehq.com";
|
|
289
346
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -359,10 +416,10 @@ function createGatewayClient(options) {
|
|
|
359
416
|
|
|
360
417
|
// src/auth/AuthSessionProvider.tsx
|
|
361
418
|
import * as React4 from "react";
|
|
362
|
-
import { jsx as
|
|
419
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
363
420
|
var AuthContext = React4.createContext(null);
|
|
364
421
|
function AuthSessionProvider({ children, session }) {
|
|
365
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ jsx14(AuthContext.Provider, { value: session, children });
|
|
366
423
|
}
|
|
367
424
|
function useBusiverseAuth() {
|
|
368
425
|
const value = React4.useContext(AuthContext);
|
|
@@ -371,34 +428,34 @@ function useBusiverseAuth() {
|
|
|
371
428
|
}
|
|
372
429
|
|
|
373
430
|
// src/auth/RequireAuth.tsx
|
|
374
|
-
import { Fragment, jsx as
|
|
431
|
+
import { Fragment, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
375
432
|
function RequireAuth({ children }) {
|
|
376
433
|
const auth = useBusiverseAuth();
|
|
377
|
-
if (auth.isLoading) return /* @__PURE__ */
|
|
434
|
+
if (auth.isLoading) return /* @__PURE__ */ jsx15("div", { className: "busiverse-loading-state", children: "Checking session\u2026" });
|
|
378
435
|
if (!auth.isAuthenticated) {
|
|
379
|
-
return /* @__PURE__ */
|
|
380
|
-
/* @__PURE__ */
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
436
|
+
return /* @__PURE__ */ jsxs7("div", { className: "busiverse-auth-required", children: [
|
|
437
|
+
/* @__PURE__ */ jsx15("h1", { children: "Sign in required" }),
|
|
438
|
+
/* @__PURE__ */ jsx15("p", { children: "Use your BUSIVERSE account to continue." }),
|
|
439
|
+
/* @__PURE__ */ jsx15(Button, { onClick: () => void auth.signIn(), children: "Sign in" })
|
|
383
440
|
] });
|
|
384
441
|
}
|
|
385
|
-
return /* @__PURE__ */
|
|
442
|
+
return /* @__PURE__ */ jsx15(Fragment, { children });
|
|
386
443
|
}
|
|
387
444
|
|
|
388
445
|
// src/auth/SignUpLink.tsx
|
|
389
|
-
import { jsx as
|
|
446
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
390
447
|
function SignUpLink({ signupUrl = "https://user.busiversehq.com/signup", children = "Create your Busiverse account", ...props }) {
|
|
391
|
-
return /* @__PURE__ */
|
|
448
|
+
return /* @__PURE__ */ jsx16("a", { href: signupUrl, ...props, children });
|
|
392
449
|
}
|
|
393
450
|
|
|
394
451
|
// src/auth/UserMenu.tsx
|
|
395
|
-
import { jsx as
|
|
452
|
+
import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
396
453
|
function UserMenu() {
|
|
397
454
|
const auth = useBusiverseAuth();
|
|
398
|
-
if (!auth.isAuthenticated || !auth.user) return /* @__PURE__ */
|
|
399
|
-
return /* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
/* @__PURE__ */
|
|
455
|
+
if (!auth.isAuthenticated || !auth.user) return /* @__PURE__ */ jsx17(Button, { size: "sm", onClick: () => void auth.signIn(), children: "Sign in" });
|
|
456
|
+
return /* @__PURE__ */ jsxs8("div", { className: "busiverse-user-menu", children: [
|
|
457
|
+
/* @__PURE__ */ jsx17("span", { children: auth.user.name ?? auth.user.email ?? "User" }),
|
|
458
|
+
/* @__PURE__ */ jsx17(Button, { size: "sm", variant: "ghost", onClick: () => void auth.signOut(), children: "Sign out" })
|
|
402
459
|
] });
|
|
403
460
|
}
|
|
404
461
|
export {
|
|
@@ -438,6 +495,7 @@ export {
|
|
|
438
495
|
MarketingPricingCard,
|
|
439
496
|
MarketingSectionHeader,
|
|
440
497
|
NorthSouthViolationError,
|
|
498
|
+
PageErrorBoundary,
|
|
441
499
|
PageHeader,
|
|
442
500
|
RegionSelector,
|
|
443
501
|
RequireAuth,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@busiverse/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"author": "Joel Julius Okoromi <okmarq@gmail.com> (https://busiversehq.com)",
|
|
5
5
|
"description": "BUSIVERSE shared React UI, design tokens, pricing, i18n, auth helpers, and product shell. Network-neutral core; Gateway transport is app-injected.",
|
|
6
6
|
"type": "module",
|