@frank-auth/react
Version:
Flexible and customizable React UI components for Frank Authentication
133 lines (132 loc) • 3.65 kB
JavaScript
'use client';
import { jsx as s } from "react/jsx-runtime";
import { AuthProvider as g, useAuth as u } from "./auth-provider.js";
import { useAuthGuard as U } from "./auth-provider.js";
import { HeroUIProvider as f } from "@heroui/react";
import n from "react";
import { ThemeProvider as y } from "../theme/provider.js";
import { ConfigProvider as A, useConfig as l } from "./config-provider.js";
import { useComponentOverrides as B, useFeatures as N, useOrganizationConfig as $, withConfig as G } from "./config-provider.js";
import { ThemeProvider as P, useTheme as h } from "./theme-provider.js";
import { ThemeSwitcher as M, useOrganizationBranding as R, useThemeMode as V, useThemeVariables as W, withTheme as D } from "./theme-provider.js";
function F({
children: r,
config: e,
onError: t,
onSignIn: i,
onSignOut: o,
onConfigChange: a,
onThemeChange: m,
customTheme: d,
enableSystemTheme: p = !0,
enableLocalStorage: c,
defaultMode: b = "light",
storageKey: v
}) {
if (!e.publishableKey)
throw new Error("publishableKey is required in FrankAuthProvider config");
if (!e.userType)
throw new Error("userType is required in FrankAuthProvider config");
return /* @__PURE__ */ s(f, { children: /* @__PURE__ */ s(A, { config: e, onConfigChange: a, children: /* @__PURE__ */ s(
y,
{
customTheme: d,
enableSystem: p,
enableLocalStorage: c,
defaultMode: b,
storageKey: v,
children: /* @__PURE__ */ s(
P,
{
theme: e.theme,
mode: e.theme?.mode,
organizationBranding: e.organization?.settings?.branding ? {
primaryColor: e.organization.settings.branding.primaryColor,
secondaryColor: e.organization.settings.branding.secondaryColor,
logo: e.organization.settings.branding.logo,
customCSS: e.organization.settings.branding.customCSS
} : void 0,
onThemeChange: m,
children: /* @__PURE__ */ s(
g,
{
publishableKey: e.publishableKey,
secretKey: e.secretKey,
userType: e.userType,
apiUrl: e.apiUrl,
projectId: e.projectId,
onError: t,
onSignIn: i,
onSignOut: o,
debug: e.debug,
children: r
}
)
}
)
}
) }) });
}
function j() {
const [r, e] = n.useState(!1), [t, i] = n.useState(!1), [o, a] = n.useState(!1);
return n.useEffect(() => {
try {
u(), e(!0);
} catch {
e(!1);
}
try {
l(), i(!0);
} catch {
i(!1);
}
try {
h(), a(!0);
} catch {
a(!1);
}
}, []), {
auth: r,
config: t,
theme: o,
allAvailable: r && t && o
};
}
function k(r) {
const e = (t) => {
const i = u(), o = l(), a = h();
return /* @__PURE__ */ s(r, { ...t, auth: i, config: o, theme: a });
};
return e.displayName = `withProviders(${r.displayName || r.name})`, e;
}
function E() {
const r = u(), e = l(), t = h();
return {
auth: r,
config: e,
theme: t
};
}
export {
g as AuthProvider,
A as ConfigProvider,
F as FrankAuthProvider,
P as ThemeProvider,
M as ThemeSwitcher,
E as useAllProviders,
u as useAuth,
U as useAuthGuard,
B as useComponentOverrides,
l as useConfig,
N as useFeatures,
R as useOrganizationBranding,
$ as useOrganizationConfig,
j as useProviderStatus,
h as useTheme,
V as useThemeMode,
W as useThemeVariables,
G as withConfig,
k as withProviders,
D as withTheme
};
//# sourceMappingURL=index.js.map