@lincyaw/aegis-ui 0.18.0 → 0.20.0
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/components/ui/AnchoredPopover.cjs +1 -1
- package/dist/components/ui/AnchoredPopover.cjs.map +1 -1
- package/dist/components/ui/AnchoredPopover.d.ts +21 -1
- package/dist/components/ui/AnchoredPopover.js +106 -78
- package/dist/components/ui/AnchoredPopover.js.map +1 -1
- package/dist/components/ui/CodeBlock.cjs +2 -2
- package/dist/components/ui/CodeBlock.cjs.map +1 -1
- package/dist/components/ui/CodeBlock.d.ts +10 -1
- package/dist/components/ui/CodeBlock.js +65 -57
- package/dist/components/ui/CodeBlock.js.map +1 -1
- package/dist/components/ui/DataTable.cjs +1 -1
- package/dist/components/ui/DataTable.cjs.map +1 -1
- package/dist/components/ui/DataTable.d.ts +11 -1
- package/dist/components/ui/DataTable.js +78 -74
- package/dist/components/ui/DataTable.js.map +1 -1
- package/dist/components/ui/DetailBeside.cjs +1 -1
- package/dist/components/ui/DetailBeside.cjs.map +1 -1
- package/dist/components/ui/DetailBeside.d.ts +45 -11
- package/dist/components/ui/DetailBeside.js +118 -85
- package/dist/components/ui/DetailBeside.js.map +1 -1
- package/dist/components/ui/IdentityCell.cjs +1 -1
- package/dist/components/ui/IdentityCell.cjs.map +1 -1
- package/dist/components/ui/IdentityCell.d.ts +6 -1
- package/dist/components/ui/IdentityCell.js +17 -15
- package/dist/components/ui/IdentityCell.js.map +1 -1
- package/dist/components/ui/PaneLayout.cjs +1 -1
- package/dist/components/ui/PaneLayout.cjs.map +1 -1
- package/dist/components/ui/PaneLayout.d.ts +7 -2
- package/dist/components/ui/PaneLayout.js +20 -22
- package/dist/components/ui/PaneLayout.js.map +1 -1
- package/dist/components/ui/Select.cjs +1 -1
- package/dist/components/ui/Select.cjs.map +1 -1
- package/dist/components/ui/Select.d.ts +8 -2
- package/dist/components/ui/Select.js +44 -38
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/components/ui/TimeDisplay.cjs +1 -1
- package/dist/components/ui/TimeDisplay.cjs.map +1 -1
- package/dist/components/ui/TimeDisplay.d.ts +11 -3
- package/dist/components/ui/TimeDisplay.js +39 -34
- package/dist/components/ui/TimeDisplay.js.map +1 -1
- package/dist/components/ui/Timeline.cjs +1 -1
- package/dist/components/ui/Timeline.cjs.map +1 -1
- package/dist/components/ui/Timeline.d.ts +17 -4
- package/dist/components/ui/Timeline.js +88 -67
- package/dist/components/ui/Timeline.js.map +1 -1
- package/dist/components/ui/Toolbar.cjs.map +1 -1
- package/dist/components/ui/Toolbar.d.ts +2 -1
- package/dist/components/ui/Toolbar.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.d.ts +7 -1
- package/dist/components/ui/TraceTree.js +127 -119
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/linkComponent.cjs +1 -1
- package/dist/components/ui/linkComponent.cjs.map +1 -1
- package/dist/components/ui/linkComponent.d.ts +6 -4
- package/dist/components/ui/linkComponent.js +12 -10
- package/dist/components/ui/linkComponent.js.map +1 -1
- package/dist/layouts/shell/AegisShell.cjs +1 -1
- package/dist/layouts/shell/AegisShell.cjs.map +1 -1
- package/dist/layouts/shell/AegisShell.js +24 -24
- package/dist/layouts/shell/AegisShell.js.map +1 -1
- package/dist/layouts/shell/RouterLink.cjs +1 -1
- package/dist/layouts/shell/RouterLink.cjs.map +1 -1
- package/dist/layouts/shell/RouterLink.js +14 -12
- package/dist/layouts/shell/RouterLink.js.map +1 -1
- package/dist/layouts/shell/types.d.ts +6 -0
- package/dist/lib/scrollView.cjs +1 -1
- package/dist/lib/scrollView.cjs.map +1 -1
- package/dist/lib/scrollView.d.ts +6 -0
- package/dist/lib/scrollView.js +26 -17
- package/dist/lib/scrollView.js.map +1 -1
- package/dist/locale/strings.cjs +1 -1
- package/dist/locale/strings.cjs.map +1 -1
- package/dist/locale/strings.d.ts +2 -0
- package/dist/locale/strings.js +7 -5
- package/dist/locale/strings.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -3,14 +3,16 @@ import { ComponentType, ReactNode } from 'react';
|
|
|
3
3
|
* Router link adapter for primitives that render links. Routed apps pass a
|
|
4
4
|
* wrapper around their router's `<Link>`; without one the primitive renders
|
|
5
5
|
* a plain `<a href>`, so primitives stay router-agnostic. Pass
|
|
6
|
-
* `aria-current` and `tabIndex` on to the anchor: navigation
|
|
7
|
-
* mark the current page with the first,
|
|
8
|
-
*
|
|
6
|
+
* `aria-current`, `aria-label` and `tabIndex` on to the anchor: navigation
|
|
7
|
+
* primitives mark the current page or item with the first, a link whose
|
|
8
|
+
* text is short names itself in full with the second, and a tree keeps the
|
|
9
|
+
* links in its rows out of the tab order with the third.
|
|
9
10
|
*/
|
|
10
11
|
export type LinkComponent = ComponentType<{
|
|
11
12
|
to: string;
|
|
12
13
|
className?: string;
|
|
13
|
-
'aria-current'?: 'page';
|
|
14
|
+
'aria-current'?: 'page' | 'true';
|
|
15
|
+
'aria-label'?: string;
|
|
14
16
|
tabIndex?: number;
|
|
15
17
|
children: ReactNode;
|
|
16
18
|
}>;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
const c = ({
|
|
3
|
-
to:
|
|
4
|
-
className:
|
|
5
|
-
"aria-current":
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
to: a,
|
|
4
|
+
className: r,
|
|
5
|
+
"aria-current": e,
|
|
6
|
+
"aria-label": i,
|
|
7
|
+
tabIndex: t,
|
|
8
|
+
children: l
|
|
8
9
|
}) => /* @__PURE__ */ n(
|
|
9
10
|
"a",
|
|
10
11
|
{
|
|
11
|
-
href:
|
|
12
|
-
className:
|
|
13
|
-
"aria-current":
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
href: a,
|
|
13
|
+
className: r,
|
|
14
|
+
"aria-current": e,
|
|
15
|
+
"aria-label": i,
|
|
16
|
+
tabIndex: t,
|
|
17
|
+
children: l
|
|
16
18
|
}
|
|
17
19
|
);
|
|
18
20
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkComponent.js","sources":["../../../src/components/ui/linkComponent.tsx"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\n\n/**\n * Router link adapter for primitives that render links. Routed apps pass a\n * wrapper around their router's `<Link>`; without one the primitive renders\n * a plain `<a href>`, so primitives stay router-agnostic. Pass\n * `aria-current` and `tabIndex` on to the anchor: navigation
|
|
1
|
+
{"version":3,"file":"linkComponent.js","sources":["../../../src/components/ui/linkComponent.tsx"],"sourcesContent":["import type { ComponentType, ReactNode } from 'react';\n\n/**\n * Router link adapter for primitives that render links. Routed apps pass a\n * wrapper around their router's `<Link>`; without one the primitive renders\n * a plain `<a href>`, so primitives stay router-agnostic. Pass\n * `aria-current`, `aria-label` and `tabIndex` on to the anchor: navigation\n * primitives mark the current page or item with the first, a link whose\n * text is short names itself in full with the second, and a tree keeps the\n * links in its rows out of the tab order with the third.\n */\nexport type LinkComponent = ComponentType<{\n to: string;\n className?: string;\n 'aria-current'?: 'page' | 'true';\n 'aria-label'?: string;\n tabIndex?: number;\n children: ReactNode;\n}>;\n\nexport const DefaultLink: LinkComponent = ({\n to,\n className,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n tabIndex,\n children,\n}) => (\n <a\n href={to}\n className={className}\n aria-current={ariaCurrent}\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n >\n {children}\n </a>\n);\n"],"names":["DefaultLink","to","className","ariaCurrent","ariaLabel","tabIndex","children","jsx"],"mappings":";AAoBO,MAAMA,IAA6B,CAAC;AAAA,EACzC,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAgBC;AAAA,EAChB,cAAcC;AAAA,EACd,UAAAC;AAAA,EACA,UAAAC;AACF,MACE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAMN;AAAA,IACN,WAAAC;AAAA,IACA,gBAAcC;AAAA,IACd,cAAYC;AAAA,IACZ,UAAAC;AAAA,IAEC,UAAAC;AAAA,EAAA;AACH;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),le=require("react-dom"),h=require("react-router-dom"),ue=require("../../components/ui/AmbientBackground.cjs"),ce=require("../../components/ui/Button.cjs"),de=require("../../hooks/useStorageItem.cjs"),ge=require("../../hooks/useWindowScrolled.cjs"),he=require("../../theme/themeContext.cjs"),me=require("../SkipLink.cjs");;/* empty css */const pe=require("./AppSwitcher.cjs"),be=require("./BreadcrumbBar.cjs"),ve=require("./RouteErrorBoundary.cjs"),xe=require("./ShellCommandPalette.cjs"),Se=require("./ShellNotificationBell.cjs"),D=require("./Sidebar.cjs"),m=require("./TopHeader.cjs"),fe=require("./activeAppContext.cjs"),j=require("./apps.cjs"),qe=require("./buildRouteTree.cjs"),Ae=require("./paths.cjs"),je=require("./shellNavContext.cjs"),Re=require("./useAgentPanel.cjs"),Ce=require("./useAppCommands.cjs"),we=require("./useMobileNav.cjs"),Be=require("./useShellUser.cjs"),Pe=require("./useWarnOnce.cjs"),Ie=require("../../locale/useStrings.cjs"),ke=require("../../auth/useAuth.cjs"),Me=require("../../commands/useCommands.cjs"),Ne=require("../../agent/core/AegisRuntimeProvider.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),le=require("react-dom"),h=require("react-router-dom"),ue=require("../../components/ui/AmbientBackground.cjs"),ce=require("../../components/ui/Button.cjs"),de=require("../../hooks/useStorageItem.cjs"),ge=require("../../hooks/useWindowScrolled.cjs"),he=require("../../theme/themeContext.cjs"),me=require("../SkipLink.cjs");;/* empty css */const pe=require("./AppSwitcher.cjs"),be=require("./BreadcrumbBar.cjs"),ve=require("./RouteErrorBoundary.cjs"),xe=require("./ShellCommandPalette.cjs"),Se=require("./ShellNotificationBell.cjs"),D=require("./Sidebar.cjs"),m=require("./TopHeader.cjs"),fe=require("./activeAppContext.cjs"),j=require("./apps.cjs"),qe=require("./buildRouteTree.cjs"),Ae=require("./paths.cjs"),je=require("./shellNavContext.cjs"),Re=require("./useAgentPanel.cjs"),Ce=require("./useAppCommands.cjs"),we=require("./useMobileNav.cjs"),Be=require("./useShellUser.cjs"),Pe=require("./useWarnOnce.cjs"),Ie=require("../../locale/useStrings.cjs"),ke=require("../../auth/useAuth.cjs"),Me=require("../../commands/useCommands.cjs"),Ne=require("../../agent/core/AegisRuntimeProvider.cjs"),_e=require("./environments/EnvironmentProvider.cjs"),Te=require("../../agent/ask/AskOverlay.cjs"),ye="aegis-shell.sidebar-collapsed";function Oe({brand:a,apps:r,rootRoutes:u=[],fallbackPath:c,notFoundElement:R,user:V,userMenu:F,headerCenter:K,headerActions:C,appSwitcher:w=!0,elevateHeaderOnScroll:z=!1,ambient:x,inboxPath:S,onAppSwitch:B,enableCommandPalette:P=!1,commandGroupOrder:Y,agentPanel:I,agentRuntime:G,chrome:J="header"}){const d=h.useLocation(),Q=h.useNavigate(),k=Ie.useStrings(),{pathname:g}=d,n=ke.useAuth(),M=o.useContext(he.ThemeContext),[X,N]=de.useStorageItem(ye),p=X==="1",[_,Z]=o.useState(null),$=ge.useWindowScrolled(),ee=z&&$,T=o.useRef(null),f=Be.useShellUser(V,F,n),q=o.useMemo(()=>r.filter(v=>j.isAppVisible(v,n.status,n.user)),[r,n.status,n.user]),s=o.useMemo(()=>j.findActiveApp(r,g),[r,g]),se=o.useMemo(()=>s?{id:s.id,basePath:Ae.normalizeBasePath(s.basePath)}:null,[s]);o.useEffect(()=>{j.assertUniqueBasePaths(r)},[r]),Ce.useAppCommands(q,s?.id);const y=Me.useHasCommandProvider();Pe.useWarnOnce(P&&!y,"AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted.");const i=Re.useAgentPanel(I),t=we.useMobileNav(g),l=(s?.chrome??J)==="sidebar",te=o.useMemo(()=>l?{open:t.open,toggle:t.toggle,toggleRef:t.toggleRef}:null,[l,t.open,t.toggle,t.toggleRef]),ne=o.useCallback(()=>{N(p?"0":"1")},[N,p]),A=o.useMemo(()=>qe.buildRouteTree({apps:r,rootRoutes:u,fallbackPath:c,notFoundElement:R,auth:n}),[r,u,c,R,n]),re=h.useRoutes(A.routes),O=h.matchRoutes(A.routes,d),E=O?O[0].route:void 0,H=e.jsx(ve.RouteErrorBoundary,{resetKey:d.key,children:re}),W=h.useHref("/"),L=W.startsWith("/")?W.replace(/\/+$/,""):void 0,oe=o.useCallback(()=>{const v=typeof window<"u"?window:null;return{currentAppId:s?.id??null,route:{pathname:g,search:d.search,params:{},basename:L},breadcrumbs:[],theme:M?.resolved??"light",viewport:{width:v?.innerWidth??0,height:v?.innerHeight??0}}},[s,g,d.search,L,M]);if(E&&A.bareRoutes.has(E))return e.jsx("div",{children:H});const b=!!(s?.sidebar&&s.sidebar.length>0),ie=l||b&&!p,U=n.status==="unauthenticated"&&n.signIn&&e.jsx(ce.Button,{onClick:()=>{n.signIn?.({})},children:k.signIn}),ae=["aegis-shell",l?"aegis-shell--chrome-sidebar":"",ie?"aegis-shell--with-sidebar":"aegis-shell--no-sidebar",t.open?"aegis-shell--mobile-nav-open":"",i.open?"aegis-shell--with-agent-panel":"",x?"aegis-shell--ambient":""].filter(Boolean).join(" ");return e.jsx(Ne.AegisRuntimeProvider,{runtime:G,appId:s?.id??null,shellSnapshot:oe,navigate:Q,children:e.jsx(_e.EnvironmentProvider,{app:s,children:e.jsxs("div",{ref:t.shellRef,className:ae,children:[e.jsx(me.SkipLink,{targetId:"aegis-main",targetRef:T}),x&&e.jsx(ue.AmbientBackground,{variant:x}),!l&&e.jsx(m.TopHeader,{brand:a,apps:q,activeAppId:s?.id,onAppSwitch:B,appSwitcher:w,scrolled:ee,user:f,headerCenter:K,headerActions:e.jsxs(e.Fragment,{children:[C,U]}),inboxPath:n.status==="authenticated"?S:void 0,onMobileMenuToggle:t.toggle,mobileMenuOpen:t.open,menuToggleRef:t.toggleRef,showMobileMenu:b,sidebarCollapsible:b,sidebarCollapsed:p,onSidebarToggle:ne,inlineSlotRef:Z,inlineSlotActive:!!s?.header,agentPanelOpen:i.open,onAgentPanelToggle:i.toggle}),l?e.jsx(D.Sidebar,{activeApp:s,drawerRef:t.drawerRef,top:e.jsxs(e.Fragment,{children:[w?e.jsx(pe.AppSwitcher,{apps:q,activeAppId:s?.id,onAppSwitch:B}):null,e.jsx(m.ShellBrand,{brand:a})]}),footer:e.jsxs(e.Fragment,{children:[e.jsx(m.ActiveEnvironmentSwitcher,{}),C,U,n.status==="authenticated"&&S&&e.jsx(Se.ShellNotificationBell,{inboxPath:S}),f&&e.jsx(m.UserMenu,{user:f,align:"left"}),i.toggle&&e.jsx(m.AgentPanelToggle,{open:i.open,onToggle:i.toggle})]})}):b&&e.jsx(D.Sidebar,{activeApp:s,drawerRef:t.drawerRef}),e.jsx("button",{ref:t.backdropRef,type:"button",className:"aegis-shell__backdrop","aria-label":k.closeNavigation,tabIndex:-1,onClick:t.dismiss}),e.jsx("main",{id:"aegis-main",ref:T,tabIndex:-1,className:s?.bleed===!0?"aegis-shell__main aegis-shell__main--bleed":"aegis-shell__main",children:Ee(s,se,e.jsxs(je.ShellNavContext.Provider,{value:te,children:[s?.header&&_&&le.createPortal(s.header,_),s?.breadcrumbBar!==!1&&e.jsx(be.BreadcrumbBar,{activeApp:s}),e.jsx("div",{className:"aegis-shell__content",children:H})]}))}),i.open&&e.jsx("div",{className:"aegis-shell__agent-panel",children:I}),e.jsx(Te.AskOverlay,{}),P&&y&&e.jsx(xe.ShellCommandPalette,{groupOrder:Y})]})})})}function Ee(a,r,u){if(!a||!r)return u;const c=e.jsx(fe.ActiveAppContext.Provider,{value:r,children:u});return a.wrap?e.jsx(e.Fragment,{children:a.wrap(c)}):c}exports.AegisShell=Oe;
|
|
2
2
|
//# sourceMappingURL=AegisShell.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisShell.cjs","sources":["../../../src/layouts/shell/AegisShell.tsx"],"sourcesContent":["import {\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n matchRoutes,\n useHref,\n useLocation,\n useNavigate,\n useRoutes,\n} from 'react-router-dom';\n\nimport {\n AegisRuntimeProvider,\n AskOverlay,\n type ShellSnapshot,\n} from '../../agent';\nimport { useAuth } from '../../auth';\nimport { useHasCommandProvider } from '../../commands';\nimport { AmbientBackground } from '../../components/ui/AmbientBackground';\nimport { Button } from '../../components/ui/Button';\nimport { useStorageItem } from '../../hooks/useStorageItem';\nimport { useWindowScrolled } from '../../hooks/useWindowScrolled';\nimport { useStrings } from '../../locale';\nimport { ThemeContext } from '../../theme/themeContext';\nimport { SkipLink } from '../SkipLink';\nimport './AegisShell.css';\nimport { AppSwitcher } from './AppSwitcher';\nimport { BreadcrumbBar } from './BreadcrumbBar';\nimport { RouteErrorBoundary } from './RouteErrorBoundary';\nimport { ShellCommandPalette } from './ShellCommandPalette';\nimport { ShellNotificationBell } from './ShellNotificationBell';\nimport { Sidebar } from './Sidebar';\nimport {\n ActiveEnvironmentSwitcher,\n AgentPanelToggle,\n ShellBrand,\n TopHeader,\n UserMenu,\n} from './TopHeader';\nimport { ActiveAppContext } from './activeAppContext';\nimport { assertUniqueBasePaths, findActiveApp, isAppVisible } from './apps';\nimport { buildRouteTree } from './buildRouteTree';\nimport { EnvironmentProvider } from './environments';\nimport { normalizeBasePath } from './paths';\nimport { ShellNavContext, type ShellNavContextValue } from './shellNavContext';\nimport type { AegisApp, AegisShellProps } from './types';\nimport { useAgentPanel } from './useAgentPanel';\nimport { useAppCommands } from './useAppCommands';\nimport { useMobileNav } from './useMobileNav';\nimport { useShellUser } from './useShellUser';\nimport { useWarnOnce } from './useWarnOnce';\n\nconst SIDEBAR_COLLAPSED_KEY = 'aegis-shell.sidebar-collapsed';\n\n/**\n * Top-level layout: top header, two-section sidebar, breadcrumb bar, and\n * a routed content area composed from `apps`.\n *\n * Each app's `routes` is mounted under its `basePath`. The shell renders\n * the chrome around every app — apps themselves only render page content\n * inside a `<PageWrapper>` (the shell wraps the outlet automatically). A\n * page that throws while rendering shows an error with a retry in the page\n * area; the chrome stays up.\n */\nexport function AegisShell({\n brand,\n apps,\n rootRoutes = [],\n fallbackPath,\n notFoundElement,\n user,\n userMenu,\n headerCenter,\n headerActions,\n appSwitcher = true,\n elevateHeaderOnScroll = false,\n ambient,\n inboxPath,\n onAppSwitch,\n enableCommandPalette = false,\n commandGroupOrder,\n agentPanel,\n agentRuntime,\n chrome = 'header',\n}: AegisShellProps): ReactElement {\n const location = useLocation();\n const navigate = useNavigate();\n const strings = useStrings();\n const { pathname } = location;\n const auth = useAuth();\n const themeCtx = useContext(ThemeContext);\n const [sidebarCollapsedValue, setSidebarCollapsedValue] = useStorageItem(\n SIDEBAR_COLLAPSED_KEY,\n );\n const sidebarCollapsed = sidebarCollapsedValue === '1';\n const [inlineSlot, setInlineSlot] = useState<HTMLDivElement | null>(null);\n const windowScrolled = useWindowScrolled();\n const headerScrolled = elevateHeaderOnScroll && windowScrolled;\n const mainRef = useRef<HTMLElement>(null);\n\n const resolvedUser = useShellUser(user, userMenu, auth);\n\n const visibleApps = useMemo(\n () => apps.filter((app) => isAppVisible(app, auth.status, auth.user)),\n [apps, auth.status, auth.user],\n );\n\n const activeApp = useMemo(\n () => findActiveApp(apps, pathname),\n [apps, pathname],\n );\n\n const activeAppValue = useMemo(\n () =>\n activeApp\n ? { id: activeApp.id, basePath: normalizeBasePath(activeApp.basePath) }\n : null,\n [activeApp],\n );\n\n useEffect(() => {\n assertUniqueBasePaths(apps);\n }, [apps]);\n\n useAppCommands(visibleApps, activeApp?.id);\n const hasCommandProvider = useHasCommandProvider();\n useWarnOnce(\n enableCommandPalette && !hasCommandProvider,\n 'AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted.',\n );\n\n const agent = useAgentPanel(agentPanel);\n const mobileNav = useMobileNav(pathname);\n\n const sidebarChrome = (activeApp?.chrome ?? chrome) === 'sidebar';\n const navValue = useMemo<ShellNavContextValue | null>(\n () =>\n sidebarChrome\n ? {\n open: mobileNav.open,\n toggle: mobileNav.toggle,\n toggleRef: mobileNav.toggleRef,\n }\n : null,\n [sidebarChrome, mobileNav.open, mobileNav.toggle, mobileNav.toggleRef],\n );\n\n const toggleSidebar = useCallback(() => {\n setSidebarCollapsedValue(sidebarCollapsed ? '0' : '1');\n }, [setSidebarCollapsedValue, sidebarCollapsed]);\n\n const routeTree = useMemo(\n () =>\n buildRouteTree({ apps, rootRoutes, fallbackPath, notFoundElement, auth }),\n [apps, rootRoutes, fallbackPath, notFoundElement, auth],\n );\n const element = useRoutes(routeTree.routes);\n const matches = matchRoutes(routeTree.routes, location);\n const topRoute = matches ? matches[0].route : undefined;\n const page = (\n <RouteErrorBoundary resetKey={location.key}>{element}</RouteErrorBoundary>\n );\n\n const rootHref = useHref('/');\n // A hash router's href is not a path prefix, so it reports none.\n const basename = rootHref.startsWith('/')\n ? rootHref.replace(/\\/+$/, '')\n : undefined;\n\n const shellSnapshot = useCallback((): ShellSnapshot => {\n const w = typeof window !== 'undefined' ? window : null;\n return {\n currentAppId: activeApp?.id ?? null,\n route: {\n pathname,\n search: location.search,\n params: {},\n basename,\n },\n breadcrumbs: [],\n theme: themeCtx?.resolved ?? 'light',\n viewport: {\n width: w?.innerWidth ?? 0,\n height: w?.innerHeight ?? 0,\n },\n };\n }, [activeApp, pathname, location.search, basename, themeCtx]);\n\n // Bare routes (e.g. /login) render without the shell chrome.\n if (topRoute && routeTree.bareRoutes.has(topRoute)) {\n return <div>{page}</div>;\n }\n\n const appHasSidebar = Boolean(\n activeApp?.sidebar && activeApp.sidebar.length > 0,\n );\n const hasSidebar = sidebarChrome || (appHasSidebar && !sidebarCollapsed);\n\n const signInButton = auth.status === 'unauthenticated' && auth.signIn && (\n <Button\n onClick={() => {\n void auth.signIn?.({});\n }}\n >\n {strings.signIn}\n </Button>\n );\n\n const shellClass = [\n 'aegis-shell',\n sidebarChrome ? 'aegis-shell--chrome-sidebar' : '',\n hasSidebar ? 'aegis-shell--with-sidebar' : 'aegis-shell--no-sidebar',\n mobileNav.open ? 'aegis-shell--mobile-nav-open' : '',\n agent.open ? 'aegis-shell--with-agent-panel' : '',\n ambient ? 'aegis-shell--ambient' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <AegisRuntimeProvider\n runtime={agentRuntime}\n appId={activeApp?.id ?? null}\n shellSnapshot={shellSnapshot}\n navigate={navigate}\n >\n <EnvironmentProvider app={activeApp}>\n <div ref={mobileNav.shellRef} className={shellClass}>\n <SkipLink targetId=\"aegis-main\" targetRef={mainRef} />\n {ambient && <AmbientBackground variant={ambient} />}\n {!sidebarChrome && (\n <TopHeader\n brand={brand}\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n appSwitcher={appSwitcher}\n scrolled={headerScrolled}\n user={resolvedUser}\n headerCenter={headerCenter}\n headerActions={\n <>\n {headerActions}\n {signInButton}\n </>\n }\n inboxPath={\n auth.status === 'authenticated' ? inboxPath : undefined\n }\n onMobileMenuToggle={mobileNav.toggle}\n mobileMenuOpen={mobileNav.open}\n menuToggleRef={mobileNav.toggleRef}\n showMobileMenu={appHasSidebar}\n sidebarCollapsible={appHasSidebar}\n sidebarCollapsed={sidebarCollapsed}\n onSidebarToggle={toggleSidebar}\n inlineSlotRef={setInlineSlot}\n inlineSlotActive={Boolean(activeApp?.header)}\n agentPanelOpen={agent.open}\n onAgentPanelToggle={agent.toggle}\n />\n )}\n {sidebarChrome ? (\n <Sidebar\n activeApp={activeApp}\n drawerRef={mobileNav.drawerRef}\n top={\n <>\n {appSwitcher ? (\n <AppSwitcher\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n />\n ) : null}\n <ShellBrand brand={brand} />\n </>\n }\n footer={\n <>\n <ActiveEnvironmentSwitcher />\n {headerActions}\n {signInButton}\n {auth.status === 'authenticated' && inboxPath && (\n <ShellNotificationBell inboxPath={inboxPath} />\n )}\n {resolvedUser && (\n <UserMenu user={resolvedUser} align=\"left\" />\n )}\n {agent.toggle && (\n <AgentPanelToggle\n open={agent.open}\n onToggle={agent.toggle}\n />\n )}\n </>\n }\n />\n ) : (\n appHasSidebar && (\n <Sidebar activeApp={activeApp} drawerRef={mobileNav.drawerRef} />\n )\n )}\n <button\n ref={mobileNav.backdropRef}\n type=\"button\"\n className=\"aegis-shell__backdrop\"\n aria-label={strings.closeNavigation}\n tabIndex={-1}\n onClick={mobileNav.dismiss}\n />\n <main\n id=\"aegis-main\"\n ref={mainRef}\n tabIndex={-1}\n className=\"aegis-shell__main\"\n >\n {renderAppRegion(\n activeApp,\n activeAppValue,\n <ShellNavContext.Provider value={navValue}>\n {activeApp?.header &&\n inlineSlot &&\n createPortal(activeApp.header, inlineSlot)}\n {activeApp?.breadcrumbBar !== false && (\n <BreadcrumbBar activeApp={activeApp} />\n )}\n <div className=\"aegis-shell__content\">{page}</div>\n </ShellNavContext.Provider>,\n )}\n </main>\n {agent.open && (\n <div className=\"aegis-shell__agent-panel\">{agentPanel}</div>\n )}\n <AskOverlay />\n {enableCommandPalette && hasCommandProvider && (\n <ShellCommandPalette groupOrder={commandGroupOrder} />\n )}\n </div>\n </EnvironmentProvider>\n </AegisRuntimeProvider>\n );\n}\n\nfunction renderAppRegion(\n app: AegisApp | undefined,\n appValue: { id: string; basePath: string } | null,\n children: ReactElement,\n): ReactElement {\n if (!app || !appValue) {\n return children;\n }\n const inner = (\n <ActiveAppContext.Provider value={appValue}>\n {children}\n </ActiveAppContext.Provider>\n );\n return app.wrap ? <>{app.wrap(inner)}</> : inner;\n}\n"],"names":["SIDEBAR_COLLAPSED_KEY","AegisShell","brand","apps","rootRoutes","fallbackPath","notFoundElement","user","userMenu","headerCenter","headerActions","appSwitcher","elevateHeaderOnScroll","ambient","inboxPath","onAppSwitch","enableCommandPalette","commandGroupOrder","agentPanel","agentRuntime","chrome","location","useLocation","navigate","useNavigate","strings","useStrings","pathname","auth","useAuth","themeCtx","useContext","ThemeContext","sidebarCollapsedValue","setSidebarCollapsedValue","useStorageItem","sidebarCollapsed","inlineSlot","setInlineSlot","useState","windowScrolled","useWindowScrolled","headerScrolled","mainRef","useRef","resolvedUser","useShellUser","visibleApps","useMemo","app","isAppVisible","activeApp","findActiveApp","activeAppValue","normalizeBasePath","useEffect","assertUniqueBasePaths","useAppCommands","hasCommandProvider","useHasCommandProvider","useWarnOnce","agent","useAgentPanel","mobileNav","useMobileNav","sidebarChrome","navValue","toggleSidebar","useCallback","routeTree","buildRouteTree","element","useRoutes","matches","matchRoutes","topRoute","page","jsx","RouteErrorBoundary","rootHref","useHref","basename","shellSnapshot","w","appHasSidebar","hasSidebar","signInButton","Button","shellClass","AegisRuntimeProvider","EnvironmentProvider","jsxs","SkipLink","AmbientBackground","TopHeader","Fragment","Sidebar","AppSwitcher","ShellBrand","ActiveEnvironmentSwitcher","ShellNotificationBell","UserMenu","AgentPanelToggle","renderAppRegion","ShellNavContext","createPortal","BreadcrumbBar","AskOverlay","ShellCommandPalette","appValue","children","inner","ActiveAppContext"],"mappings":"6zCA6DMA,GAAwB,gCAYvB,SAASC,GAAW,CACzB,MAAAC,EAAA,KACAC,EACA,WAAAC,EAAa,CAAA,EACb,aAAAC,EACA,gBAAAC,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,cAAAC,EACA,YAAAC,EAAc,GACd,sBAAAC,EAAwB,GACxB,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,qBAAAC,EAAuB,GACvB,kBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EAAS,QACX,EAAkC,CAChC,MAAMC,EAAWC,EA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B,EAAAA,IAAC6B,GAAAA,eAAc,UAAAvD,EAAsB,EAEvC0B,EAAAA,IAAC,MAAA,CAAI,UAAU,uBAAwB,SAAAD,CAAA,CAAK,CAAA,CAAA,CAC9C,CAAA,CACF,CAAA,EAEDf,EAAM,MACLgB,EAAAA,IAAC,MAAA,CAAI,UAAU,2BAA4B,SAAA3D,EAAW,QAEvDyF,GAAAA,WAAA,EAAW,EACX3F,GAAwB0C,GACvBmB,EAAAA,IAAC+B,GAAAA,oBAAA,CAAoB,WAAY3F,CAAA,CAAmB,CAAA,CAAA,CAExD,CAAA,CACF,CAAA,CAAA,CAGN,CAEA,SAASsF,GACPtD,EACA4D,EACAC,EACc,CACd,GAAI,CAAC7D,GAAO,CAAC4D,EACX,OAAOC,EAET,MAAMC,EACJlC,EAAAA,IAACmC,oBAAiB,SAAjB,CAA0B,MAAOH,EAC/B,SAAAC,EACH,EAEF,OAAO7D,EAAI,KAAO4B,EAAAA,IAAAkB,WAAA,CAAG,WAAI,KAAKgB,CAAK,EAAE,EAAMA,CAC7C"}
|
|
1
|
+
{"version":3,"file":"AegisShell.cjs","sources":["../../../src/layouts/shell/AegisShell.tsx"],"sourcesContent":["import {\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n matchRoutes,\n useHref,\n useLocation,\n useNavigate,\n useRoutes,\n} from 'react-router-dom';\n\nimport {\n AegisRuntimeProvider,\n AskOverlay,\n type ShellSnapshot,\n} from '../../agent';\nimport { useAuth } from '../../auth';\nimport { useHasCommandProvider } from '../../commands';\nimport { AmbientBackground } from '../../components/ui/AmbientBackground';\nimport { Button } from '../../components/ui/Button';\nimport { useStorageItem } from '../../hooks/useStorageItem';\nimport { useWindowScrolled } from '../../hooks/useWindowScrolled';\nimport { useStrings } from '../../locale';\nimport { ThemeContext } from '../../theme/themeContext';\nimport { SkipLink } from '../SkipLink';\nimport './AegisShell.css';\nimport { AppSwitcher } from './AppSwitcher';\nimport { BreadcrumbBar } from './BreadcrumbBar';\nimport { RouteErrorBoundary } from './RouteErrorBoundary';\nimport { ShellCommandPalette } from './ShellCommandPalette';\nimport { ShellNotificationBell } from './ShellNotificationBell';\nimport { Sidebar } from './Sidebar';\nimport {\n ActiveEnvironmentSwitcher,\n AgentPanelToggle,\n ShellBrand,\n TopHeader,\n UserMenu,\n} from './TopHeader';\nimport { ActiveAppContext } from './activeAppContext';\nimport { assertUniqueBasePaths, findActiveApp, isAppVisible } from './apps';\nimport { buildRouteTree } from './buildRouteTree';\nimport { EnvironmentProvider } from './environments';\nimport { normalizeBasePath } from './paths';\nimport { ShellNavContext, type ShellNavContextValue } from './shellNavContext';\nimport type { AegisApp, AegisShellProps } from './types';\nimport { useAgentPanel } from './useAgentPanel';\nimport { useAppCommands } from './useAppCommands';\nimport { useMobileNav } from './useMobileNav';\nimport { useShellUser } from './useShellUser';\nimport { useWarnOnce } from './useWarnOnce';\n\nconst SIDEBAR_COLLAPSED_KEY = 'aegis-shell.sidebar-collapsed';\n\n/**\n * Top-level layout: top header, two-section sidebar, breadcrumb bar, and\n * a routed content area composed from `apps`.\n *\n * Each app's `routes` is mounted under its `basePath`. The shell renders\n * the chrome around every app — apps themselves only render page content\n * inside a `<PageWrapper>` (the shell wraps the outlet automatically). A\n * page that throws while rendering shows an error with a retry in the page\n * area; the chrome stays up.\n */\nexport function AegisShell({\n brand,\n apps,\n rootRoutes = [],\n fallbackPath,\n notFoundElement,\n user,\n userMenu,\n headerCenter,\n headerActions,\n appSwitcher = true,\n elevateHeaderOnScroll = false,\n ambient,\n inboxPath,\n onAppSwitch,\n enableCommandPalette = false,\n commandGroupOrder,\n agentPanel,\n agentRuntime,\n chrome = 'header',\n}: AegisShellProps): ReactElement {\n const location = useLocation();\n const navigate = useNavigate();\n const strings = useStrings();\n const { pathname } = location;\n const auth = useAuth();\n const themeCtx = useContext(ThemeContext);\n const [sidebarCollapsedValue, setSidebarCollapsedValue] = useStorageItem(\n SIDEBAR_COLLAPSED_KEY,\n );\n const sidebarCollapsed = sidebarCollapsedValue === '1';\n const [inlineSlot, setInlineSlot] = useState<HTMLDivElement | null>(null);\n const windowScrolled = useWindowScrolled();\n const headerScrolled = elevateHeaderOnScroll && windowScrolled;\n const mainRef = useRef<HTMLElement>(null);\n\n const resolvedUser = useShellUser(user, userMenu, auth);\n\n const visibleApps = useMemo(\n () => apps.filter((app) => isAppVisible(app, auth.status, auth.user)),\n [apps, auth.status, auth.user],\n );\n\n const activeApp = useMemo(\n () => findActiveApp(apps, pathname),\n [apps, pathname],\n );\n\n const activeAppValue = useMemo(\n () =>\n activeApp\n ? { id: activeApp.id, basePath: normalizeBasePath(activeApp.basePath) }\n : null,\n [activeApp],\n );\n\n useEffect(() => {\n assertUniqueBasePaths(apps);\n }, [apps]);\n\n useAppCommands(visibleApps, activeApp?.id);\n const hasCommandProvider = useHasCommandProvider();\n useWarnOnce(\n enableCommandPalette && !hasCommandProvider,\n 'AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted.',\n );\n\n const agent = useAgentPanel(agentPanel);\n const mobileNav = useMobileNav(pathname);\n\n const sidebarChrome = (activeApp?.chrome ?? chrome) === 'sidebar';\n const navValue = useMemo<ShellNavContextValue | null>(\n () =>\n sidebarChrome\n ? {\n open: mobileNav.open,\n toggle: mobileNav.toggle,\n toggleRef: mobileNav.toggleRef,\n }\n : null,\n [sidebarChrome, mobileNav.open, mobileNav.toggle, mobileNav.toggleRef],\n );\n\n const toggleSidebar = useCallback(() => {\n setSidebarCollapsedValue(sidebarCollapsed ? '0' : '1');\n }, [setSidebarCollapsedValue, sidebarCollapsed]);\n\n const routeTree = useMemo(\n () =>\n buildRouteTree({ apps, rootRoutes, fallbackPath, notFoundElement, auth }),\n [apps, rootRoutes, fallbackPath, notFoundElement, auth],\n );\n const element = useRoutes(routeTree.routes);\n const matches = matchRoutes(routeTree.routes, location);\n const topRoute = matches ? matches[0].route : undefined;\n const page = (\n <RouteErrorBoundary resetKey={location.key}>{element}</RouteErrorBoundary>\n );\n\n const rootHref = useHref('/');\n // A hash router's href is not a path prefix, so it reports none.\n const basename = rootHref.startsWith('/')\n ? rootHref.replace(/\\/+$/, '')\n : undefined;\n\n const shellSnapshot = useCallback((): ShellSnapshot => {\n const w = typeof window !== 'undefined' ? window : null;\n return {\n currentAppId: activeApp?.id ?? null,\n route: {\n pathname,\n search: location.search,\n params: {},\n basename,\n },\n breadcrumbs: [],\n theme: themeCtx?.resolved ?? 'light',\n viewport: {\n width: w?.innerWidth ?? 0,\n height: w?.innerHeight ?? 0,\n },\n };\n }, [activeApp, pathname, location.search, basename, themeCtx]);\n\n // Bare routes (e.g. /login) render without the shell chrome.\n if (topRoute && routeTree.bareRoutes.has(topRoute)) {\n return <div>{page}</div>;\n }\n\n const appHasSidebar = Boolean(\n activeApp?.sidebar && activeApp.sidebar.length > 0,\n );\n const hasSidebar = sidebarChrome || (appHasSidebar && !sidebarCollapsed);\n\n const signInButton = auth.status === 'unauthenticated' && auth.signIn && (\n <Button\n onClick={() => {\n void auth.signIn?.({});\n }}\n >\n {strings.signIn}\n </Button>\n );\n\n const shellClass = [\n 'aegis-shell',\n sidebarChrome ? 'aegis-shell--chrome-sidebar' : '',\n hasSidebar ? 'aegis-shell--with-sidebar' : 'aegis-shell--no-sidebar',\n mobileNav.open ? 'aegis-shell--mobile-nav-open' : '',\n agent.open ? 'aegis-shell--with-agent-panel' : '',\n ambient ? 'aegis-shell--ambient' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <AegisRuntimeProvider\n runtime={agentRuntime}\n appId={activeApp?.id ?? null}\n shellSnapshot={shellSnapshot}\n navigate={navigate}\n >\n <EnvironmentProvider app={activeApp}>\n <div ref={mobileNav.shellRef} className={shellClass}>\n <SkipLink targetId=\"aegis-main\" targetRef={mainRef} />\n {ambient && <AmbientBackground variant={ambient} />}\n {!sidebarChrome && (\n <TopHeader\n brand={brand}\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n appSwitcher={appSwitcher}\n scrolled={headerScrolled}\n user={resolvedUser}\n headerCenter={headerCenter}\n headerActions={\n <>\n {headerActions}\n {signInButton}\n </>\n }\n inboxPath={\n auth.status === 'authenticated' ? inboxPath : undefined\n }\n onMobileMenuToggle={mobileNav.toggle}\n mobileMenuOpen={mobileNav.open}\n menuToggleRef={mobileNav.toggleRef}\n showMobileMenu={appHasSidebar}\n sidebarCollapsible={appHasSidebar}\n sidebarCollapsed={sidebarCollapsed}\n onSidebarToggle={toggleSidebar}\n inlineSlotRef={setInlineSlot}\n inlineSlotActive={Boolean(activeApp?.header)}\n agentPanelOpen={agent.open}\n onAgentPanelToggle={agent.toggle}\n />\n )}\n {sidebarChrome ? (\n <Sidebar\n activeApp={activeApp}\n drawerRef={mobileNav.drawerRef}\n top={\n <>\n {appSwitcher ? (\n <AppSwitcher\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n />\n ) : null}\n <ShellBrand brand={brand} />\n </>\n }\n footer={\n <>\n <ActiveEnvironmentSwitcher />\n {headerActions}\n {signInButton}\n {auth.status === 'authenticated' && inboxPath && (\n <ShellNotificationBell inboxPath={inboxPath} />\n )}\n {resolvedUser && (\n <UserMenu user={resolvedUser} align=\"left\" />\n )}\n {agent.toggle && (\n <AgentPanelToggle\n open={agent.open}\n onToggle={agent.toggle}\n />\n )}\n </>\n }\n />\n ) : (\n appHasSidebar && (\n <Sidebar activeApp={activeApp} drawerRef={mobileNav.drawerRef} />\n )\n )}\n <button\n ref={mobileNav.backdropRef}\n type=\"button\"\n className=\"aegis-shell__backdrop\"\n aria-label={strings.closeNavigation}\n tabIndex={-1}\n onClick={mobileNav.dismiss}\n />\n <main\n id=\"aegis-main\"\n ref={mainRef}\n tabIndex={-1}\n className={\n activeApp?.bleed === true\n ? 'aegis-shell__main aegis-shell__main--bleed'\n : 'aegis-shell__main'\n }\n >\n {renderAppRegion(\n activeApp,\n activeAppValue,\n <ShellNavContext.Provider value={navValue}>\n {activeApp?.header &&\n inlineSlot &&\n createPortal(activeApp.header, inlineSlot)}\n {activeApp?.breadcrumbBar !== false && (\n <BreadcrumbBar activeApp={activeApp} />\n )}\n <div className=\"aegis-shell__content\">{page}</div>\n </ShellNavContext.Provider>,\n )}\n </main>\n {agent.open && (\n <div className=\"aegis-shell__agent-panel\">{agentPanel}</div>\n )}\n <AskOverlay />\n {enableCommandPalette && hasCommandProvider && (\n <ShellCommandPalette groupOrder={commandGroupOrder} />\n )}\n </div>\n </EnvironmentProvider>\n </AegisRuntimeProvider>\n );\n}\n\nfunction renderAppRegion(\n app: AegisApp | undefined,\n appValue: { id: string; basePath: string } | null,\n children: ReactElement,\n): ReactElement {\n if (!app || !appValue) {\n return children;\n }\n const inner = (\n <ActiveAppContext.Provider value={appValue}>\n {children}\n </ActiveAppContext.Provider>\n );\n return app.wrap ? <>{app.wrap(inner)}</> : inner;\n}\n"],"names":["SIDEBAR_COLLAPSED_KEY","AegisShell","brand","apps","rootRoutes","fallbackPath","notFoundElement","user","userMenu","headerCenter","headerActions","appSwitcher","elevateHeaderOnScroll","ambient","inboxPath","onAppSwitch","enableCommandPalette","commandGroupOrder","agentPanel","agentRuntime","chrome","location","useLocation","navigate","useNavigate","strings","useStrings","pathname","auth","useAuth","themeCtx","useContext","ThemeContext","sidebarCollapsedValue","setSidebarCollapsedValue","useStorageItem","sidebarCollapsed","inlineSlot","setInlineSlot","useState","windowScrolled","useWindowScrolled","headerScrolled","mainRef","useRef","resolvedUser","useShellUser","visibleApps","useMemo","app","isAppVisible","activeApp","findActiveApp","activeAppValue","normalizeBasePath","useEffect","assertUniqueBasePaths","useAppCommands","hasCommandProvider","useHasCommandProvider","useWarnOnce","agent","useAgentPanel","mobileNav","useMobileNav","sidebarChrome","navValue","toggleSidebar","useCallback","routeTree","buildRouteTree","element","useRoutes","matches","matchRoutes","topRoute","page","jsx","RouteErrorBoundary","rootHref","useHref","basename","shellSnapshot","w","appHasSidebar","hasSidebar","signInButton","Button","shellClass","AegisRuntimeProvider","EnvironmentProvider","jsxs","SkipLink","AmbientBackground","TopHeader","Fragment","Sidebar","AppSwitcher","ShellBrand","ActiveEnvironmentSwitcher","ShellNotificationBell","UserMenu","AgentPanelToggle","renderAppRegion","ShellNavContext","createPortal","BreadcrumbBar","AskOverlay","ShellCommandPalette","appValue","children","inner","ActiveAppContext"],"mappings":"6zCA6DMA,GAAwB,gCAYvB,SAASC,GAAW,CACzB,MAAAC,EAAA,KACAC,EACA,WAAAC,EAAa,CAAA,EACb,aAAAC,EACA,gBAAAC,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,cAAAC,EACA,YAAAC,EAAc,GACd,sBAAAC,EAAwB,GACxB,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,qBAAAC,EAAuB,GACvB,kBAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EAAS,QACX,EAAkC,CAChC,MAAMC,EAAWC,EAAAA,YAAA,EACXC,EAAWC,EAAAA,YAAA,EACXC,EAAUC,GAAAA,WAAA,EACV,CAAE,SAAAC,GAAaN,EACfO,EAAOC,GAAAA,QAAA,EACPC,EAAWC,EAAAA,WAAWC,eAAY,EAClC,CAACC,EAAuBC,CAAwB,EAAIC,GAAAA,eACxDnC,EAAA,EAEIoC,EAAmBH,IAA0B,IAC7C,CAACI,EAAYC,CAAa,EAAIC,EAAAA,SAAgC,IAAI,EAClEC,EAAiBC,GAAAA,kBAAA,EACjBC,GAAiB9B,GAAyB4B,EAC1CG,EAAUC,EAAAA,OAAoB,IAAI,EAElCC,EAAeC,GAAAA,aAAavC,EAAMC,EAAUoB,CAAI,EAEhDmB,EAAcC,EAAAA,QAClB,IAAM7C,EAAK,OAAQ8C,GAAQC,EAAAA,aAAaD,EAAKrB,EAAK,OAAQA,EAAK,IAAI,CAAC,EACpE,CAACzB,EAAMyB,EAAK,OAAQA,EAAK,IAAI,CAAA,EAGzBuB,EAAYH,EAAAA,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AkB,WAAA,CAAG,WAAI,KAAKgB,CAAK,EAAE,EAAMA,CAC7C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as u, Fragment as b } from "react/jsx-runtime";
|
|
2
|
-
import { useContext as ae, useState as me, useRef as de, useMemo as
|
|
2
|
+
import { useContext as ae, useState as me, useRef as de, useMemo as g, useEffect as ce, useCallback as j } from "react";
|
|
3
3
|
import { createPortal as ue } from "react-dom";
|
|
4
|
-
import { useLocation as
|
|
4
|
+
import { useLocation as ge, useNavigate as pe, useRoutes as he, matchRoutes as fe, useHref as be } from "react-router-dom";
|
|
5
5
|
import { AmbientBackground as ve } from "../../components/ui/AmbientBackground.js";
|
|
6
6
|
import { Button as Se } from "../../components/ui/Button.js";
|
|
7
7
|
import { useStorageItem as Ae } from "../../hooks/useStorageItem.js";
|
|
@@ -12,10 +12,10 @@ import { SkipLink as we } from "../SkipLink.js";
|
|
|
12
12
|
import { AppSwitcher as Be } from "./AppSwitcher.js";
|
|
13
13
|
import { BreadcrumbBar as Pe } from "./BreadcrumbBar.js";
|
|
14
14
|
import { RouteErrorBoundary as Ie } from "./RouteErrorBoundary.js";
|
|
15
|
-
import { ShellCommandPalette as
|
|
16
|
-
import { ShellNotificationBell as
|
|
15
|
+
import { ShellCommandPalette as _e } from "./ShellCommandPalette.js";
|
|
16
|
+
import { ShellNotificationBell as Ne } from "./ShellNotificationBell.js";
|
|
17
17
|
import { Sidebar as D } from "./Sidebar.js";
|
|
18
|
-
import { TopHeader as
|
|
18
|
+
import { TopHeader as Te, ActiveEnvironmentSwitcher as ke, UserMenu as xe, AgentPanelToggle as Me, ShellBrand as ye } from "./TopHeader.js";
|
|
19
19
|
import { ActiveAppContext as Ee } from "./activeAppContext.js";
|
|
20
20
|
import { isAppVisible as He, findActiveApp as Oe, assertUniqueBasePaths as Le } from "./apps.js";
|
|
21
21
|
import { buildRouteTree as Ue } from "./buildRouteTree.js";
|
|
@@ -48,21 +48,21 @@ function Ho({
|
|
|
48
48
|
ambient: v,
|
|
49
49
|
inboxPath: S,
|
|
50
50
|
onAppSwitch: I,
|
|
51
|
-
enableCommandPalette:
|
|
51
|
+
enableCommandPalette: _ = !1,
|
|
52
52
|
commandGroupOrder: $,
|
|
53
|
-
agentPanel:
|
|
53
|
+
agentPanel: N,
|
|
54
54
|
agentRuntime: F,
|
|
55
55
|
chrome: G = "header"
|
|
56
56
|
}) {
|
|
57
|
-
const d =
|
|
57
|
+
const d = ge(), J = pe(), T = Ye(), { pathname: c } = d, r = $e(), k = ae(Ce), [Q, x] = Ae(
|
|
58
58
|
Xe
|
|
59
|
-
),
|
|
59
|
+
), p = Q === "1", [M, X] = me(null), Z = Re(), ee = Y && Z, y = de(null), A = qe(K, q, r), R = g(
|
|
60
60
|
() => i.filter((f) => He(f, r.status, r.user)),
|
|
61
61
|
[i, r.status, r.user]
|
|
62
|
-
), o =
|
|
62
|
+
), o = g(
|
|
63
63
|
() => Oe(i, c),
|
|
64
64
|
[i, c]
|
|
65
|
-
), oe =
|
|
65
|
+
), oe = g(
|
|
66
66
|
() => o ? { id: o.id, basePath: Ve(o.basePath) } : null,
|
|
67
67
|
[o]
|
|
68
68
|
);
|
|
@@ -71,10 +71,10 @@ function Ho({
|
|
|
71
71
|
}, [i]), De(R, o?.id);
|
|
72
72
|
const E = Fe();
|
|
73
73
|
ze(
|
|
74
|
-
|
|
74
|
+
_ && !E,
|
|
75
75
|
"AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted."
|
|
76
76
|
);
|
|
77
|
-
const n = je(
|
|
77
|
+
const n = je(N), t = Ke(c), l = (o?.chrome ?? G) === "sidebar", te = g(
|
|
78
78
|
() => l ? {
|
|
79
79
|
open: t.open,
|
|
80
80
|
toggle: t.toggle,
|
|
@@ -82,8 +82,8 @@ function Ho({
|
|
|
82
82
|
} : null,
|
|
83
83
|
[l, t.open, t.toggle, t.toggleRef]
|
|
84
84
|
), re = j(() => {
|
|
85
|
-
x(
|
|
86
|
-
}, [x,
|
|
85
|
+
x(p ? "0" : "1");
|
|
86
|
+
}, [x, p]), C = g(
|
|
87
87
|
() => Ue({ apps: i, rootRoutes: a, fallbackPath: m, notFoundElement: w, auth: r }),
|
|
88
88
|
[i, a, m, w, r]
|
|
89
89
|
), ie = he(C.routes), H = fe(C.routes, d), O = H ? H[0].route : void 0, L = /* @__PURE__ */ e(Ie, { resetKey: d.key, children: ie }), U = be("/"), V = U.startsWith("/") ? U.replace(/\/+$/, "") : void 0, ne = j(() => {
|
|
@@ -106,13 +106,13 @@ function Ho({
|
|
|
106
106
|
}, [o, c, d.search, V, k]);
|
|
107
107
|
if (O && C.bareRoutes.has(O))
|
|
108
108
|
return /* @__PURE__ */ e("div", { children: L });
|
|
109
|
-
const h = !!(o?.sidebar && o.sidebar.length > 0), se = l || h && !
|
|
109
|
+
const h = !!(o?.sidebar && o.sidebar.length > 0), se = l || h && !p, W = r.status === "unauthenticated" && r.signIn && /* @__PURE__ */ e(
|
|
110
110
|
Se,
|
|
111
111
|
{
|
|
112
112
|
onClick: () => {
|
|
113
113
|
r.signIn?.({});
|
|
114
114
|
},
|
|
115
|
-
children:
|
|
115
|
+
children: T.signIn
|
|
116
116
|
}
|
|
117
117
|
), le = [
|
|
118
118
|
"aegis-shell",
|
|
@@ -133,7 +133,7 @@ function Ho({
|
|
|
133
133
|
/* @__PURE__ */ e(we, { targetId: "aegis-main", targetRef: y }),
|
|
134
134
|
v && /* @__PURE__ */ e(ve, { variant: v }),
|
|
135
135
|
!l && /* @__PURE__ */ e(
|
|
136
|
-
|
|
136
|
+
Te,
|
|
137
137
|
{
|
|
138
138
|
brand: s,
|
|
139
139
|
apps: R,
|
|
@@ -153,7 +153,7 @@ function Ho({
|
|
|
153
153
|
menuToggleRef: t.toggleRef,
|
|
154
154
|
showMobileMenu: h,
|
|
155
155
|
sidebarCollapsible: h,
|
|
156
|
-
sidebarCollapsed:
|
|
156
|
+
sidebarCollapsed: p,
|
|
157
157
|
onSidebarToggle: re,
|
|
158
158
|
inlineSlotRef: X,
|
|
159
159
|
inlineSlotActive: !!o?.header,
|
|
@@ -181,7 +181,7 @@ function Ho({
|
|
|
181
181
|
/* @__PURE__ */ e(ke, {}),
|
|
182
182
|
B,
|
|
183
183
|
W,
|
|
184
|
-
r.status === "authenticated" && S && /* @__PURE__ */ e(
|
|
184
|
+
r.status === "authenticated" && S && /* @__PURE__ */ e(Ne, { inboxPath: S }),
|
|
185
185
|
A && /* @__PURE__ */ e(xe, { user: A, align: "left" }),
|
|
186
186
|
n.toggle && /* @__PURE__ */ e(
|
|
187
187
|
Me,
|
|
@@ -199,7 +199,7 @@ function Ho({
|
|
|
199
199
|
ref: t.backdropRef,
|
|
200
200
|
type: "button",
|
|
201
201
|
className: "aegis-shell__backdrop",
|
|
202
|
-
"aria-label":
|
|
202
|
+
"aria-label": T.closeNavigation,
|
|
203
203
|
tabIndex: -1,
|
|
204
204
|
onClick: t.dismiss
|
|
205
205
|
}
|
|
@@ -210,7 +210,7 @@ function Ho({
|
|
|
210
210
|
id: "aegis-main",
|
|
211
211
|
ref: y,
|
|
212
212
|
tabIndex: -1,
|
|
213
|
-
className: "aegis-shell__main",
|
|
213
|
+
className: o?.bleed === !0 ? "aegis-shell__main aegis-shell__main--bleed" : "aegis-shell__main",
|
|
214
214
|
children: Ze(
|
|
215
215
|
o,
|
|
216
216
|
oe,
|
|
@@ -222,9 +222,9 @@ function Ho({
|
|
|
222
222
|
)
|
|
223
223
|
}
|
|
224
224
|
),
|
|
225
|
-
n.open && /* @__PURE__ */ e("div", { className: "aegis-shell__agent-panel", children:
|
|
225
|
+
n.open && /* @__PURE__ */ e("div", { className: "aegis-shell__agent-panel", children: N }),
|
|
226
226
|
/* @__PURE__ */ e(Qe, {}),
|
|
227
|
-
|
|
227
|
+
_ && E && /* @__PURE__ */ e(_e, { groupOrder: $ })
|
|
228
228
|
] }) })
|
|
229
229
|
}
|
|
230
230
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisShell.js","sources":["../../../src/layouts/shell/AegisShell.tsx"],"sourcesContent":["import {\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n matchRoutes,\n useHref,\n useLocation,\n useNavigate,\n useRoutes,\n} from 'react-router-dom';\n\nimport {\n AegisRuntimeProvider,\n AskOverlay,\n type ShellSnapshot,\n} from '../../agent';\nimport { useAuth } from '../../auth';\nimport { useHasCommandProvider } from '../../commands';\nimport { AmbientBackground } from '../../components/ui/AmbientBackground';\nimport { Button } from '../../components/ui/Button';\nimport { useStorageItem } from '../../hooks/useStorageItem';\nimport { useWindowScrolled } from '../../hooks/useWindowScrolled';\nimport { useStrings } from '../../locale';\nimport { ThemeContext } from '../../theme/themeContext';\nimport { SkipLink } from '../SkipLink';\nimport './AegisShell.css';\nimport { AppSwitcher } from './AppSwitcher';\nimport { BreadcrumbBar } from './BreadcrumbBar';\nimport { RouteErrorBoundary } from './RouteErrorBoundary';\nimport { ShellCommandPalette } from './ShellCommandPalette';\nimport { ShellNotificationBell } from './ShellNotificationBell';\nimport { Sidebar } from './Sidebar';\nimport {\n ActiveEnvironmentSwitcher,\n AgentPanelToggle,\n ShellBrand,\n TopHeader,\n UserMenu,\n} from './TopHeader';\nimport { ActiveAppContext } from './activeAppContext';\nimport { assertUniqueBasePaths, findActiveApp, isAppVisible } from './apps';\nimport { buildRouteTree } from './buildRouteTree';\nimport { EnvironmentProvider } from './environments';\nimport { normalizeBasePath } from './paths';\nimport { ShellNavContext, type ShellNavContextValue } from './shellNavContext';\nimport type { AegisApp, AegisShellProps } from './types';\nimport { useAgentPanel } from './useAgentPanel';\nimport { useAppCommands } from './useAppCommands';\nimport { useMobileNav } from './useMobileNav';\nimport { useShellUser } from './useShellUser';\nimport { useWarnOnce } from './useWarnOnce';\n\nconst SIDEBAR_COLLAPSED_KEY = 'aegis-shell.sidebar-collapsed';\n\n/**\n * Top-level layout: top header, two-section sidebar, breadcrumb bar, and\n * a routed content area composed from `apps`.\n *\n * Each app's `routes` is mounted under its `basePath`. The shell renders\n * the chrome around every app — apps themselves only render page content\n * inside a `<PageWrapper>` (the shell wraps the outlet automatically). A\n * page that throws while rendering shows an error with a retry in the page\n * area; the chrome stays up.\n */\nexport function AegisShell({\n brand,\n apps,\n rootRoutes = [],\n fallbackPath,\n notFoundElement,\n user,\n userMenu,\n headerCenter,\n headerActions,\n appSwitcher = true,\n elevateHeaderOnScroll = false,\n ambient,\n inboxPath,\n onAppSwitch,\n enableCommandPalette = false,\n commandGroupOrder,\n agentPanel,\n agentRuntime,\n chrome = 'header',\n}: AegisShellProps): ReactElement {\n const location = useLocation();\n const navigate = useNavigate();\n const strings = useStrings();\n const { pathname } = location;\n const auth = useAuth();\n const themeCtx = useContext(ThemeContext);\n const [sidebarCollapsedValue, setSidebarCollapsedValue] = useStorageItem(\n SIDEBAR_COLLAPSED_KEY,\n );\n const sidebarCollapsed = sidebarCollapsedValue === '1';\n const [inlineSlot, setInlineSlot] = useState<HTMLDivElement | null>(null);\n const windowScrolled = useWindowScrolled();\n const headerScrolled = elevateHeaderOnScroll && windowScrolled;\n const mainRef = useRef<HTMLElement>(null);\n\n const resolvedUser = useShellUser(user, userMenu, auth);\n\n const visibleApps = useMemo(\n () => apps.filter((app) => isAppVisible(app, auth.status, auth.user)),\n [apps, auth.status, auth.user],\n );\n\n const activeApp = useMemo(\n () => findActiveApp(apps, pathname),\n [apps, pathname],\n );\n\n const activeAppValue = useMemo(\n () =>\n activeApp\n ? { id: activeApp.id, basePath: normalizeBasePath(activeApp.basePath) }\n : null,\n [activeApp],\n );\n\n useEffect(() => {\n assertUniqueBasePaths(apps);\n }, [apps]);\n\n useAppCommands(visibleApps, activeApp?.id);\n const hasCommandProvider = useHasCommandProvider();\n useWarnOnce(\n enableCommandPalette && !hasCommandProvider,\n 'AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted.',\n );\n\n const agent = useAgentPanel(agentPanel);\n const mobileNav = useMobileNav(pathname);\n\n const sidebarChrome = (activeApp?.chrome ?? chrome) === 'sidebar';\n const navValue = useMemo<ShellNavContextValue | null>(\n () =>\n sidebarChrome\n ? {\n open: mobileNav.open,\n toggle: mobileNav.toggle,\n toggleRef: mobileNav.toggleRef,\n }\n : null,\n [sidebarChrome, mobileNav.open, mobileNav.toggle, mobileNav.toggleRef],\n );\n\n const toggleSidebar = useCallback(() => {\n setSidebarCollapsedValue(sidebarCollapsed ? '0' : '1');\n }, [setSidebarCollapsedValue, sidebarCollapsed]);\n\n const routeTree = useMemo(\n () =>\n buildRouteTree({ apps, rootRoutes, fallbackPath, notFoundElement, auth }),\n [apps, rootRoutes, fallbackPath, notFoundElement, auth],\n );\n const element = useRoutes(routeTree.routes);\n const matches = matchRoutes(routeTree.routes, location);\n const topRoute = matches ? matches[0].route : undefined;\n const page = (\n <RouteErrorBoundary resetKey={location.key}>{element}</RouteErrorBoundary>\n );\n\n const rootHref = useHref('/');\n // A hash router's href is not a path prefix, so it reports none.\n const basename = rootHref.startsWith('/')\n ? rootHref.replace(/\\/+$/, '')\n : undefined;\n\n const shellSnapshot = useCallback((): ShellSnapshot => {\n const w = typeof window !== 'undefined' ? window : null;\n return {\n currentAppId: activeApp?.id ?? null,\n route: {\n pathname,\n search: location.search,\n params: {},\n basename,\n },\n breadcrumbs: [],\n theme: themeCtx?.resolved ?? 'light',\n viewport: {\n width: w?.innerWidth ?? 0,\n height: w?.innerHeight ?? 0,\n },\n };\n }, [activeApp, pathname, location.search, basename, themeCtx]);\n\n // Bare routes (e.g. /login) render without the shell chrome.\n if (topRoute && routeTree.bareRoutes.has(topRoute)) {\n return <div>{page}</div>;\n }\n\n const appHasSidebar = Boolean(\n activeApp?.sidebar && activeApp.sidebar.length > 0,\n );\n const hasSidebar = sidebarChrome || (appHasSidebar && !sidebarCollapsed);\n\n const signInButton = auth.status === 'unauthenticated' && auth.signIn && (\n <Button\n onClick={() => {\n void auth.signIn?.({});\n }}\n >\n {strings.signIn}\n </Button>\n );\n\n const shellClass = [\n 'aegis-shell',\n sidebarChrome ? 'aegis-shell--chrome-sidebar' : '',\n hasSidebar ? 'aegis-shell--with-sidebar' : 'aegis-shell--no-sidebar',\n mobileNav.open ? 'aegis-shell--mobile-nav-open' : '',\n agent.open ? 'aegis-shell--with-agent-panel' : '',\n ambient ? 'aegis-shell--ambient' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <AegisRuntimeProvider\n runtime={agentRuntime}\n appId={activeApp?.id ?? null}\n shellSnapshot={shellSnapshot}\n navigate={navigate}\n >\n <EnvironmentProvider app={activeApp}>\n <div ref={mobileNav.shellRef} className={shellClass}>\n <SkipLink targetId=\"aegis-main\" targetRef={mainRef} />\n {ambient && <AmbientBackground variant={ambient} />}\n {!sidebarChrome && (\n <TopHeader\n brand={brand}\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n appSwitcher={appSwitcher}\n scrolled={headerScrolled}\n user={resolvedUser}\n headerCenter={headerCenter}\n headerActions={\n <>\n {headerActions}\n {signInButton}\n </>\n }\n inboxPath={\n auth.status === 'authenticated' ? inboxPath : undefined\n }\n onMobileMenuToggle={mobileNav.toggle}\n mobileMenuOpen={mobileNav.open}\n menuToggleRef={mobileNav.toggleRef}\n showMobileMenu={appHasSidebar}\n sidebarCollapsible={appHasSidebar}\n sidebarCollapsed={sidebarCollapsed}\n onSidebarToggle={toggleSidebar}\n inlineSlotRef={setInlineSlot}\n inlineSlotActive={Boolean(activeApp?.header)}\n agentPanelOpen={agent.open}\n onAgentPanelToggle={agent.toggle}\n />\n )}\n {sidebarChrome ? (\n <Sidebar\n activeApp={activeApp}\n drawerRef={mobileNav.drawerRef}\n top={\n <>\n {appSwitcher ? (\n <AppSwitcher\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n />\n ) : null}\n <ShellBrand brand={brand} />\n </>\n }\n footer={\n <>\n <ActiveEnvironmentSwitcher />\n {headerActions}\n {signInButton}\n {auth.status === 'authenticated' && inboxPath && (\n <ShellNotificationBell inboxPath={inboxPath} />\n )}\n {resolvedUser && (\n <UserMenu user={resolvedUser} align=\"left\" />\n )}\n {agent.toggle && (\n <AgentPanelToggle\n open={agent.open}\n onToggle={agent.toggle}\n />\n )}\n </>\n }\n />\n ) : (\n appHasSidebar && (\n <Sidebar activeApp={activeApp} drawerRef={mobileNav.drawerRef} />\n )\n )}\n <button\n ref={mobileNav.backdropRef}\n type=\"button\"\n className=\"aegis-shell__backdrop\"\n aria-label={strings.closeNavigation}\n tabIndex={-1}\n onClick={mobileNav.dismiss}\n />\n <main\n id=\"aegis-main\"\n ref={mainRef}\n tabIndex={-1}\n className=\"aegis-shell__main\"\n >\n {renderAppRegion(\n activeApp,\n activeAppValue,\n <ShellNavContext.Provider value={navValue}>\n {activeApp?.header &&\n inlineSlot &&\n createPortal(activeApp.header, inlineSlot)}\n {activeApp?.breadcrumbBar !== false && (\n <BreadcrumbBar activeApp={activeApp} />\n )}\n <div className=\"aegis-shell__content\">{page}</div>\n </ShellNavContext.Provider>,\n )}\n </main>\n {agent.open && (\n <div className=\"aegis-shell__agent-panel\">{agentPanel}</div>\n )}\n <AskOverlay />\n {enableCommandPalette && hasCommandProvider && (\n <ShellCommandPalette groupOrder={commandGroupOrder} />\n )}\n </div>\n </EnvironmentProvider>\n </AegisRuntimeProvider>\n );\n}\n\nfunction renderAppRegion(\n app: AegisApp | undefined,\n appValue: { id: string; basePath: string } | null,\n children: ReactElement,\n): ReactElement {\n if (!app || !appValue) {\n return children;\n }\n const inner = (\n <ActiveAppContext.Provider value={appValue}>\n {children}\n </ActiveAppContext.Provider>\n );\n return app.wrap ? <>{app.wrap(inner)}</> : inner;\n}\n"],"names":["SIDEBAR_COLLAPSED_KEY","AegisShell","brand","apps","rootRoutes","fallbackPath","notFoundElement","user","userMenu","headerCenter","headerActions","appSwitcher","elevateHeaderOnScroll","ambient","inboxPath","onAppSwitch","enableCommandPalette","commandGroupOrder","agentPanel","agentRuntime","chrome","location","useLocation","navigate","useNavigate","strings","useStrings","pathname","auth","useAuth","themeCtx","useContext","ThemeContext","sidebarCollapsedValue","setSidebarCollapsedValue","useStorageItem","sidebarCollapsed","inlineSlot","setInlineSlot","useState","windowScrolled","useWindowScrolled","headerScrolled","mainRef","useRef","resolvedUser","useShellUser","visibleApps","useMemo","app","isAppVisible","activeApp","findActiveApp","activeAppValue","normalizeBasePath","useEffect","assertUniqueBasePaths","useAppCommands","hasCommandProvider","useHasCommandProvider","useWarnOnce","agent","useAgentPanel","mobileNav","useMobileNav","sidebarChrome","navValue","toggleSidebar","useCallback","routeTree","buildRouteTree","element","useRoutes","matches","matchRoutes","topRoute","page","jsx","RouteErrorBoundary","rootHref","useHref","basename","shellSnapshot","w","appHasSidebar","hasSidebar","signInButton","Button","shellClass","AegisRuntimeProvider","EnvironmentProvider","jsxs","SkipLink","AmbientBackground","TopHeader","Fragment","Sidebar","AppSwitcher","ShellBrand","ActiveEnvironmentSwitcher","ShellNotificationBell","UserMenu","AgentPanelToggle","renderAppRegion","ShellNavContext","createPortal","BreadcrumbBar","AskOverlay","ShellCommandPalette","appValue","children","inner","ActiveAppContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAMA,KAAwB;AAYvB,SAASC,GAAW;AAAA,EACzB,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,cAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,uBAAAC,IAAwB;AAAA,EACxB,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,mBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QA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,EAA0B,OAAOH,GAC/B,UAAAC,GACH;AAEF,SAAO7D,EAAI,OAAO,gBAAA4B,EAAAkB,GAAA,EAAG,YAAI,KAAKgB,CAAK,GAAE,IAAMA;AAC7C;"}
|
|
1
|
+
{"version":3,"file":"AegisShell.js","sources":["../../../src/layouts/shell/AegisShell.tsx"],"sourcesContent":["import {\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n matchRoutes,\n useHref,\n useLocation,\n useNavigate,\n useRoutes,\n} from 'react-router-dom';\n\nimport {\n AegisRuntimeProvider,\n AskOverlay,\n type ShellSnapshot,\n} from '../../agent';\nimport { useAuth } from '../../auth';\nimport { useHasCommandProvider } from '../../commands';\nimport { AmbientBackground } from '../../components/ui/AmbientBackground';\nimport { Button } from '../../components/ui/Button';\nimport { useStorageItem } from '../../hooks/useStorageItem';\nimport { useWindowScrolled } from '../../hooks/useWindowScrolled';\nimport { useStrings } from '../../locale';\nimport { ThemeContext } from '../../theme/themeContext';\nimport { SkipLink } from '../SkipLink';\nimport './AegisShell.css';\nimport { AppSwitcher } from './AppSwitcher';\nimport { BreadcrumbBar } from './BreadcrumbBar';\nimport { RouteErrorBoundary } from './RouteErrorBoundary';\nimport { ShellCommandPalette } from './ShellCommandPalette';\nimport { ShellNotificationBell } from './ShellNotificationBell';\nimport { Sidebar } from './Sidebar';\nimport {\n ActiveEnvironmentSwitcher,\n AgentPanelToggle,\n ShellBrand,\n TopHeader,\n UserMenu,\n} from './TopHeader';\nimport { ActiveAppContext } from './activeAppContext';\nimport { assertUniqueBasePaths, findActiveApp, isAppVisible } from './apps';\nimport { buildRouteTree } from './buildRouteTree';\nimport { EnvironmentProvider } from './environments';\nimport { normalizeBasePath } from './paths';\nimport { ShellNavContext, type ShellNavContextValue } from './shellNavContext';\nimport type { AegisApp, AegisShellProps } from './types';\nimport { useAgentPanel } from './useAgentPanel';\nimport { useAppCommands } from './useAppCommands';\nimport { useMobileNav } from './useMobileNav';\nimport { useShellUser } from './useShellUser';\nimport { useWarnOnce } from './useWarnOnce';\n\nconst SIDEBAR_COLLAPSED_KEY = 'aegis-shell.sidebar-collapsed';\n\n/**\n * Top-level layout: top header, two-section sidebar, breadcrumb bar, and\n * a routed content area composed from `apps`.\n *\n * Each app's `routes` is mounted under its `basePath`. The shell renders\n * the chrome around every app — apps themselves only render page content\n * inside a `<PageWrapper>` (the shell wraps the outlet automatically). A\n * page that throws while rendering shows an error with a retry in the page\n * area; the chrome stays up.\n */\nexport function AegisShell({\n brand,\n apps,\n rootRoutes = [],\n fallbackPath,\n notFoundElement,\n user,\n userMenu,\n headerCenter,\n headerActions,\n appSwitcher = true,\n elevateHeaderOnScroll = false,\n ambient,\n inboxPath,\n onAppSwitch,\n enableCommandPalette = false,\n commandGroupOrder,\n agentPanel,\n agentRuntime,\n chrome = 'header',\n}: AegisShellProps): ReactElement {\n const location = useLocation();\n const navigate = useNavigate();\n const strings = useStrings();\n const { pathname } = location;\n const auth = useAuth();\n const themeCtx = useContext(ThemeContext);\n const [sidebarCollapsedValue, setSidebarCollapsedValue] = useStorageItem(\n SIDEBAR_COLLAPSED_KEY,\n );\n const sidebarCollapsed = sidebarCollapsedValue === '1';\n const [inlineSlot, setInlineSlot] = useState<HTMLDivElement | null>(null);\n const windowScrolled = useWindowScrolled();\n const headerScrolled = elevateHeaderOnScroll && windowScrolled;\n const mainRef = useRef<HTMLElement>(null);\n\n const resolvedUser = useShellUser(user, userMenu, auth);\n\n const visibleApps = useMemo(\n () => apps.filter((app) => isAppVisible(app, auth.status, auth.user)),\n [apps, auth.status, auth.user],\n );\n\n const activeApp = useMemo(\n () => findActiveApp(apps, pathname),\n [apps, pathname],\n );\n\n const activeAppValue = useMemo(\n () =>\n activeApp\n ? { id: activeApp.id, basePath: normalizeBasePath(activeApp.basePath) }\n : null,\n [activeApp],\n );\n\n useEffect(() => {\n assertUniqueBasePaths(apps);\n }, [apps]);\n\n useAppCommands(visibleApps, activeApp?.id);\n const hasCommandProvider = useHasCommandProvider();\n useWarnOnce(\n enableCommandPalette && !hasCommandProvider,\n 'AegisShell: enableCommandPalette needs a <CommandProvider> above the shell; the command palette is not mounted.',\n );\n\n const agent = useAgentPanel(agentPanel);\n const mobileNav = useMobileNav(pathname);\n\n const sidebarChrome = (activeApp?.chrome ?? chrome) === 'sidebar';\n const navValue = useMemo<ShellNavContextValue | null>(\n () =>\n sidebarChrome\n ? {\n open: mobileNav.open,\n toggle: mobileNav.toggle,\n toggleRef: mobileNav.toggleRef,\n }\n : null,\n [sidebarChrome, mobileNav.open, mobileNav.toggle, mobileNav.toggleRef],\n );\n\n const toggleSidebar = useCallback(() => {\n setSidebarCollapsedValue(sidebarCollapsed ? '0' : '1');\n }, [setSidebarCollapsedValue, sidebarCollapsed]);\n\n const routeTree = useMemo(\n () =>\n buildRouteTree({ apps, rootRoutes, fallbackPath, notFoundElement, auth }),\n [apps, rootRoutes, fallbackPath, notFoundElement, auth],\n );\n const element = useRoutes(routeTree.routes);\n const matches = matchRoutes(routeTree.routes, location);\n const topRoute = matches ? matches[0].route : undefined;\n const page = (\n <RouteErrorBoundary resetKey={location.key}>{element}</RouteErrorBoundary>\n );\n\n const rootHref = useHref('/');\n // A hash router's href is not a path prefix, so it reports none.\n const basename = rootHref.startsWith('/')\n ? rootHref.replace(/\\/+$/, '')\n : undefined;\n\n const shellSnapshot = useCallback((): ShellSnapshot => {\n const w = typeof window !== 'undefined' ? window : null;\n return {\n currentAppId: activeApp?.id ?? null,\n route: {\n pathname,\n search: location.search,\n params: {},\n basename,\n },\n breadcrumbs: [],\n theme: themeCtx?.resolved ?? 'light',\n viewport: {\n width: w?.innerWidth ?? 0,\n height: w?.innerHeight ?? 0,\n },\n };\n }, [activeApp, pathname, location.search, basename, themeCtx]);\n\n // Bare routes (e.g. /login) render without the shell chrome.\n if (topRoute && routeTree.bareRoutes.has(topRoute)) {\n return <div>{page}</div>;\n }\n\n const appHasSidebar = Boolean(\n activeApp?.sidebar && activeApp.sidebar.length > 0,\n );\n const hasSidebar = sidebarChrome || (appHasSidebar && !sidebarCollapsed);\n\n const signInButton = auth.status === 'unauthenticated' && auth.signIn && (\n <Button\n onClick={() => {\n void auth.signIn?.({});\n }}\n >\n {strings.signIn}\n </Button>\n );\n\n const shellClass = [\n 'aegis-shell',\n sidebarChrome ? 'aegis-shell--chrome-sidebar' : '',\n hasSidebar ? 'aegis-shell--with-sidebar' : 'aegis-shell--no-sidebar',\n mobileNav.open ? 'aegis-shell--mobile-nav-open' : '',\n agent.open ? 'aegis-shell--with-agent-panel' : '',\n ambient ? 'aegis-shell--ambient' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <AegisRuntimeProvider\n runtime={agentRuntime}\n appId={activeApp?.id ?? null}\n shellSnapshot={shellSnapshot}\n navigate={navigate}\n >\n <EnvironmentProvider app={activeApp}>\n <div ref={mobileNav.shellRef} className={shellClass}>\n <SkipLink targetId=\"aegis-main\" targetRef={mainRef} />\n {ambient && <AmbientBackground variant={ambient} />}\n {!sidebarChrome && (\n <TopHeader\n brand={brand}\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n appSwitcher={appSwitcher}\n scrolled={headerScrolled}\n user={resolvedUser}\n headerCenter={headerCenter}\n headerActions={\n <>\n {headerActions}\n {signInButton}\n </>\n }\n inboxPath={\n auth.status === 'authenticated' ? inboxPath : undefined\n }\n onMobileMenuToggle={mobileNav.toggle}\n mobileMenuOpen={mobileNav.open}\n menuToggleRef={mobileNav.toggleRef}\n showMobileMenu={appHasSidebar}\n sidebarCollapsible={appHasSidebar}\n sidebarCollapsed={sidebarCollapsed}\n onSidebarToggle={toggleSidebar}\n inlineSlotRef={setInlineSlot}\n inlineSlotActive={Boolean(activeApp?.header)}\n agentPanelOpen={agent.open}\n onAgentPanelToggle={agent.toggle}\n />\n )}\n {sidebarChrome ? (\n <Sidebar\n activeApp={activeApp}\n drawerRef={mobileNav.drawerRef}\n top={\n <>\n {appSwitcher ? (\n <AppSwitcher\n apps={visibleApps}\n activeAppId={activeApp?.id}\n onAppSwitch={onAppSwitch}\n />\n ) : null}\n <ShellBrand brand={brand} />\n </>\n }\n footer={\n <>\n <ActiveEnvironmentSwitcher />\n {headerActions}\n {signInButton}\n {auth.status === 'authenticated' && inboxPath && (\n <ShellNotificationBell inboxPath={inboxPath} />\n )}\n {resolvedUser && (\n <UserMenu user={resolvedUser} align=\"left\" />\n )}\n {agent.toggle && (\n <AgentPanelToggle\n open={agent.open}\n onToggle={agent.toggle}\n />\n )}\n </>\n }\n />\n ) : (\n appHasSidebar && (\n <Sidebar activeApp={activeApp} drawerRef={mobileNav.drawerRef} />\n )\n )}\n <button\n ref={mobileNav.backdropRef}\n type=\"button\"\n className=\"aegis-shell__backdrop\"\n aria-label={strings.closeNavigation}\n tabIndex={-1}\n onClick={mobileNav.dismiss}\n />\n <main\n id=\"aegis-main\"\n ref={mainRef}\n tabIndex={-1}\n className={\n activeApp?.bleed === true\n ? 'aegis-shell__main aegis-shell__main--bleed'\n : 'aegis-shell__main'\n }\n >\n {renderAppRegion(\n activeApp,\n activeAppValue,\n <ShellNavContext.Provider value={navValue}>\n {activeApp?.header &&\n inlineSlot &&\n createPortal(activeApp.header, inlineSlot)}\n {activeApp?.breadcrumbBar !== false && (\n <BreadcrumbBar activeApp={activeApp} />\n )}\n <div className=\"aegis-shell__content\">{page}</div>\n </ShellNavContext.Provider>,\n )}\n </main>\n {agent.open && (\n <div className=\"aegis-shell__agent-panel\">{agentPanel}</div>\n )}\n <AskOverlay />\n {enableCommandPalette && hasCommandProvider && (\n <ShellCommandPalette groupOrder={commandGroupOrder} />\n )}\n </div>\n </EnvironmentProvider>\n </AegisRuntimeProvider>\n );\n}\n\nfunction renderAppRegion(\n app: AegisApp | undefined,\n appValue: { id: string; basePath: string } | null,\n children: ReactElement,\n): ReactElement {\n if (!app || !appValue) {\n return children;\n }\n const inner = (\n <ActiveAppContext.Provider value={appValue}>\n {children}\n </ActiveAppContext.Provider>\n );\n return app.wrap ? <>{app.wrap(inner)}</> : inner;\n}\n"],"names":["SIDEBAR_COLLAPSED_KEY","AegisShell","brand","apps","rootRoutes","fallbackPath","notFoundElement","user","userMenu","headerCenter","headerActions","appSwitcher","elevateHeaderOnScroll","ambient","inboxPath","onAppSwitch","enableCommandPalette","commandGroupOrder","agentPanel","agentRuntime","chrome","location","useLocation","navigate","useNavigate","strings","useStrings","pathname","auth","useAuth","themeCtx","useContext","ThemeContext","sidebarCollapsedValue","setSidebarCollapsedValue","useStorageItem","sidebarCollapsed","inlineSlot","setInlineSlot","useState","windowScrolled","useWindowScrolled","headerScrolled","mainRef","useRef","resolvedUser","useShellUser","visibleApps","useMemo","app","isAppVisible","activeApp","findActiveApp","activeAppValue","normalizeBasePath","useEffect","assertUniqueBasePaths","useAppCommands","hasCommandProvider","useHasCommandProvider","useWarnOnce","agent","useAgentPanel","mobileNav","useMobileNav","sidebarChrome","navValue","toggleSidebar","useCallback","routeTree","buildRouteTree","element","useRoutes","matches","matchRoutes","topRoute","page","jsx","RouteErrorBoundary","rootHref","useHref","basename","shellSnapshot","w","appHasSidebar","hasSidebar","signInButton","Button","shellClass","AegisRuntimeProvider","EnvironmentProvider","jsxs","SkipLink","AmbientBackground","TopHeader","Fragment","Sidebar","AppSwitcher","ShellBrand","ActiveEnvironmentSwitcher","ShellNotificationBell","UserMenu","AgentPanelToggle","renderAppRegion","ShellNavContext","createPortal","BreadcrumbBar","AskOverlay","ShellCommandPalette","appValue","children","inner","ActiveAppContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAMA,KAAwB;AAYvB,SAASC,GAAW;AAAA,EACzB,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,cAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC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AA,EAAoB,YAAY3F,EAAA,CAAmB;AAAA,MAAA,EAAA,CAExD,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASsF,GACPtD,GACA4D,GACAC,GACc;AACd,MAAI,CAAC7D,KAAO,CAAC4D;AACX,WAAOC;AAET,QAAMC,IACJ,gBAAAlC,EAACmC,GAAiB,UAAjB,EAA0B,OAAOH,GAC/B,UAAAC,GACH;AAEF,SAAO7D,EAAI,OAAO,gBAAA4B,EAAAkB,GAAA,EAAG,YAAI,KAAKgB,CAAK,GAAE,IAAMA;AAC7C;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("react-router-dom"),c=({to:e,className:r,"aria-current":t,tabIndex:i,children:n})=>o.jsx(u.Link,{to:e,className:r,"aria-current":t,tabIndex:i,children:n});exports.RouterLink=c;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),u=require("react-router-dom"),c=({to:e,className:r,"aria-current":t,"aria-label":a,tabIndex:i,children:n})=>o.jsx(u.Link,{to:e,className:r,"aria-current":t,"aria-label":a,tabIndex:i,children:n});exports.RouterLink=c;
|
|
2
2
|
//# sourceMappingURL=RouterLink.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterLink.cjs","sources":["../../../src/layouts/shell/RouterLink.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nimport type { LinkComponent } from '../../components/ui/linkComponent';\n\n/** `LinkComponent` adapter over react-router's `<Link>`. */\nexport const RouterLink: LinkComponent = ({\n to,\n className,\n 'aria-current': ariaCurrent,\n tabIndex,\n children,\n}) => (\n <Link\n to={to}\n className={className}\n aria-current={ariaCurrent}\n tabIndex={tabIndex}\n >\n {children}\n </Link>\n);\n"],"names":["RouterLink","to","className","ariaCurrent","tabIndex","children","jsx","Link"],"mappings":"mJAKaA,EAA4B,CAAC,CACxC,GAAAC,EACA,UAAAC,EACA,eAAgBC,EAChB,SAAAC,EACA,SAAAC,CACF,IACEC,EAAAA,IAACC,EAAAA,KAAA,CACC,
|
|
1
|
+
{"version":3,"file":"RouterLink.cjs","sources":["../../../src/layouts/shell/RouterLink.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nimport type { LinkComponent } from '../../components/ui/linkComponent';\n\n/** `LinkComponent` adapter over react-router's `<Link>`. */\nexport const RouterLink: LinkComponent = ({\n to,\n className,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n tabIndex,\n children,\n}) => (\n <Link\n to={to}\n className={className}\n aria-current={ariaCurrent}\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n >\n {children}\n </Link>\n);\n"],"names":["RouterLink","to","className","ariaCurrent","ariaLabel","tabIndex","children","jsx","Link"],"mappings":"mJAKaA,EAA4B,CAAC,CACxC,GAAAC,EACA,UAAAC,EACA,eAAgBC,EAChB,aAAcC,EACd,SAAAC,EACA,SAAAC,CACF,IACEC,EAAAA,IAACC,EAAAA,KAAA,CACC,GAAAP,EACA,UAAAC,EACA,eAAcC,EACd,aAAYC,EACZ,SAAAC,EAEC,SAAAC,CAAA,CACH"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Link as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { Link as l } from "react-router-dom";
|
|
3
3
|
const p = ({
|
|
4
4
|
to: r,
|
|
5
|
-
className:
|
|
6
|
-
"aria-current":
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
className: a,
|
|
6
|
+
"aria-current": i,
|
|
7
|
+
"aria-label": o,
|
|
8
|
+
tabIndex: t,
|
|
9
|
+
children: e
|
|
10
|
+
}) => /* @__PURE__ */ n(
|
|
11
|
+
l,
|
|
11
12
|
{
|
|
12
13
|
to: r,
|
|
13
|
-
className:
|
|
14
|
-
"aria-current":
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
className: a,
|
|
15
|
+
"aria-current": i,
|
|
16
|
+
"aria-label": o,
|
|
17
|
+
tabIndex: t,
|
|
18
|
+
children: e
|
|
17
19
|
}
|
|
18
20
|
);
|
|
19
21
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterLink.js","sources":["../../../src/layouts/shell/RouterLink.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nimport type { LinkComponent } from '../../components/ui/linkComponent';\n\n/** `LinkComponent` adapter over react-router's `<Link>`. */\nexport const RouterLink: LinkComponent = ({\n to,\n className,\n 'aria-current': ariaCurrent,\n tabIndex,\n children,\n}) => (\n <Link\n to={to}\n className={className}\n aria-current={ariaCurrent}\n tabIndex={tabIndex}\n >\n {children}\n </Link>\n);\n"],"names":["RouterLink","to","className","ariaCurrent","tabIndex","children","jsx","Link"],"mappings":";;AAKO,MAAMA,IAA4B,CAAC;AAAA,EACxC,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAgBC;AAAA,EAChB,UAAAC;AAAA,EACA,UAAAC;AACF,MACE,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,
|
|
1
|
+
{"version":3,"file":"RouterLink.js","sources":["../../../src/layouts/shell/RouterLink.tsx"],"sourcesContent":["import { Link } from 'react-router-dom';\n\nimport type { LinkComponent } from '../../components/ui/linkComponent';\n\n/** `LinkComponent` adapter over react-router's `<Link>`. */\nexport const RouterLink: LinkComponent = ({\n to,\n className,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n tabIndex,\n children,\n}) => (\n <Link\n to={to}\n className={className}\n aria-current={ariaCurrent}\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n >\n {children}\n </Link>\n);\n"],"names":["RouterLink","to","className","ariaCurrent","ariaLabel","tabIndex","children","jsx","Link"],"mappings":";;AAKO,MAAMA,IAA4B,CAAC;AAAA,EACxC,IAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAgBC;AAAA,EAChB,cAAcC;AAAA,EACd,UAAAC;AAAA,EACA,UAAAC;AACF,MACE,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,IAAAP;AAAA,IACA,WAAAC;AAAA,IACA,gBAAcC;AAAA,IACd,cAAYC;AAAA,IACZ,UAAAC;AAAA,IAEC,UAAAC;AAAA,EAAA;AACH;"}
|
|
@@ -69,6 +69,8 @@ export interface AegisApp {
|
|
|
69
69
|
* Set true to render the app's pages in a bleed `PageWrapper`: edge to
|
|
70
70
|
* edge under the header, the height of the view, for pages built of
|
|
71
71
|
* `Toolbar` bars over a `PaneLayout`. Pair it with `breadcrumbBar: false`.
|
|
72
|
+
* The shell's `main` is then positioned, so an `AnchoredPopover` with
|
|
73
|
+
* `container` set to it is placed in its box.
|
|
72
74
|
*/
|
|
73
75
|
bleed?: boolean;
|
|
74
76
|
/**
|
|
@@ -126,6 +128,10 @@ export interface AegisUserMenuItem {
|
|
|
126
128
|
}
|
|
127
129
|
export interface AegisBrand {
|
|
128
130
|
name: ReactNode;
|
|
131
|
+
/**
|
|
132
|
+
* The brand mark beside the name, drawn in a `--brand-mark-size` square
|
|
133
|
+
* that an `svg` or `img` given directly fills, so it needs no CSS of its own.
|
|
134
|
+
*/
|
|
129
135
|
logo?: ReactNode;
|
|
130
136
|
/** Optional click target for the brand area (e.g. home path). */
|
|
131
137
|
href?: string;
|
package/dist/lib/scrollView.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(e){return e??document.documentElement}function m(e){for(let t=e;t!==null&&t!==document.body;t=t.parentElement){const{overflowY:o}=getComputedStyle(t);if((o==="auto"||o==="scroll")&&t.scrollHeight>t.clientHeight)return t}return null}function u(e){if(!e)return{top:0,bottom:document.documentElement.clientHeight};const t=e.getBoundingClientRect().top+e.clientTop;return{top:t,bottom:t+e.clientHeight}}function p(e){return`0% 0% -${100-e}% 0%`}function a(e,t,o){const n=u(t),s=n.top+(n.bottom-n.top)*o/100,l=i(t),f=Math.ceil(l.scrollTop+l.clientHeight)>=l.scrollHeight;let r=0;return e.forEach((d,g)=>{const{top:c}=d.getBoundingClientRect();(c<=s||f&&c<n.bottom)&&(r=g)}),r}exports.activationRootMargin=p;exports.findCurrentIndex=a;exports.scrollerOf=i;exports.scrollingAncestorOf=m;exports.viewBoundsOf=u;
|
|
2
2
|
//# sourceMappingURL=scrollView.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollView.cjs","sources":["../../src/lib/scrollView.ts"],"sourcesContent":["/** The visible part of a scroller, in viewport coordinates. */\nexport interface ViewBounds {\n top: number;\n bottom: number;\n}\n\n/** The element whose `scrollTop` moves the view; null means the viewport. */\nexport function scrollerOf(container: HTMLElement | null): HTMLElement {\n return container ?? document.documentElement;\n}\n\nexport function viewBoundsOf(container: HTMLElement | null): ViewBounds {\n if (!container) {\n return { top: 0, bottom: document.documentElement.clientHeight };\n }\n const top = container.getBoundingClientRect().top + container.clientTop;\n return { top, bottom: top + container.clientHeight };\n}\n\n/** An IntersectionObserver `rootMargin` whose bottom edge is the activation line. */\nexport function activationRootMargin(percent: number): string {\n return `0% 0% -${100 - percent}% 0%`;\n}\n\n/**\n * The index of the last element whose top has passed `percent` of the\n * view; at the end of the scroll, the last element in view, so a short\n * final element can still become current.\n */\nexport function findCurrentIndex(\n elements: HTMLElement[],\n container: HTMLElement | null,\n percent: number,\n): number {\n const view = viewBoundsOf(container);\n const line = view.top + ((view.bottom - view.top) * percent) / 100;\n const scroller = scrollerOf(container);\n const atEnd =\n Math.ceil(scroller.scrollTop + scroller.clientHeight) >=\n scroller.scrollHeight;\n let current = 0;\n elements.forEach((element, index) => {\n const { top } = element.getBoundingClientRect();\n if (top <= line || (atEnd && top < view.bottom)) {\n current = index;\n }\n });\n return current;\n}\n"],"names":["scrollerOf","container","viewBoundsOf","top","activationRootMargin","percent","findCurrentIndex","elements","view","line","scroller","atEnd","current","
|
|
1
|
+
{"version":3,"file":"scrollView.cjs","sources":["../../src/lib/scrollView.ts"],"sourcesContent":["/** The visible part of a scroller, in viewport coordinates. */\nexport interface ViewBounds {\n top: number;\n bottom: number;\n}\n\n/** The element whose `scrollTop` moves the view; null means the viewport. */\nexport function scrollerOf(container: HTMLElement | null): HTMLElement {\n return container ?? document.documentElement;\n}\n\n/**\n * The nearest element at or above `from` whose content runs past its\n * height and scrolls; null when none does below the body, which means the\n * viewport.\n */\nexport function scrollingAncestorOf(from: HTMLElement): HTMLElement | null {\n for (\n let element: HTMLElement | null = from;\n element !== null && element !== document.body;\n element = element.parentElement\n ) {\n const { overflowY } = getComputedStyle(element);\n if (\n (overflowY === 'auto' || overflowY === 'scroll') &&\n element.scrollHeight > element.clientHeight\n ) {\n return element;\n }\n }\n return null;\n}\n\nexport function viewBoundsOf(container: HTMLElement | null): ViewBounds {\n if (!container) {\n return { top: 0, bottom: document.documentElement.clientHeight };\n }\n const top = container.getBoundingClientRect().top + container.clientTop;\n return { top, bottom: top + container.clientHeight };\n}\n\n/** An IntersectionObserver `rootMargin` whose bottom edge is the activation line. */\nexport function activationRootMargin(percent: number): string {\n return `0% 0% -${100 - percent}% 0%`;\n}\n\n/**\n * The index of the last element whose top has passed `percent` of the\n * view; at the end of the scroll, the last element in view, so a short\n * final element can still become current.\n */\nexport function findCurrentIndex(\n elements: HTMLElement[],\n container: HTMLElement | null,\n percent: number,\n): number {\n const view = viewBoundsOf(container);\n const line = view.top + ((view.bottom - view.top) * percent) / 100;\n const scroller = scrollerOf(container);\n const atEnd =\n Math.ceil(scroller.scrollTop + scroller.clientHeight) >=\n scroller.scrollHeight;\n let current = 0;\n elements.forEach((element, index) => {\n const { top } = element.getBoundingClientRect();\n if (top <= line || (atEnd && top < view.bottom)) {\n current = index;\n }\n });\n return current;\n}\n"],"names":["scrollerOf","container","scrollingAncestorOf","from","element","overflowY","viewBoundsOf","top","activationRootMargin","percent","findCurrentIndex","elements","view","line","scroller","atEnd","current","index"],"mappings":"gFAOO,SAASA,EAAWC,EAA4C,CACrE,OAAOA,GAAa,SAAS,eAC/B,CAOO,SAASC,EAAoBC,EAAuC,CACzE,QACMC,EAA8BD,EAClCC,IAAY,MAAQA,IAAY,SAAS,KACzCA,EAAUA,EAAQ,cAClB,CACA,KAAM,CAAE,UAAAC,CAAA,EAAc,iBAAiBD,CAAO,EAC9C,IACGC,IAAc,QAAUA,IAAc,WACvCD,EAAQ,aAAeA,EAAQ,aAE/B,OAAOA,CAEX,CACA,OAAO,IACT,CAEO,SAASE,EAAaL,EAA2C,CACtE,GAAI,CAACA,EACH,MAAO,CAAE,IAAK,EAAG,OAAQ,SAAS,gBAAgB,YAAA,EAEpD,MAAMM,EAAMN,EAAU,sBAAA,EAAwB,IAAMA,EAAU,UAC9D,MAAO,CAAE,IAAAM,EAAK,OAAQA,EAAMN,EAAU,YAAA,CACxC,CAGO,SAASO,EAAqBC,EAAyB,CAC5D,MAAO,UAAU,IAAMA,CAAO,MAChC,CAOO,SAASC,EACdC,EACAV,EACAQ,EACQ,CACR,MAAMG,EAAON,EAAaL,CAAS,EAC7BY,EAAOD,EAAK,KAAQA,EAAK,OAASA,EAAK,KAAOH,EAAW,IACzDK,EAAWd,EAAWC,CAAS,EAC/Bc,EACJ,KAAK,KAAKD,EAAS,UAAYA,EAAS,YAAY,GACpDA,EAAS,aACX,IAAIE,EAAU,EACd,OAAAL,EAAS,QAAQ,CAACP,EAASa,IAAU,CACnC,KAAM,CAAE,IAAAV,CAAA,EAAQH,EAAQ,sBAAA,GACpBG,GAAOM,GAASE,GAASR,EAAMK,EAAK,UACtCI,EAAUC,EAEd,CAAC,EACMD,CACT"}
|
package/dist/lib/scrollView.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export interface ViewBounds {
|
|
|
5
5
|
}
|
|
6
6
|
/** The element whose `scrollTop` moves the view; null means the viewport. */
|
|
7
7
|
export declare function scrollerOf(container: HTMLElement | null): HTMLElement;
|
|
8
|
+
/**
|
|
9
|
+
* The nearest element at or above `from` whose content runs past its
|
|
10
|
+
* height and scrolls; null when none does below the body, which means the
|
|
11
|
+
* viewport.
|
|
12
|
+
*/
|
|
13
|
+
export declare function scrollingAncestorOf(from: HTMLElement): HTMLElement | null;
|
|
8
14
|
export declare function viewBoundsOf(container: HTMLElement | null): ViewBounds;
|
|
9
15
|
/** An IntersectionObserver `rootMargin` whose bottom edge is the activation line. */
|
|
10
16
|
export declare function activationRootMargin(percent: number): string;
|