@techzyapp/ui-library 1.0.12 → 1.0.13
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/AdminRoot-BuB92RpF.cjs +2 -0
- package/dist/AdminRoot-BuB92RpF.cjs.map +1 -0
- package/dist/AdminRoot-TCS_blQB.js +50 -0
- package/dist/AdminRoot-TCS_blQB.js.map +1 -0
- package/dist/AuthGuard-CVklwDbj.js +7 -0
- package/dist/AuthGuard-CVklwDbj.js.map +1 -0
- package/dist/AuthGuard-kfOZviar.cjs +2 -0
- package/dist/AuthGuard-kfOZviar.cjs.map +1 -0
- package/dist/app/AdminRoot.d.cts +41 -0
- package/dist/app/AdminRoot.d.ts +41 -0
- package/dist/authLayoutRoute-B10sXioW.js +11 -0
- package/dist/authLayoutRoute-B10sXioW.js.map +1 -0
- package/dist/authLayoutRoute-BVQ4LhuU.cjs +2 -0
- package/dist/authLayoutRoute-BVQ4LhuU.cjs.map +1 -0
- package/dist/entries/app.cjs +2 -0
- package/dist/entries/app.cjs.map +1 -0
- package/dist/entries/app.d.cts +2 -0
- package/dist/entries/app.d.ts +2 -0
- package/dist/entries/app.js +5 -0
- package/dist/entries/app.js.map +1 -0
- package/dist/entries/auth.cjs +1 -1
- package/dist/entries/auth.js +4 -3
- package/dist/entries/auth.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +165 -162
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
- package/dist/authLayoutRoute-CkR9IANN.cjs +0 -2
- package/dist/authLayoutRoute-CkR9IANN.cjs.map +0 -1
- package/dist/authLayoutRoute-DEYvuYxM.js +0 -13
- package/dist/authLayoutRoute-DEYvuYxM.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("@tanstack/react-router"),x=require("./AuthGuard-kfOZviar.cjs"),R=require("./RootLayout-CxMadTU1.cjs"),g=require("./UserCard-C8rC_gzD.cjs"),q=require("./Toaster-qdS8Urgy.cjs"),A=({logo:s,getUser:u,onLogout:n,authRouteId:i="/_auth",loginPath:r="/login",showUserCard:c=!0,header:d})=>{const l=o.useNavigate(),m=o.useRouterState({select:j=>j.matches.some(v=>v.routeId.startsWith(i))}),t=u(),a=()=>{n(),l({to:r})},h=m?e.jsx(o.Outlet,{}):e.jsx(x.AuthGuard,{isAuthenticated:t!=null,redirectTo:r,children:e.jsx(R.RootLayout,{logo:s,toaster:!1,header:{user:t?{name:t.name,email:t.email,avatar:t.avatar}:void 0,onLogout:a,...d},sidebarFooter:c&&t?e.jsx(g.UserCard,{name:t.name,email:t.email,avatar:t.avatar,onLogout:a}):void 0,children:e.jsx(o.Outlet,{})})});return e.jsxs(e.Fragment,{children:[h,e.jsx(q.Toaster,{})]})};exports.AdminRoot=A;
|
|
2
|
+
//# sourceMappingURL=AdminRoot-BuB92RpF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminRoot-BuB92RpF.cjs","sources":["../src/app/AdminRoot.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Outlet, useNavigate, useRouterState, type LinkProps } from '@tanstack/react-router'\nimport { RootLayout, UserCard, Toaster, type RootLayoutHeader } from '../components'\nimport { AuthGuard } from '../auth/AuthGuard'\n\n/** The minimal user shape `AdminRoot` reads — apps pass their own richer type via the generic. */\nexport interface AdminUser {\n name?: string\n email?: string\n avatar?: string\n}\n\nexport interface AdminRootProps<U extends AdminUser = AdminUser> {\n /** Brand mark for the sidebar top. */\n logo?: ReactNode\n /** Current user, or `null` when signed out. */\n getUser: () => U | null\n /** Clears the session; `AdminRoot` navigates to `loginPath` afterwards. */\n onLogout: () => void\n /** Route-id prefix for standalone public pages (rendered outside the shell). Default `'/_auth'`. */\n authRouteId?: string\n /** Guard target for signed-out visitors + post-logout redirect. Default `'/login'`. */\n loginPath?: string\n /** Show a `UserCard` in the sidebar footer. Default `true`. */\n showUserCard?: boolean\n /** Extra `RootLayout` header config, merged **over** the defaults (the app's fields win). */\n header?: RootLayoutHeader\n}\n\n/**\n * Root-route component for admin apps — it wires up the whole shell orchestration so an app only has to\n * supply `logo` + `getUser` + `onLogout`. Public pages (route id under `authRouteId`) render standalone;\n * everything else renders inside the guarded admin shell (`RootLayout` + a sidebar `UserCard`), gated by\n * `AuthGuard` (signed-out visitors bounce to `loginPath`). Logout clears the session and navigates to\n * `loginPath`. Mounts exactly one app-wide `<Toaster/>` (the inner `RootLayout` gets `toaster={false}`).\n *\n * `loginPath` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree). The generic `<U>` preserves the app's own user type through `getUser`.\n *\n * @example\n * // routes/__root.tsx\n * export const Route = createRootRoute({\n * component: () => <AdminRoot<AuthUser> logo={<Logo />} getUser={getUser} onLogout={logout} />,\n * })\n */\nexport const AdminRoot = <U extends AdminUser = AdminUser>({\n logo,\n getUser,\n onLogout,\n authRouteId = '/_auth',\n loginPath = '/login',\n showUserCard = true,\n header,\n}: AdminRootProps<U>) => {\n const navigate = useNavigate()\n const isAuthRoute = useRouterState({\n select: (s) => s.matches.some((m) => m.routeId.startsWith(authRouteId)),\n })\n const user = getUser()\n const handleLogout = () => {\n onLogout()\n navigate({ to: loginPath as LinkProps['to'] })\n }\n const content = isAuthRoute ? (\n <Outlet />\n ) : (\n <AuthGuard isAuthenticated={user != null} redirectTo={loginPath}>\n <RootLayout\n logo={logo}\n toaster={false}\n header={{\n user: user ? { name: user.name, email: user.email, avatar: user.avatar } : undefined,\n onLogout: handleLogout,\n ...header,\n }}\n sidebarFooter={\n showUserCard && user ? (\n <UserCard\n name={user.name}\n email={user.email}\n avatar={user.avatar}\n onLogout={handleLogout}\n />\n ) : undefined\n }\n >\n <Outlet />\n </RootLayout>\n </AuthGuard>\n )\n return (\n <>\n {content}\n <Toaster />\n </>\n )\n}\n"],"names":["AdminRoot","logo","getUser","onLogout","authRouteId","loginPath","showUserCard","header","navigate","useNavigate","isAuthRoute","useRouterState","s","m","user","handleLogout","content","jsx","Outlet","AuthGuard","RootLayout","UserCard","jsxs","Fragment","Toaster"],"mappings":"4OA6CaA,EAAY,CAAkC,CACzD,KAAAC,EACA,QAAAC,EACA,SAAAC,EACA,YAAAC,EAAc,SACd,UAAAC,EAAY,SACZ,aAAAC,EAAe,GACf,OAAAC,CACF,IAAyB,CACvB,MAAMC,EAAWC,EAAAA,YAAA,EACXC,EAAcC,EAAAA,eAAe,CACjC,OAASC,GAAMA,EAAE,QAAQ,KAAMC,GAAMA,EAAE,QAAQ,WAAWT,CAAW,CAAC,CAAA,CACvE,EACKU,EAAOZ,EAAA,EACPa,EAAe,IAAM,CACzBZ,EAAA,EACAK,EAAS,CAAE,GAAIH,EAA8B,CAC/C,EACMW,EAAUN,EACdO,EAAAA,IAACC,EAAAA,OAAA,CAAA,CAAO,EAERD,EAAAA,IAACE,EAAAA,UAAA,CAAU,gBAAiBL,GAAQ,KAAM,WAAYT,EACpD,SAAAY,EAAAA,IAACG,EAAAA,WAAA,CACC,KAAAnB,EACA,QAAS,GACT,OAAQ,CACN,KAAMa,EAAO,CAAE,KAAMA,EAAK,KAAM,MAAOA,EAAK,MAAO,OAAQA,EAAK,MAAA,EAAW,OAC3E,SAAUC,EACV,GAAGR,CAAA,EAEL,cACED,GAAgBQ,EACdG,EAAAA,IAACI,EAAAA,SAAA,CACC,KAAMP,EAAK,KACX,MAAOA,EAAK,MACZ,OAAQA,EAAK,OACb,SAAUC,CAAA,CAAA,EAEV,OAGN,eAACG,EAAAA,OAAA,CAAA,CAAO,CAAA,CAAA,EAEZ,EAEF,OACEI,EAAAA,KAAAC,WAAA,CACG,SAAA,CAAAP,QACAQ,EAAAA,QAAA,CAAA,CAAQ,CAAA,EACX,CAEJ"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as o, jsxs as p, Fragment as g } from "react/jsx-runtime";
|
|
2
|
+
import { useNavigate as A, useRouterState as R, Outlet as r } from "@tanstack/react-router";
|
|
3
|
+
import { A as L } from "./AuthGuard-CVklwDbj.js";
|
|
4
|
+
import { R as x } from "./RootLayout-CqQZ6h5c.js";
|
|
5
|
+
import { U as T } from "./UserCard-0ZF29bkK.js";
|
|
6
|
+
import { T as j } from "./Toaster-Da8F_SFV.js";
|
|
7
|
+
const I = ({
|
|
8
|
+
logo: s,
|
|
9
|
+
getUser: i,
|
|
10
|
+
onLogout: m,
|
|
11
|
+
authRouteId: n = "/_auth",
|
|
12
|
+
loginPath: e = "/login",
|
|
13
|
+
showUserCard: u = !0,
|
|
14
|
+
header: c
|
|
15
|
+
}) => {
|
|
16
|
+
const d = A(), l = R({
|
|
17
|
+
select: (v) => v.matches.some((f) => f.routeId.startsWith(n))
|
|
18
|
+
}), t = i(), a = () => {
|
|
19
|
+
m(), d({ to: e });
|
|
20
|
+
}, h = l ? /* @__PURE__ */ o(r, {}) : /* @__PURE__ */ o(L, { isAuthenticated: t != null, redirectTo: e, children: /* @__PURE__ */ o(
|
|
21
|
+
x,
|
|
22
|
+
{
|
|
23
|
+
logo: s,
|
|
24
|
+
toaster: !1,
|
|
25
|
+
header: {
|
|
26
|
+
user: t ? { name: t.name, email: t.email, avatar: t.avatar } : void 0,
|
|
27
|
+
onLogout: a,
|
|
28
|
+
...c
|
|
29
|
+
},
|
|
30
|
+
sidebarFooter: u && t ? /* @__PURE__ */ o(
|
|
31
|
+
T,
|
|
32
|
+
{
|
|
33
|
+
name: t.name,
|
|
34
|
+
email: t.email,
|
|
35
|
+
avatar: t.avatar,
|
|
36
|
+
onLogout: a
|
|
37
|
+
}
|
|
38
|
+
) : void 0,
|
|
39
|
+
children: /* @__PURE__ */ o(r, {})
|
|
40
|
+
}
|
|
41
|
+
) });
|
|
42
|
+
return /* @__PURE__ */ p(g, { children: [
|
|
43
|
+
h,
|
|
44
|
+
/* @__PURE__ */ o(j, {})
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
I as A
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=AdminRoot-TCS_blQB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminRoot-TCS_blQB.js","sources":["../src/app/AdminRoot.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Outlet, useNavigate, useRouterState, type LinkProps } from '@tanstack/react-router'\nimport { RootLayout, UserCard, Toaster, type RootLayoutHeader } from '../components'\nimport { AuthGuard } from '../auth/AuthGuard'\n\n/** The minimal user shape `AdminRoot` reads — apps pass their own richer type via the generic. */\nexport interface AdminUser {\n name?: string\n email?: string\n avatar?: string\n}\n\nexport interface AdminRootProps<U extends AdminUser = AdminUser> {\n /** Brand mark for the sidebar top. */\n logo?: ReactNode\n /** Current user, or `null` when signed out. */\n getUser: () => U | null\n /** Clears the session; `AdminRoot` navigates to `loginPath` afterwards. */\n onLogout: () => void\n /** Route-id prefix for standalone public pages (rendered outside the shell). Default `'/_auth'`. */\n authRouteId?: string\n /** Guard target for signed-out visitors + post-logout redirect. Default `'/login'`. */\n loginPath?: string\n /** Show a `UserCard` in the sidebar footer. Default `true`. */\n showUserCard?: boolean\n /** Extra `RootLayout` header config, merged **over** the defaults (the app's fields win). */\n header?: RootLayoutHeader\n}\n\n/**\n * Root-route component for admin apps — it wires up the whole shell orchestration so an app only has to\n * supply `logo` + `getUser` + `onLogout`. Public pages (route id under `authRouteId`) render standalone;\n * everything else renders inside the guarded admin shell (`RootLayout` + a sidebar `UserCard`), gated by\n * `AuthGuard` (signed-out visitors bounce to `loginPath`). Logout clears the session and navigates to\n * `loginPath`. Mounts exactly one app-wide `<Toaster/>` (the inner `RootLayout` gets `toaster={false}`).\n *\n * `loginPath` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree). The generic `<U>` preserves the app's own user type through `getUser`.\n *\n * @example\n * // routes/__root.tsx\n * export const Route = createRootRoute({\n * component: () => <AdminRoot<AuthUser> logo={<Logo />} getUser={getUser} onLogout={logout} />,\n * })\n */\nexport const AdminRoot = <U extends AdminUser = AdminUser>({\n logo,\n getUser,\n onLogout,\n authRouteId = '/_auth',\n loginPath = '/login',\n showUserCard = true,\n header,\n}: AdminRootProps<U>) => {\n const navigate = useNavigate()\n const isAuthRoute = useRouterState({\n select: (s) => s.matches.some((m) => m.routeId.startsWith(authRouteId)),\n })\n const user = getUser()\n const handleLogout = () => {\n onLogout()\n navigate({ to: loginPath as LinkProps['to'] })\n }\n const content = isAuthRoute ? (\n <Outlet />\n ) : (\n <AuthGuard isAuthenticated={user != null} redirectTo={loginPath}>\n <RootLayout\n logo={logo}\n toaster={false}\n header={{\n user: user ? { name: user.name, email: user.email, avatar: user.avatar } : undefined,\n onLogout: handleLogout,\n ...header,\n }}\n sidebarFooter={\n showUserCard && user ? (\n <UserCard\n name={user.name}\n email={user.email}\n avatar={user.avatar}\n onLogout={handleLogout}\n />\n ) : undefined\n }\n >\n <Outlet />\n </RootLayout>\n </AuthGuard>\n )\n return (\n <>\n {content}\n <Toaster />\n </>\n )\n}\n"],"names":["AdminRoot","logo","getUser","onLogout","authRouteId","loginPath","showUserCard","header","navigate","useNavigate","isAuthRoute","useRouterState","s","m","user","handleLogout","content","jsx","Outlet","AuthGuard","RootLayout","UserCard","jsxs","Fragment","Toaster"],"mappings":";;;;;;AA6CO,MAAMA,IAAY,CAAkC;AAAA,EACzD,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,cAAAC,IAAe;AAAA,EACf,QAAAC;AACF,MAAyB;AACvB,QAAMC,IAAWC,EAAA,GACXC,IAAcC,EAAe;AAAA,IACjC,QAAQ,CAACC,MAAMA,EAAE,QAAQ,KAAK,CAACC,MAAMA,EAAE,QAAQ,WAAWT,CAAW,CAAC;AAAA,EAAA,CACvE,GACKU,IAAOZ,EAAA,GACPa,IAAe,MAAM;AACzB,IAAAZ,EAAA,GACAK,EAAS,EAAE,IAAIH,GAA8B;AAAA,EAC/C,GACMW,IAAUN,IACd,gBAAAO,EAACC,GAAA,CAAA,CAAO,IAER,gBAAAD,EAACE,GAAA,EAAU,iBAAiBL,KAAQ,MAAM,YAAYT,GACpD,UAAA,gBAAAY;AAAA,IAACG;AAAA,IAAA;AAAA,MACC,MAAAnB;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,QACN,MAAMa,IAAO,EAAE,MAAMA,EAAK,MAAM,OAAOA,EAAK,OAAO,QAAQA,EAAK,OAAA,IAAW;AAAA,QAC3E,UAAUC;AAAA,QACV,GAAGR;AAAA,MAAA;AAAA,MAEL,eACED,KAAgBQ,IACd,gBAAAG;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,MAAMP,EAAK;AAAA,UACX,OAAOA,EAAK;AAAA,UACZ,QAAQA,EAAK;AAAA,UACb,UAAUC;AAAA,QAAA;AAAA,MAAA,IAEV;AAAA,MAGN,4BAACG,GAAA,CAAA,CAAO;AAAA,IAAA;AAAA,EAAA,GAEZ;AAEF,SACE,gBAAAI,EAAAC,GAAA,EACG,UAAA;AAAA,IAAAP;AAAA,sBACAQ,GAAA,CAAA,CAAQ;AAAA,EAAA,GACX;AAEJ;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as r, Fragment as n } from "react/jsx-runtime";
|
|
2
|
+
import { Navigate as f } from "@tanstack/react-router";
|
|
3
|
+
const k = ({ isAuthenticated: o, redirectTo: t = "/login", children: m }) => (typeof o == "function" ? o() : o) ? /* @__PURE__ */ r(n, { children: m }) : /* @__PURE__ */ r(f, { to: t });
|
|
4
|
+
export {
|
|
5
|
+
k as A
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=AuthGuard-CVklwDbj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthGuard-CVklwDbj.js","sources":["../src/auth/AuthGuard.tsx"],"sourcesContent":["import { Navigate, type LinkProps } from '@tanstack/react-router'\nimport type { ReactNode } from 'react'\n\nexport interface AuthGuardProps {\n /** Session check — a boolean, or a function that returns one (evaluated on render). */\n isAuthenticated: boolean | (() => boolean)\n /** Where to send an unauthenticated visitor. Defaults to `'/login'`. */\n redirectTo?: string\n /** The protected content, rendered only when authenticated. */\n children: ReactNode\n}\n\n/**\n * Component-level auth guard: renders `children` only when authenticated, otherwise redirects to\n * `redirectTo` via `<Navigate>`. Wrap the authenticated area (a page or a subtree) with it.\n *\n * Requires a `@tanstack/react-router` context (it renders `<Navigate>`), so use it inside a routed\n * tree. `redirectTo` is a plain string — the library can't know the app's typed route tree, so it's\n * cast loosely to the router's `to` type.\n *\n * @example\n * <AuthGuard isAuthenticated={session.isAuthenticated} redirectTo=\"/login\">\n * <Dashboard />\n * </AuthGuard>\n */\nexport const AuthGuard = ({ isAuthenticated, redirectTo = '/login', children }: AuthGuardProps) => {\n const ok = typeof isAuthenticated === 'function' ? isAuthenticated() : isAuthenticated\n return ok ? <>{children}</> : <Navigate to={redirectTo as LinkProps['to']} />\n}\n"],"names":["AuthGuard","isAuthenticated","redirectTo","children","jsx","Fragment","Navigate"],"mappings":";;AAyBO,MAAMA,IAAY,CAAC,EAAE,iBAAAC,GAAiB,YAAAC,IAAa,UAAU,UAAAC,SACvD,OAAOF,KAAoB,aAAaA,MAAoBA,KAC3D,gBAAAG,EAAAC,GAAA,EAAG,UAAAF,EAAA,CAAS,IAAM,gBAAAC,EAACE,GAAA,EAAS,IAAIJ,EAAA,CAA+B;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),e=require("@tanstack/react-router"),n=({isAuthenticated:r,redirectTo:t="/login",children:u})=>(typeof r=="function"?r():r)?o.jsx(o.Fragment,{children:u}):o.jsx(e.Navigate,{to:t});exports.AuthGuard=n;
|
|
2
|
+
//# sourceMappingURL=AuthGuard-kfOZviar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthGuard-kfOZviar.cjs","sources":["../src/auth/AuthGuard.tsx"],"sourcesContent":["import { Navigate, type LinkProps } from '@tanstack/react-router'\nimport type { ReactNode } from 'react'\n\nexport interface AuthGuardProps {\n /** Session check — a boolean, or a function that returns one (evaluated on render). */\n isAuthenticated: boolean | (() => boolean)\n /** Where to send an unauthenticated visitor. Defaults to `'/login'`. */\n redirectTo?: string\n /** The protected content, rendered only when authenticated. */\n children: ReactNode\n}\n\n/**\n * Component-level auth guard: renders `children` only when authenticated, otherwise redirects to\n * `redirectTo` via `<Navigate>`. Wrap the authenticated area (a page or a subtree) with it.\n *\n * Requires a `@tanstack/react-router` context (it renders `<Navigate>`), so use it inside a routed\n * tree. `redirectTo` is a plain string — the library can't know the app's typed route tree, so it's\n * cast loosely to the router's `to` type.\n *\n * @example\n * <AuthGuard isAuthenticated={session.isAuthenticated} redirectTo=\"/login\">\n * <Dashboard />\n * </AuthGuard>\n */\nexport const AuthGuard = ({ isAuthenticated, redirectTo = '/login', children }: AuthGuardProps) => {\n const ok = typeof isAuthenticated === 'function' ? isAuthenticated() : isAuthenticated\n return ok ? <>{children}</> : <Navigate to={redirectTo as LinkProps['to']} />\n}\n"],"names":["AuthGuard","isAuthenticated","redirectTo","children","jsx","Fragment","Navigate"],"mappings":"sFAyBaA,EAAY,CAAC,CAAE,gBAAAC,EAAiB,WAAAC,EAAa,SAAU,SAAAC,MACvD,OAAOF,GAAoB,WAAaA,IAAoBA,GAC3DG,EAAAA,IAAAC,EAAAA,SAAA,CAAG,SAAAF,CAAA,CAAS,EAAMC,EAAAA,IAACE,EAAAA,SAAA,CAAS,GAAIJ,CAAA,CAA+B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type RootLayoutHeader } from '../components';
|
|
3
|
+
/** The minimal user shape `AdminRoot` reads — apps pass their own richer type via the generic. */
|
|
4
|
+
export interface AdminUser {
|
|
5
|
+
name?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
avatar?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AdminRootProps<U extends AdminUser = AdminUser> {
|
|
10
|
+
/** Brand mark for the sidebar top. */
|
|
11
|
+
logo?: ReactNode;
|
|
12
|
+
/** Current user, or `null` when signed out. */
|
|
13
|
+
getUser: () => U | null;
|
|
14
|
+
/** Clears the session; `AdminRoot` navigates to `loginPath` afterwards. */
|
|
15
|
+
onLogout: () => void;
|
|
16
|
+
/** Route-id prefix for standalone public pages (rendered outside the shell). Default `'/_auth'`. */
|
|
17
|
+
authRouteId?: string;
|
|
18
|
+
/** Guard target for signed-out visitors + post-logout redirect. Default `'/login'`. */
|
|
19
|
+
loginPath?: string;
|
|
20
|
+
/** Show a `UserCard` in the sidebar footer. Default `true`. */
|
|
21
|
+
showUserCard?: boolean;
|
|
22
|
+
/** Extra `RootLayout` header config, merged **over** the defaults (the app's fields win). */
|
|
23
|
+
header?: RootLayoutHeader;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Root-route component for admin apps — it wires up the whole shell orchestration so an app only has to
|
|
27
|
+
* supply `logo` + `getUser` + `onLogout`. Public pages (route id under `authRouteId`) render standalone;
|
|
28
|
+
* everything else renders inside the guarded admin shell (`RootLayout` + a sidebar `UserCard`), gated by
|
|
29
|
+
* `AuthGuard` (signed-out visitors bounce to `loginPath`). Logout clears the session and navigates to
|
|
30
|
+
* `loginPath`. Mounts exactly one app-wide `<Toaster/>` (the inner `RootLayout` gets `toaster={false}`).
|
|
31
|
+
*
|
|
32
|
+
* `loginPath` is a plain string, cast loosely to the router's `to` type (the library can't know the
|
|
33
|
+
* app's typed route tree). The generic `<U>` preserves the app's own user type through `getUser`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // routes/__root.tsx
|
|
37
|
+
* export const Route = createRootRoute({
|
|
38
|
+
* component: () => <AdminRoot<AuthUser> logo={<Logo />} getUser={getUser} onLogout={logout} />,
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
export declare const AdminRoot: <U extends AdminUser = AdminUser>({ logo, getUser, onLogout, authRouteId, loginPath, showUserCard, header, }: AdminRootProps<U>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type RootLayoutHeader } from '../components';
|
|
3
|
+
/** The minimal user shape `AdminRoot` reads — apps pass their own richer type via the generic. */
|
|
4
|
+
export interface AdminUser {
|
|
5
|
+
name?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
avatar?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AdminRootProps<U extends AdminUser = AdminUser> {
|
|
10
|
+
/** Brand mark for the sidebar top. */
|
|
11
|
+
logo?: ReactNode;
|
|
12
|
+
/** Current user, or `null` when signed out. */
|
|
13
|
+
getUser: () => U | null;
|
|
14
|
+
/** Clears the session; `AdminRoot` navigates to `loginPath` afterwards. */
|
|
15
|
+
onLogout: () => void;
|
|
16
|
+
/** Route-id prefix for standalone public pages (rendered outside the shell). Default `'/_auth'`. */
|
|
17
|
+
authRouteId?: string;
|
|
18
|
+
/** Guard target for signed-out visitors + post-logout redirect. Default `'/login'`. */
|
|
19
|
+
loginPath?: string;
|
|
20
|
+
/** Show a `UserCard` in the sidebar footer. Default `true`. */
|
|
21
|
+
showUserCard?: boolean;
|
|
22
|
+
/** Extra `RootLayout` header config, merged **over** the defaults (the app's fields win). */
|
|
23
|
+
header?: RootLayoutHeader;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Root-route component for admin apps — it wires up the whole shell orchestration so an app only has to
|
|
27
|
+
* supply `logo` + `getUser` + `onLogout`. Public pages (route id under `authRouteId`) render standalone;
|
|
28
|
+
* everything else renders inside the guarded admin shell (`RootLayout` + a sidebar `UserCard`), gated by
|
|
29
|
+
* `AuthGuard` (signed-out visitors bounce to `loginPath`). Logout clears the session and navigates to
|
|
30
|
+
* `loginPath`. Mounts exactly one app-wide `<Toaster/>` (the inner `RootLayout` gets `toaster={false}`).
|
|
31
|
+
*
|
|
32
|
+
* `loginPath` is a plain string, cast loosely to the router's `to` type (the library can't know the
|
|
33
|
+
* app's typed route tree). The generic `<U>` preserves the app's own user type through `getUser`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // routes/__root.tsx
|
|
37
|
+
* export const Route = createRootRoute({
|
|
38
|
+
* component: () => <AdminRoot<AuthUser> logo={<Logo />} getUser={getUser} onLogout={logout} />,
|
|
39
|
+
* })
|
|
40
|
+
*/
|
|
41
|
+
export declare const AdminRoot: <U extends AdminUser = AdminUser>({ logo, getUser, onLogout, authRouteId, loginPath, showUserCard, header, }: AdminRootProps<U>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Outlet as e, redirect as r } from "@tanstack/react-router";
|
|
2
|
+
const u = ({ isAuthenticated: o, redirectTo: t = "/" }) => ({
|
|
3
|
+
beforeLoad: () => {
|
|
4
|
+
if (o()) throw r({ to: t });
|
|
5
|
+
},
|
|
6
|
+
component: e
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
u as a
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=authLayoutRoute-B10sXioW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authLayoutRoute-B10sXioW.js","sources":["../src/auth/authLayoutRoute.ts"],"sourcesContent":["import { Outlet, redirect, type LinkProps } from '@tanstack/react-router'\n\nexport interface AuthLayoutRouteOptions {\n /** Session check — returns whether the visitor is already signed in. */\n isAuthenticated: () => boolean\n /** Where to send an **already signed-in** visitor. Defaults to `'/'`. */\n redirectTo?: string\n}\n\n/**\n * Route options for the pathless `_auth` layout that groups the public auth pages (login,\n * forgot-password, reset-password, otp, …). In `beforeLoad` it bounces an already signed-in visitor to\n * `redirectTo`; otherwise it renders its children standalone (`component: Outlet`).\n *\n * Returns only the route **options** (`beforeLoad` + `component`) — not a whole route — because the\n * router plugin needs the literal path in the file. Compose it with `createFileRoute('/_auth')`.\n * `redirectTo` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree).\n *\n * @example\n * // routes/_auth.tsx\n * export const Route = createFileRoute('/_auth')(\n * authLayoutRoute({ isAuthenticated: session.isAuthenticated }),\n * )\n */\nexport const authLayoutRoute = ({ isAuthenticated, redirectTo = '/' }: AuthLayoutRouteOptions) => ({\n beforeLoad: () => {\n if (isAuthenticated()) throw redirect({ to: redirectTo as LinkProps['to'] })\n },\n component: Outlet,\n})\n"],"names":["authLayoutRoute","isAuthenticated","redirectTo","redirect","Outlet"],"mappings":";AAyBO,MAAMA,IAAkB,CAAC,EAAE,iBAAAC,GAAiB,YAAAC,IAAa,WAAmC;AAAA,EACjG,YAAY,MAAM;AAChB,QAAID,IAAmB,OAAME,EAAS,EAAE,IAAID,GAA+B;AAAA,EAC7E;AAAA,EACA,WAAWE;AACb;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authLayoutRoute-BVQ4LhuU.cjs","sources":["../src/auth/authLayoutRoute.ts"],"sourcesContent":["import { Outlet, redirect, type LinkProps } from '@tanstack/react-router'\n\nexport interface AuthLayoutRouteOptions {\n /** Session check — returns whether the visitor is already signed in. */\n isAuthenticated: () => boolean\n /** Where to send an **already signed-in** visitor. Defaults to `'/'`. */\n redirectTo?: string\n}\n\n/**\n * Route options for the pathless `_auth` layout that groups the public auth pages (login,\n * forgot-password, reset-password, otp, …). In `beforeLoad` it bounces an already signed-in visitor to\n * `redirectTo`; otherwise it renders its children standalone (`component: Outlet`).\n *\n * Returns only the route **options** (`beforeLoad` + `component`) — not a whole route — because the\n * router plugin needs the literal path in the file. Compose it with `createFileRoute('/_auth')`.\n * `redirectTo` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree).\n *\n * @example\n * // routes/_auth.tsx\n * export const Route = createFileRoute('/_auth')(\n * authLayoutRoute({ isAuthenticated: session.isAuthenticated }),\n * )\n */\nexport const authLayoutRoute = ({ isAuthenticated, redirectTo = '/' }: AuthLayoutRouteOptions) => ({\n beforeLoad: () => {\n if (isAuthenticated()) throw redirect({ to: redirectTo as LinkProps['to'] })\n },\n component: Outlet,\n})\n"],"names":["authLayoutRoute","isAuthenticated","redirectTo","redirect","Outlet"],"mappings":"uDAyBaA,EAAkB,CAAC,CAAE,gBAAAC,EAAiB,WAAAC,EAAa,QAAmC,CACjG,WAAY,IAAM,CAChB,GAAID,IAAmB,MAAME,EAAAA,SAAS,CAAE,GAAID,EAA+B,CAC7E,EACA,UAAWE,EAAAA,MACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/entries/auth.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../authLayoutRoute-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../AuthGuard-kfOZviar.cjs"),u=require("../authLayoutRoute-BVQ4LhuU.cjs");exports.AuthGuard=t.AuthGuard;exports.authLayoutRoute=u.authLayoutRoute;
|
|
2
2
|
//# sourceMappingURL=auth.cjs.map
|
package/dist/entries/auth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as t } from "../AuthGuard-CVklwDbj.js";
|
|
2
|
+
import { a as u } from "../authLayoutRoute-B10sXioW.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
t as AuthGuard,
|
|
5
|
+
u as authLayoutRoute
|
|
5
6
|
};
|
|
6
7
|
//# sourceMappingURL=auth.js.map
|
package/dist/entries/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./Form-Bz2xgkEm.cjs"),s=require("./useForm-C7erBHt0.cjs"),C=require("./useLockBodyScroll-CIXHZo-Q.cjs"),u=require("./useMediaQuery-CHMrI6Dy.cjs"),m=require("./useClipboard-BjTIX-4g.cjs"),o=require("./access-DPUHbE-S.cjs"),e=require("./ConfigProvider-BHNx-NHV.cjs"),i=require("./messages-Jxz2YMcA.cjs"),r=require("./translations-CXEeeUDL.cjs"),a=require("./table-CZRQGNdk.cjs"),S=require("./AuthGuard-kfOZviar.cjs"),h=require("./authLayoutRoute-BVQ4LhuU.cjs"),E=require("./AdminRoot-BuB92RpF.cjs"),n=require("./Icon-CXTl_QAP.cjs"),c=require("./Accordion-Dy_dM79Y.cjs"),R=require("./Alert-D99G0StL.cjs"),b=require("./AuthLayout-pvqB9w-B.cjs"),B=require("./Avatar-_ufXh3AY.cjs"),L=require("./AvatarGroup-TW1pt4tj.cjs"),t=require("./breakpoints-Dpnh6BbG.cjs"),D=require("./Badge-BQpr2Jee.cjs"),P=require("./Blockquote-CxHwOecc.cjs"),N=require("./Breadcrumbs-BnxhmyK5.cjs"),_=require("./Button-Cj6pckNl.cjs"),k=require("./Card-DD9SWHzZ.cjs"),I=require("./Checkbox-DXOzYIAz.cjs"),M=require("./Chip-B2lY4TJ0.cjs"),l=require("./ChoiceCardGroup-6eFM1eL0.cjs"),U=require("./Code-CUdpWlY5.cjs"),v=require("./CodeBlock-EhB7v9-R.cjs"),d=require("./Col-BdQeyKEX.cjs"),Q=require("./ColorPicker-Dc1y9Zuu.cjs"),K=require("./CopyButton-D_DCLHhb.cjs"),O=require("./DashedButton-q7AOqKUE.cjs"),G=require("./DatePicker-CEczjGZy.cjs"),x=require("./DateTimePicker-CDyGxUBX.cjs"),Y=require("./Divider-CzbhdCiD.cjs"),f=require("./Dropdown-Ui7h2TGd.cjs"),w=require("./EmptyState-B77utgEn.cjs"),H=require("./FileCard-CsGW2sxE.cjs"),j=require("./FileUploader-DDi_uzIx.cjs"),T=require("./Sidebar-CT_NUo_7.cjs"),z=require("./Flag-BJLWKB9J.cjs"),J=require("./Flex-C6tHC8n7.cjs"),V=require("./FullscreenToggle-MCxGzAEe.cjs"),W=require("./Grid-frN0D9lR.cjs"),q=require("./names-C2Yj1p3u.cjs"),X=require("./IconButton-BoY2y_pV.cjs"),Z=require("./List-ChXO0Hz-.cjs"),$=require("./ListItem-DWQorRxG.cjs"),ee=require("./Loader-Cwb1bOHj.cjs"),re=require("./Masonry-9LrJKlhI.cjs"),oe=require("./Modal-CO3c3sGY.cjs"),te=require("./MultiSelect-DVOVHuIm.cjs"),ie=require("./MultilineTextField-Dz6Fg8RJ.cjs"),se=require("./NumberField-BH237Vt2.cjs"),ue=require("./OtpField-CXP59zM2.cjs"),ae=require("./PageLayout-CuVuZEbR.cjs"),ne=require("./PageNotFound-CxLUFoJa.cjs"),ce=require("./Pagination-Dcs_Znx3.cjs"),le=require("./Popover-CBI1icIM.cjs"),p=require("./RadioGroup-C8u7eNBS.cjs"),de=require("./RemoveDialog-Cwtq9wAt.cjs"),Te=require("./RichTextEditor-GxbnzLRe.cjs"),qe=require("./RootLayout-CxMadTU1.cjs"),pe=require("./Select-DjMZec8c.cjs"),Ae=require("./Slider-dxYVXRev.cjs"),A=require("./SpeedDial-CyiPagdu.cjs"),ge=require("./Stepper-PW7c45PV.cjs"),ye=require("./SwatchPicker-DbAU9-ux.cjs"),Fe=require("./Switch-DRkZ6kHJ.cjs"),Ce=require("./Table-C_Ov-kvK.cjs"),me=require("./Tabs-CaHTJ99w.cjs"),Se=require("./TagsField-BQIwSX5m.cjs"),he=require("./TextField-fmt7aacg.cjs"),Ee=require("./ThemeToggle-Cz5I2-DL.cjs"),Re=require("./TimePicker-B-c6uIaY.cjs"),g=require("./Timeline-CoxW0Ia_.cjs"),be=require("./Toaster-qdS8Urgy.cjs"),y=require("./ToggleButtonGroup-DYRLwKKh.cjs"),Be=require("./Tooltip-Ao7az09p.cjs"),Le=require("./TranslatedFields-C30ww45c.cjs"),De=require("./Typography-BFatE1_A.cjs"),Pe=require("./UserCard-C8rC_gzD.cjs"),Ne=require("./toastStore-B4Tk2Xk7.cjs");exports.Form=F.Form;exports.useDisclosure=s.useDisclosure;exports.useForm=s.useForm;exports.useLockBodyScroll=C.useLockBodyScroll;exports.useBreakpointMatches=u.useBreakpointMatches;exports.useMediaQuery=u.useMediaQuery;exports.useClipboard=m.useClipboard;exports.getAccessKeys=o.getAccessKeys;exports.hasAccess=o.hasAccess;exports.setAccessKeys=o.setAccessKeys;exports.useAccessKeys=o.useAccessKeys;exports.ConfigProvider=e.ConfigProvider;exports.DEFAULT_FONT_FAMILY=e.DEFAULT_FONT_FAMILY;exports.DEFAULT_NESTED_TAB_QUERY_KEY=e.DEFAULT_NESTED_TAB_QUERY_KEY;exports.DEFAULT_STEP_QUERY_KEY=e.DEFAULT_STEP_QUERY_KEY;exports.DEFAULT_TABS_QUERY_KEY=e.DEFAULT_TABS_QUERY_KEY;exports.applyTheme=e.applyTheme;exports.useHeaderConfig=e.useHeaderConfig;exports.useLanguage=e.useLanguage;exports.useLocales=e.useLocales;exports.useNestedTabQueryKey=e.useNestedTabQueryKey;exports.useStepQueryKey=e.useStepQueryKey;exports.useT=e.useT;exports.useTableQueryConfig=e.useTableQueryConfig;exports.useTabsQueryKey=e.useTabsQueryKey;exports.useTheme=e.useTheme;exports.useTranslations=e.useTranslations;exports.useTranslationsNamespace=e.useTranslationsNamespace;exports.createAppTranslator=i.createAppTranslator;exports.createTranslator=i.createTranslator;exports.flagFor=i.flagFor;exports.DEFAULT_TRANSLATIONS_NAMESPACE=r.DEFAULT_TRANSLATIONS_NAMESPACE;exports.buildTranslationName=r.buildTranslationName;exports.buildTranslations=r.buildTranslations;exports.flattenTranslations=r.flattenTranslations;exports.nestTranslations=r.nestTranslations;exports.toFormData=r.toFormData;exports.buildTableQuery=a.buildTableQuery;exports.parseTableQuery=a.parseTableQuery;exports.AuthGuard=S.AuthGuard;exports.authLayoutRoute=h.authLayoutRoute;exports.AdminRoot=E.AdminRoot;exports.Icon=n.Icon;exports.icons=n.icons;exports.Accordion=c.Accordion;exports.AccordionItem=c.AccordionItem;exports.Alert=R.Alert;exports.AuthLayout=b.AuthLayout;exports.Avatar=B.Avatar;exports.AvatarGroup=L.AvatarGroup;exports.BREAKPOINTS=t.BREAKPOINTS;exports.BREAKPOINT_ORDER=t.BREAKPOINT_ORDER;exports.breakpointQuery=t.breakpointQuery;exports.resolveResponsive=t.resolveResponsive;exports.Badge=D.Badge;exports.Blockquote=P.Blockquote;exports.Breadcrumbs=N.Breadcrumbs;exports.Button=_.Button;exports.Card=k.Card;exports.Checkbox=I.Checkbox;exports.Chip=M.Chip;exports.ChoiceCard=l.ChoiceCard;exports.ChoiceCardGroup=l.ChoiceCardGroup;exports.Code=U.Code;exports.CodeBlock=v.CodeBlock;exports.Col=d.Col;exports.Row=d.Row;exports.ColorPicker=Q.ColorPicker;exports.CopyButton=K.CopyButton;exports.DashedButton=O.DashedButton;exports.DatePicker=G.DatePicker;exports.DateTimePicker=x.DateTimePicker;exports.Divider=Y.Divider;exports.Dropdown=f.Dropdown;exports.EmptyState=w.EmptyState;exports.FileCard=H.FileCard;exports.FileUploader=j.FileUploader;exports.FirstRouteRedirect=T.FirstRouteRedirect;exports.Sidebar=T.Sidebar;exports.Flag=z.Flag;exports.Flex=J.Flex;exports.FullscreenToggle=V.FullscreenToggle;exports.Grid=W.Grid;exports.ICON_COUNT=q.ICON_COUNT;exports.ICON_NAMES=q.ICON_NAMES;exports.IconButton=X.IconButton;exports.List=Z.List;exports.ListItem=$.ListItem;exports.Loader=ee.Loader;exports.Masonry=re.Masonry;exports.Modal=oe.Modal;exports.MultiSelect=te.MultiSelect;exports.MultilineTextField=ie.MultilineTextField;exports.NumberField=se.NumberField;exports.OtpField=ue.OtpField;exports.PageLayout=ae.PageLayout;exports.PageNotFound=ne.PageNotFound;exports.Pagination=ce.Pagination;exports.Popover=le.Popover;exports.Radio=p.Radio;exports.RadioGroup=p.RadioGroup;exports.RemoveDialog=de.RemoveDialog;exports.RichTextEditor=Te.RichTextEditor;exports.RootLayout=qe.RootLayout;exports.Select=pe.Select;exports.Slider=Ae.Slider;exports.SpeedDial=A.SpeedDial;exports.SpeedDialAction=A.SpeedDialAction;exports.Stepper=ge.Stepper;exports.SwatchPicker=ye.SwatchPicker;exports.Switch=Fe.Switch;exports.Table=Ce.Table;exports.Tabs=me.Tabs;exports.TagsField=Se.TagsField;exports.TextField=he.TextField;exports.ThemeToggle=Ee.ThemeToggle;exports.TimePicker=Re.TimePicker;exports.Timeline=g.Timeline;exports.TimelineItem=g.TimelineItem;exports.Toaster=be.Toaster;exports.ToggleButton=y.ToggleButton;exports.ToggleButtonGroup=y.ToggleButtonGroup;exports.Tooltip=Be.Tooltip;exports.TranslatedFields=Le.TranslatedFields;exports.Typography=De.Typography;exports.UserCard=Pe.UserCard;exports.toast=Ne.toast;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,176 +4,179 @@ import { u as m } from "./useLockBodyScroll-DwBILLPK.js";
|
|
|
4
4
|
import { u as x, a as i } from "./useMediaQuery-DrDUrkmJ.js";
|
|
5
5
|
import { u as T } from "./useClipboard-CEw_Juiq.js";
|
|
6
6
|
import { g as n, h as d, s as c, u as A } from "./access-Db4knwyR.js";
|
|
7
|
-
import { C as F, D as S, c as g, d as y, e as D, f as
|
|
7
|
+
import { C as F, D as S, c as g, d as y, e as D, f as R, g as E, u as B, h as b, i as L, j as h, a as P, k as N, l as _, m as I, b as M, n as k } from "./ConfigProvider-BYruQYHC.js";
|
|
8
8
|
import { c as K, a as Q, f as O } from "./messages-BOKick2l.js";
|
|
9
9
|
import { D as G, b as Y, a as w, f as j, n as q, t as H } from "./translations-D15tFHM1.js";
|
|
10
10
|
import { b as J, p as V } from "./table-DF3zTrC3.js";
|
|
11
|
-
import { A as X
|
|
12
|
-
import {
|
|
13
|
-
import { A as
|
|
14
|
-
import {
|
|
15
|
-
import { A as
|
|
16
|
-
import { A as
|
|
17
|
-
import { A as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { B as
|
|
21
|
-
import { B as
|
|
22
|
-
import { B as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { C as
|
|
26
|
-
import { C as
|
|
27
|
-
import { C as
|
|
28
|
-
import { C as
|
|
29
|
-
import { C as
|
|
30
|
-
import { C as
|
|
31
|
-
import { C as
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { D as
|
|
35
|
-
import { D as
|
|
36
|
-
import { D as
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import { F as
|
|
41
|
-
import { F as
|
|
42
|
-
import { F as
|
|
43
|
-
import { F as
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import { L as
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import { M as
|
|
53
|
-
import { M as
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import { P as
|
|
59
|
-
import { P as
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import { R as
|
|
63
|
-
import { R as
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import { S as
|
|
67
|
-
import { S as
|
|
68
|
-
import { S as
|
|
69
|
-
import { S as
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import { T as
|
|
73
|
-
import { T as
|
|
74
|
-
import { T as
|
|
75
|
-
import { T as
|
|
76
|
-
import { T as
|
|
77
|
-
import { T as
|
|
78
|
-
import { T as
|
|
79
|
-
import { T as
|
|
80
|
-
import { T as
|
|
81
|
-
import { T as
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
11
|
+
import { A as X } from "./AuthGuard-CVklwDbj.js";
|
|
12
|
+
import { a as $ } from "./authLayoutRoute-B10sXioW.js";
|
|
13
|
+
import { A as ro } from "./AdminRoot-TCS_blQB.js";
|
|
14
|
+
import { I as ao, i as so } from "./Icon-CophpkHo.js";
|
|
15
|
+
import { A as po, a as mo } from "./Accordion-CAxa1I-m.js";
|
|
16
|
+
import { A as xo } from "./Alert-B3rDvpbO.js";
|
|
17
|
+
import { A as uo } from "./AuthLayout-DGCe90w0.js";
|
|
18
|
+
import { A as lo } from "./Avatar-BJVCdo-K.js";
|
|
19
|
+
import { A as co } from "./AvatarGroup-DdJf4aT7.js";
|
|
20
|
+
import { B as Co, a as Fo, b as So, r as go } from "./breakpoints-BbDakdqF.js";
|
|
21
|
+
import { B as Do } from "./Badge-DSWigoGC.js";
|
|
22
|
+
import { B as Eo } from "./Blockquote-CNIuJFHq.js";
|
|
23
|
+
import { B as bo } from "./Breadcrumbs-DvgctFLS.js";
|
|
24
|
+
import { B as ho } from "./Button-CUsXYM-m.js";
|
|
25
|
+
import { C as No } from "./Card-DhpudGvF.js";
|
|
26
|
+
import { C as Io } from "./Checkbox-XKL_Q5qj.js";
|
|
27
|
+
import { C as ko } from "./Chip-DulHqhuf.js";
|
|
28
|
+
import { C as Ko, a as Qo } from "./ChoiceCardGroup-CvFzZlgI.js";
|
|
29
|
+
import { C as vo } from "./Code-DaEpXHfF.js";
|
|
30
|
+
import { C as Yo } from "./CodeBlock-DwBMghs2.js";
|
|
31
|
+
import { C as jo, R as qo } from "./Col-B51RlwWP.js";
|
|
32
|
+
import { C as zo } from "./ColorPicker-DJgTeHht.js";
|
|
33
|
+
import { C as Vo } from "./CopyButton-B4-OYsYr.js";
|
|
34
|
+
import { D as Xo } from "./DashedButton-DeiALUPA.js";
|
|
35
|
+
import { D as $o } from "./DatePicker-DkvfSN1K.js";
|
|
36
|
+
import { D as rr } from "./DateTimePicker-DPomyrnN.js";
|
|
37
|
+
import { D as ar } from "./Divider-LtH3dLgw.js";
|
|
38
|
+
import { D as tr } from "./Dropdown-FfkmluRu.js";
|
|
39
|
+
import { E as mr } from "./EmptyState-CVyFXprK.js";
|
|
40
|
+
import { F as xr } from "./FileCard-Cpc5frNm.js";
|
|
41
|
+
import { F as ur } from "./FileUploader-B_nKMh_K.js";
|
|
42
|
+
import { F as lr, S as nr } from "./Sidebar-Csd3iKbS.js";
|
|
43
|
+
import { F as cr } from "./Flag-Ck1xK22A.js";
|
|
44
|
+
import { F as Cr } from "./Flex-BFn4P1tJ.js";
|
|
45
|
+
import { F as Sr } from "./FullscreenToggle-DmC0jTay.js";
|
|
46
|
+
import { G as yr } from "./Grid-5k6dy-F5.js";
|
|
47
|
+
import { I as Rr, a as Er } from "./names-D8ABK2Wk.js";
|
|
48
|
+
import { I as br } from "./IconButton-B8FPGgDn.js";
|
|
49
|
+
import { L as hr } from "./List-LqbfF6gU.js";
|
|
50
|
+
import { L as Nr } from "./ListItem-B4Upc0Hy.js";
|
|
51
|
+
import { L as Ir } from "./Loader-UzzqvFyo.js";
|
|
52
|
+
import { M as kr } from "./Masonry-BsRWG-oN.js";
|
|
53
|
+
import { M as Kr } from "./Modal-XMRDPHvQ.js";
|
|
54
|
+
import { M as Or } from "./MultiSelect-BPLctumx.js";
|
|
55
|
+
import { M as Gr } from "./MultilineTextField-CwNCJ9lZ.js";
|
|
56
|
+
import { N as wr } from "./NumberField-X2HsSpu9.js";
|
|
57
|
+
import { O as qr } from "./OtpField-CB05q0NX.js";
|
|
58
|
+
import { P as zr } from "./PageLayout-WKWnj5cw.js";
|
|
59
|
+
import { P as Vr } from "./PageNotFound-CmT-Wr9m.js";
|
|
60
|
+
import { P as Xr } from "./Pagination-BuP4N1bj.js";
|
|
61
|
+
import { P as $r } from "./Popover-CgIU4Rhg.js";
|
|
62
|
+
import { R as re, a as ee } from "./RadioGroup-DbodUJW8.js";
|
|
63
|
+
import { R as se } from "./RemoveDialog-DU6MqkO8.js";
|
|
64
|
+
import { R as pe } from "./RichTextEditor-k-NlWb4Y.js";
|
|
65
|
+
import { R as fe } from "./RootLayout-CqQZ6h5c.js";
|
|
66
|
+
import { S as ie } from "./Select-D7KJ-YMU.js";
|
|
67
|
+
import { S as Te } from "./Slider-oGXd5e9X.js";
|
|
68
|
+
import { S as ne, a as de } from "./SpeedDial-DEWzAGXi.js";
|
|
69
|
+
import { S as Ae } from "./Stepper-CS6s0dMF.js";
|
|
70
|
+
import { S as Fe } from "./SwatchPicker-D30aSrbY.js";
|
|
71
|
+
import { S as ge } from "./Switch-DMPJ0fhB.js";
|
|
72
|
+
import { T as De } from "./Table-IIAKXYOh.js";
|
|
73
|
+
import { T as Ee } from "./Tabs-D3wztVB1.js";
|
|
74
|
+
import { T as be } from "./TagsField-BR9Z5pik.js";
|
|
75
|
+
import { T as he } from "./TextField-Bg4TwkVD.js";
|
|
76
|
+
import { T as Ne } from "./ThemeToggle-DEfXczDs.js";
|
|
77
|
+
import { T as Ie } from "./TimePicker-i2RnZHV1.js";
|
|
78
|
+
import { T as ke, a as Ue } from "./Timeline-WkV4k_we.js";
|
|
79
|
+
import { T as Qe } from "./Toaster-Da8F_SFV.js";
|
|
80
|
+
import { T as ve, a as Ge } from "./ToggleButtonGroup-BWd7MOcc.js";
|
|
81
|
+
import { T as we } from "./Tooltip-Cb_FKxT9.js";
|
|
82
|
+
import { T as qe } from "./TranslatedFields-Ck9JTF27.js";
|
|
83
|
+
import { T as ze } from "./Typography-Cta6Rg4L.js";
|
|
84
|
+
import { U as Ve } from "./UserCard-0ZF29bkK.js";
|
|
85
|
+
import { t as Xe } from "./toastStore-Cx_JOKwS.js";
|
|
84
86
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
po as Accordion,
|
|
88
|
+
mo as AccordionItem,
|
|
89
|
+
ro as AdminRoot,
|
|
90
|
+
xo as Alert,
|
|
88
91
|
X as AuthGuard,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
uo as AuthLayout,
|
|
93
|
+
lo as Avatar,
|
|
94
|
+
co as AvatarGroup,
|
|
95
|
+
Co as BREAKPOINTS,
|
|
96
|
+
Fo as BREAKPOINT_ORDER,
|
|
97
|
+
Do as Badge,
|
|
98
|
+
Eo as Blockquote,
|
|
99
|
+
bo as Breadcrumbs,
|
|
100
|
+
ho as Button,
|
|
101
|
+
No as Card,
|
|
102
|
+
Io as Checkbox,
|
|
103
|
+
ko as Chip,
|
|
104
|
+
Ko as ChoiceCard,
|
|
105
|
+
Qo as ChoiceCardGroup,
|
|
106
|
+
vo as Code,
|
|
107
|
+
Yo as CodeBlock,
|
|
108
|
+
jo as Col,
|
|
109
|
+
zo as ColorPicker,
|
|
107
110
|
F as ConfigProvider,
|
|
108
|
-
|
|
111
|
+
Vo as CopyButton,
|
|
109
112
|
S as DEFAULT_FONT_FAMILY,
|
|
110
113
|
g as DEFAULT_NESTED_TAB_QUERY_KEY,
|
|
111
114
|
y as DEFAULT_STEP_QUERY_KEY,
|
|
112
115
|
D as DEFAULT_TABS_QUERY_KEY,
|
|
113
116
|
G as DEFAULT_TRANSLATIONS_NAMESPACE,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
Xo as DashedButton,
|
|
118
|
+
$o as DatePicker,
|
|
119
|
+
rr as DateTimePicker,
|
|
120
|
+
ar as Divider,
|
|
121
|
+
tr as Dropdown,
|
|
122
|
+
mr as EmptyState,
|
|
123
|
+
xr as FileCard,
|
|
124
|
+
ur as FileUploader,
|
|
125
|
+
lr as FirstRouteRedirect,
|
|
126
|
+
cr as Flag,
|
|
127
|
+
Cr as Flex,
|
|
125
128
|
e as Form,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
129
|
+
Sr as FullscreenToggle,
|
|
130
|
+
yr as Grid,
|
|
131
|
+
Rr as ICON_COUNT,
|
|
132
|
+
Er as ICON_NAMES,
|
|
133
|
+
ao as Icon,
|
|
134
|
+
br as IconButton,
|
|
135
|
+
hr as List,
|
|
136
|
+
Nr as ListItem,
|
|
137
|
+
Ir as Loader,
|
|
138
|
+
kr as Masonry,
|
|
139
|
+
Kr as Modal,
|
|
140
|
+
Or as MultiSelect,
|
|
141
|
+
Gr as MultilineTextField,
|
|
142
|
+
wr as NumberField,
|
|
143
|
+
qr as OtpField,
|
|
144
|
+
zr as PageLayout,
|
|
145
|
+
Vr as PageNotFound,
|
|
146
|
+
Xr as Pagination,
|
|
147
|
+
$r as Popover,
|
|
148
|
+
re as Radio,
|
|
149
|
+
ee as RadioGroup,
|
|
150
|
+
se as RemoveDialog,
|
|
151
|
+
pe as RichTextEditor,
|
|
152
|
+
fe as RootLayout,
|
|
153
|
+
qo as Row,
|
|
154
|
+
ie as Select,
|
|
155
|
+
nr as Sidebar,
|
|
156
|
+
Te as Slider,
|
|
157
|
+
ne as SpeedDial,
|
|
158
|
+
de as SpeedDialAction,
|
|
159
|
+
Ae as Stepper,
|
|
160
|
+
Fe as SwatchPicker,
|
|
161
|
+
ge as Switch,
|
|
162
|
+
De as Table,
|
|
163
|
+
Ee as Tabs,
|
|
164
|
+
be as TagsField,
|
|
165
|
+
he as TextField,
|
|
166
|
+
Ne as ThemeToggle,
|
|
167
|
+
Ie as TimePicker,
|
|
168
|
+
ke as Timeline,
|
|
169
|
+
Ue as TimelineItem,
|
|
170
|
+
Qe as Toaster,
|
|
171
|
+
ve as ToggleButton,
|
|
172
|
+
Ge as ToggleButtonGroup,
|
|
173
|
+
we as Tooltip,
|
|
174
|
+
qe as TranslatedFields,
|
|
175
|
+
ze as Typography,
|
|
176
|
+
Ve as UserCard,
|
|
177
|
+
R as applyTheme,
|
|
178
|
+
$ as authLayoutRoute,
|
|
179
|
+
So as breakpointQuery,
|
|
177
180
|
J as buildTableQuery,
|
|
178
181
|
Y as buildTranslationName,
|
|
179
182
|
w as buildTranslations,
|
|
@@ -183,19 +186,19 @@ export {
|
|
|
183
186
|
j as flattenTranslations,
|
|
184
187
|
n as getAccessKeys,
|
|
185
188
|
d as hasAccess,
|
|
186
|
-
|
|
189
|
+
so as icons,
|
|
187
190
|
q as nestTranslations,
|
|
188
191
|
V as parseTableQuery,
|
|
189
|
-
|
|
192
|
+
go as resolveResponsive,
|
|
190
193
|
c as setAccessKeys,
|
|
191
194
|
H as toFormData,
|
|
192
|
-
|
|
195
|
+
Xe as toast,
|
|
193
196
|
A as useAccessKeys,
|
|
194
197
|
x as useBreakpointMatches,
|
|
195
198
|
T as useClipboard,
|
|
196
199
|
s as useDisclosure,
|
|
197
200
|
t as useForm,
|
|
198
|
-
|
|
201
|
+
E as useHeaderConfig,
|
|
199
202
|
B as useLanguage,
|
|
200
203
|
b as useLocales,
|
|
201
204
|
m as useLockBodyScroll,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techzyapp/ui-library",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Techzy UI — reusable React component library for admin panels.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -107,6 +107,16 @@
|
|
|
107
107
|
"default": "./dist/entries/auth.cjs"
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
+
"./app": {
|
|
111
|
+
"import": {
|
|
112
|
+
"types": "./dist/entries/app.d.ts",
|
|
113
|
+
"default": "./dist/entries/app.js"
|
|
114
|
+
},
|
|
115
|
+
"require": {
|
|
116
|
+
"types": "./dist/entries/app.d.cts",
|
|
117
|
+
"default": "./dist/entries/app.cjs"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
110
120
|
"./css/reset.css": "./dist/reset.css",
|
|
111
121
|
"./css/styles.css": "./dist/index.css",
|
|
112
122
|
"./package.json": "./package.json"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),r=require("@tanstack/react-router"),n=({isAuthenticated:t,redirectTo:o="/login",children:u})=>(typeof t=="function"?t():t)?e.jsx(e.Fragment,{children:u}):e.jsx(r.Navigate,{to:o}),a=({isAuthenticated:t,redirectTo:o="/"})=>({beforeLoad:()=>{if(t())throw r.redirect({to:o})},component:r.Outlet});exports.AuthGuard=n;exports.authLayoutRoute=a;
|
|
2
|
-
//# sourceMappingURL=authLayoutRoute-CkR9IANN.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authLayoutRoute-CkR9IANN.cjs","sources":["../src/auth/AuthGuard.tsx","../src/auth/authLayoutRoute.ts"],"sourcesContent":["import { Navigate, type LinkProps } from '@tanstack/react-router'\nimport type { ReactNode } from 'react'\n\nexport interface AuthGuardProps {\n /** Session check — a boolean, or a function that returns one (evaluated on render). */\n isAuthenticated: boolean | (() => boolean)\n /** Where to send an unauthenticated visitor. Defaults to `'/login'`. */\n redirectTo?: string\n /** The protected content, rendered only when authenticated. */\n children: ReactNode\n}\n\n/**\n * Component-level auth guard: renders `children` only when authenticated, otherwise redirects to\n * `redirectTo` via `<Navigate>`. Wrap the authenticated area (a page or a subtree) with it.\n *\n * Requires a `@tanstack/react-router` context (it renders `<Navigate>`), so use it inside a routed\n * tree. `redirectTo` is a plain string — the library can't know the app's typed route tree, so it's\n * cast loosely to the router's `to` type.\n *\n * @example\n * <AuthGuard isAuthenticated={session.isAuthenticated} redirectTo=\"/login\">\n * <Dashboard />\n * </AuthGuard>\n */\nexport const AuthGuard = ({ isAuthenticated, redirectTo = '/login', children }: AuthGuardProps) => {\n const ok = typeof isAuthenticated === 'function' ? isAuthenticated() : isAuthenticated\n return ok ? <>{children}</> : <Navigate to={redirectTo as LinkProps['to']} />\n}\n","import { Outlet, redirect, type LinkProps } from '@tanstack/react-router'\n\nexport interface AuthLayoutRouteOptions {\n /** Session check — returns whether the visitor is already signed in. */\n isAuthenticated: () => boolean\n /** Where to send an **already signed-in** visitor. Defaults to `'/'`. */\n redirectTo?: string\n}\n\n/**\n * Route options for the pathless `_auth` layout that groups the public auth pages (login,\n * forgot-password, reset-password, otp, …). In `beforeLoad` it bounces an already signed-in visitor to\n * `redirectTo`; otherwise it renders its children standalone (`component: Outlet`).\n *\n * Returns only the route **options** (`beforeLoad` + `component`) — not a whole route — because the\n * router plugin needs the literal path in the file. Compose it with `createFileRoute('/_auth')`.\n * `redirectTo` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree).\n *\n * @example\n * // routes/_auth.tsx\n * export const Route = createFileRoute('/_auth')(\n * authLayoutRoute({ isAuthenticated: session.isAuthenticated }),\n * )\n */\nexport const authLayoutRoute = ({ isAuthenticated, redirectTo = '/' }: AuthLayoutRouteOptions) => ({\n beforeLoad: () => {\n if (isAuthenticated()) throw redirect({ to: redirectTo as LinkProps['to'] })\n },\n component: Outlet,\n})\n"],"names":["AuthGuard","isAuthenticated","redirectTo","children","jsx","Fragment","Navigate","authLayoutRoute","redirect","Outlet"],"mappings":"sFAyBaA,EAAY,CAAC,CAAE,gBAAAC,EAAiB,WAAAC,EAAa,SAAU,SAAAC,MACvD,OAAOF,GAAoB,WAAaA,IAAoBA,GAC3DG,EAAAA,IAAAC,EAAAA,SAAA,CAAG,SAAAF,CAAA,CAAS,EAAMC,EAAAA,IAACE,EAAAA,SAAA,CAAS,GAAIJ,CAAA,CAA+B,ECFhEK,EAAkB,CAAC,CAAE,gBAAAN,EAAiB,WAAAC,EAAa,QAAmC,CACjG,WAAY,IAAM,CAChB,GAAID,IAAmB,MAAMO,EAAAA,SAAS,CAAE,GAAIN,EAA+B,CAC7E,EACA,UAAWO,EAAAA,MACb"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as r, Fragment as e } from "react/jsx-runtime";
|
|
2
|
-
import { Navigate as n, Outlet as f, redirect as m } from "@tanstack/react-router";
|
|
3
|
-
const s = ({ isAuthenticated: o, redirectTo: t = "/login", children: a }) => (typeof o == "function" ? o() : o) ? /* @__PURE__ */ r(e, { children: a }) : /* @__PURE__ */ r(n, { to: t }), g = ({ isAuthenticated: o, redirectTo: t = "/" }) => ({
|
|
4
|
-
beforeLoad: () => {
|
|
5
|
-
if (o()) throw m({ to: t });
|
|
6
|
-
},
|
|
7
|
-
component: f
|
|
8
|
-
});
|
|
9
|
-
export {
|
|
10
|
-
s as A,
|
|
11
|
-
g as a
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=authLayoutRoute-DEYvuYxM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authLayoutRoute-DEYvuYxM.js","sources":["../src/auth/AuthGuard.tsx","../src/auth/authLayoutRoute.ts"],"sourcesContent":["import { Navigate, type LinkProps } from '@tanstack/react-router'\nimport type { ReactNode } from 'react'\n\nexport interface AuthGuardProps {\n /** Session check — a boolean, or a function that returns one (evaluated on render). */\n isAuthenticated: boolean | (() => boolean)\n /** Where to send an unauthenticated visitor. Defaults to `'/login'`. */\n redirectTo?: string\n /** The protected content, rendered only when authenticated. */\n children: ReactNode\n}\n\n/**\n * Component-level auth guard: renders `children` only when authenticated, otherwise redirects to\n * `redirectTo` via `<Navigate>`. Wrap the authenticated area (a page or a subtree) with it.\n *\n * Requires a `@tanstack/react-router` context (it renders `<Navigate>`), so use it inside a routed\n * tree. `redirectTo` is a plain string — the library can't know the app's typed route tree, so it's\n * cast loosely to the router's `to` type.\n *\n * @example\n * <AuthGuard isAuthenticated={session.isAuthenticated} redirectTo=\"/login\">\n * <Dashboard />\n * </AuthGuard>\n */\nexport const AuthGuard = ({ isAuthenticated, redirectTo = '/login', children }: AuthGuardProps) => {\n const ok = typeof isAuthenticated === 'function' ? isAuthenticated() : isAuthenticated\n return ok ? <>{children}</> : <Navigate to={redirectTo as LinkProps['to']} />\n}\n","import { Outlet, redirect, type LinkProps } from '@tanstack/react-router'\n\nexport interface AuthLayoutRouteOptions {\n /** Session check — returns whether the visitor is already signed in. */\n isAuthenticated: () => boolean\n /** Where to send an **already signed-in** visitor. Defaults to `'/'`. */\n redirectTo?: string\n}\n\n/**\n * Route options for the pathless `_auth` layout that groups the public auth pages (login,\n * forgot-password, reset-password, otp, …). In `beforeLoad` it bounces an already signed-in visitor to\n * `redirectTo`; otherwise it renders its children standalone (`component: Outlet`).\n *\n * Returns only the route **options** (`beforeLoad` + `component`) — not a whole route — because the\n * router plugin needs the literal path in the file. Compose it with `createFileRoute('/_auth')`.\n * `redirectTo` is a plain string, cast loosely to the router's `to` type (the library can't know the\n * app's typed route tree).\n *\n * @example\n * // routes/_auth.tsx\n * export const Route = createFileRoute('/_auth')(\n * authLayoutRoute({ isAuthenticated: session.isAuthenticated }),\n * )\n */\nexport const authLayoutRoute = ({ isAuthenticated, redirectTo = '/' }: AuthLayoutRouteOptions) => ({\n beforeLoad: () => {\n if (isAuthenticated()) throw redirect({ to: redirectTo as LinkProps['to'] })\n },\n component: Outlet,\n})\n"],"names":["AuthGuard","isAuthenticated","redirectTo","children","jsx","Fragment","Navigate","authLayoutRoute","redirect","Outlet"],"mappings":";;AAyBO,MAAMA,IAAY,CAAC,EAAE,iBAAAC,GAAiB,YAAAC,IAAa,UAAU,UAAAC,SACvD,OAAOF,KAAoB,aAAaA,MAAoBA,KAC3D,gBAAAG,EAAAC,GAAA,EAAG,UAAAF,EAAA,CAAS,IAAM,gBAAAC,EAACE,GAAA,EAAS,IAAIJ,EAAA,CAA+B,GCFhEK,IAAkB,CAAC,EAAE,iBAAAN,GAAiB,YAAAC,IAAa,WAAmC;AAAA,EACjG,YAAY,MAAM;AAChB,QAAID,IAAmB,OAAMO,EAAS,EAAE,IAAIN,GAA+B;AAAA,EAC7E;AAAA,EACA,WAAWO;AACb;"}
|