@coreframe/dashboard 0.3.28 → 0.3.29

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/README.md CHANGED
@@ -25,10 +25,22 @@ export default defineConfig({
25
25
  Removing `diagnostics()` removes the feature's root navigation entry and its runtime operations.
26
26
  Plugins are never discovered or installed at runtime.
27
27
 
28
- Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An adjacent `page.yaml` must define `icon` as a Codicon name (for example,
29
- `icon: settings-gear`) and may define `title` and `description`. Plugin navigation also requires
30
- `icon`. The sidebar uses the application package name and `src/assets/favicon.svg`. Build-time composition validates slugs, metadata, route modules,
31
- identifiers, and paths before generating the React Router route graph and navigation manifest.
28
+ Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An adjacent `page.yaml` must define
29
+ `icon` as a Codicon name (for example, `icon: settings-gear`) and may define `title`, `description`,
30
+ and `layout`. Plugin navigation also requires `icon`. The sidebar uses the application package name
31
+ and `src/assets/favicon.svg`. Set `layout: standalone` when a page owns its full viewport presentation
32
+ and should render without the dashboard navigation, heading, or shell spacing.
33
+
34
+ ```yaml
35
+ icon: settings-gear
36
+ title: Moderation
37
+ layout: standalone
38
+ ```
39
+
40
+ Omitting `layout`, or setting it to `default`, retains the standard shell. Standalone pages remain in
41
+ the dashboard route, build, authentication, query-client, and error-handling boundaries. Build-time
42
+ composition validates slugs, metadata, route modules, identifiers, and paths before generating the
43
+ React Router route graph and navigation manifest.
32
44
 
33
45
  The generated dashboard does not need route adapters, a document root, a query-client module, or an
34
46
  entry file. Keep those defaults in the package unless the dashboard build contract itself must
@@ -1,3 +1,3 @@
1
- import{getDashboardPluginBuild as e}from"./config.js";import{createRequire as t}from"node:module";import{readFile as n,readdir as r}from"node:fs/promises";import{isAbsolute as i,join as a,resolve as o}from"node:path";import{icons as s}from"@iconify-json/codicon";import{parseDocument as c}from"yaml";import{z as l}from"zod";const u=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,d=l.string().refine(e=>Object.hasOwn(s.icons,e),`must be a valid Codicon name`),f=l.object({icon:d,title:l.string().trim().min(1,`title must not be empty`).optional(),description:l.string().trim().min(1,`description must not be empty`).optional()}).strict(),p=l.object({id:l.string(),path:l.string(),icon:d,title:l.string(),description:l.string().optional(),routeModule:l.string(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),m=l.string().trim().min(1,`module reference must not be empty`),h=l.object({path:l.string(),icon:d,title:l.string(),description:l.string().optional(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),g=l.object({document:m.optional(),plugins:l.array(l.object({id:l.string(),navigation:h,pageModule:m,api:l.unknown().optional()}).strict()).optional()}).strict();async function _(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(F(e)&&e.code===`ENOENT`)return[];throw new w(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>P(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);M(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw F(e)&&e.code===`ENOENT`?new w(i,`missing required React Router route.tsx`):new w(i,`could not read route.tsx`,e)}let o=await T(a(r,`page.yaml`));return{id:e,path:e,icon:o.icon,title:o?.title??N(e),...o?.description?{description:o.description}:{},routeModule:`pages/${e}/route.tsx`}}))}function v(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=A(e);for(let e of o.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=D(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:E(e,`app`)})).sort((e,t)=>P(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)k(e,r)&&a.push(t);return O(a),a}function y(e,t){let n=A(e),r=new Set,i=[];for(let e of n.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=j(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function b(e){let t=[],n=[];for(let[r,i]of e.entries())t.push(`import { api as api${r} } from ${JSON.stringify(i.apiModule)}`,`import { createImplementation as createImplementation${r} } from ${JSON.stringify(i.implementationModule)}`),n.push(`{ api: api${r}, createImplementation: createImplementation${r} }`);return`${t.join(`
1
+ import{getDashboardPluginBuild as e}from"./config.js";import{createRequire as t}from"node:module";import{readFile as n,readdir as r}from"node:fs/promises";import{isAbsolute as i,join as a,resolve as o}from"node:path";import{icons as s}from"@iconify-json/codicon";import{parseDocument as c}from"yaml";import{z as l}from"zod";const u=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,d=l.string().refine(e=>Object.hasOwn(s.icons,e),`must be a valid Codicon name`),f=l.object({icon:d,title:l.string().trim().min(1,`title must not be empty`).optional(),description:l.string().trim().min(1,`description must not be empty`).optional(),layout:l.enum([`default`,`standalone`]).optional()}).strict(),p=l.object({id:l.string(),path:l.string(),icon:d,title:l.string(),description:l.string().optional(),layout:l.enum([`default`,`standalone`]).optional(),routeModule:l.string(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),m=l.string().trim().min(1,`module reference must not be empty`),h=l.object({path:l.string(),icon:d,title:l.string(),description:l.string().optional(),environments:l.array(l.enum([`local`,`deployed`])).optional()}).strict(),g=l.object({document:m.optional(),plugins:l.array(l.object({id:l.string(),navigation:h,pageModule:m,api:l.unknown().optional()}).strict()).optional()}).strict();async function _(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(F(e)&&e.code===`ENOENT`)return[];throw new w(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>P(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);M(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw F(e)&&e.code===`ENOENT`?new w(i,`missing required React Router route.tsx`):new w(i,`could not read route.tsx`,e)}let o=await T(a(r,`page.yaml`));return{id:e,path:e,icon:o.icon,title:o?.title??N(e),...o?.description?{description:o.description}:{},...o?.layout?{layout:o.layout}:{},routeModule:`pages/${e}/route.tsx`}}))}function v(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=A(e);for(let e of o.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=D(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:E(e,`app`)})).sort((e,t)=>P(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)k(e,r)&&a.push(t);return O(a),a}function y(e,t){let n=A(e),r=new Set,i=[];for(let e of n.plugins??[]){if(M(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new w(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=j(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function b(e){let t=[],n=[];for(let[r,i]of e.entries())t.push(`import { api as api${r} } from ${JSON.stringify(i.apiModule)}`,`import { createImplementation as createImplementation${r} } from ${JSON.stringify(i.implementationModule)}`),n.push(`{ api: api${r}, createImplementation: createImplementation${r} }`);return`${t.join(`
2
2
  `)}\n\nexport const dashboardPlugins = [\n${n.map(e=>` ${e},`).join(`
3
- `)}\n]\n`}function x(e,t){let n=[e.length>0?{index:!0,file:t.indexRoute}:{index:!0,file:t.emptyRoute},...e.map(e=>({id:`dashboard-page-${e.id}`,path:e.path,file:e.routeModule})),...t.notFoundRoute?[{path:`*`,file:t.notFoundRoute}]:[]];return[{id:`dashboard-shell`,file:t.shellRoute,children:n}]}function S(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):C(e.routeModule,t)}))}function C(e,n={}){let r=o(n.dashboardDirectory??a(process.cwd(),`dashboard`)),s=t(a(o(n.projectRoot??a(r,`..`)),`package.json`));if(i(e)||e.startsWith(`.`))return o(r,e);try{return s.resolve(e)}catch(t){throw new w(e,`could not resolve dashboard module`,t)}}var w=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function T(e){let t;try{t=await n(e,`utf8`)}catch(t){throw F(t)&&t.code===`ENOENT`?new w(e,`missing required page.yaml with a Codicon icon`):new w(e,`could not read page metadata`,t)}let r=c(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new w(e,r.errors[0]?.message??`invalid YAML`);let i=f.safeParse(r.toJS());if(!i.success)throw new w(e,l.prettifyError(i.error));return i.data}function E(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=p.safeParse(e);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;M(a.id,r,`page id`),M(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new w(r,`page title must not be empty`);if(!a.routeModule.trim())throw new w(r,`page routeModule must not be empty`);let s=a.description?.trim();if(a.description!==void 0&&!s)throw new w(r,`page description must not be empty`);return{id:a.id,path:a.path,title:o,icon:a.icon,...s?{description:s}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function D(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=h.safeParse(e.navigation);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;if(M(e.id,r,`plugin id`),M(a.path,r,`navigation path`),!a.title.trim())throw new w(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new w(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new w(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=j(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return E({id:e.id,path:a.path,title:a.title,icon:a.icon,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function O(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new w(r.routeModule,`duplicate page id "${r.id}" also contributed by ${e.routeModule}`);t.set(r.id,r);let i=n.get(r.path);if(i)throw new w(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function k(e,t){return e.environments?e.environments.includes(t):!0}function A(e){let t=g.safeParse(e);if(!t.success)throw new w(`dashboard.config.ts`,l.prettifyError(t.error));return e}function j(t,n){let r=e(t);if(!r)throw new w(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new w(`dashboard.config.ts plugin "${t.id}"`,`API id "${t.api.id}" does not match the plugin id`);for(let e of[`apiModule`,`localImplementationModule`]){let n=r[e];if(typeof n!=`string`||!n.trim())throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "${e}" must be a non-empty module reference`)}if(r.deployedImplementationModule!==void 0&&(typeof r.deployedImplementationModule!=`string`||!r.deployedImplementationModule.trim()))throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function M(e,t,n){if(!u.test(e))throw new w(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function N(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function P(e,t){return e<t?-1:+(e>t)}function F(e){return e instanceof Error&&`code`in e}export{w as DashboardCompositionError,v as composeDashboardManifest,y as composeDashboardPluginTarget,x as composeDashboardRoutes,_ as discoverDashboardPages,b as renderDashboardPluginTargetModule,C as resolveDashboardModuleReference,S as resolveDashboardRouteModules};
3
+ `)}\n]\n`}function x(e,t){let n=[e.length>0?{index:!0,file:t.indexRoute}:{index:!0,file:t.emptyRoute},...e.map(e=>({id:`dashboard-page-${e.id}`,path:e.path,file:e.routeModule})),...t.notFoundRoute?[{path:`*`,file:t.notFoundRoute}]:[]];return[{id:`dashboard-shell`,file:t.shellRoute,children:n}]}function S(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):C(e.routeModule,t)}))}function C(e,n={}){let r=o(n.dashboardDirectory??a(process.cwd(),`dashboard`)),s=t(a(o(n.projectRoot??a(r,`..`)),`package.json`));if(i(e)||e.startsWith(`.`))return o(r,e);try{return s.resolve(e)}catch(t){throw new w(e,`could not resolve dashboard module`,t)}}var w=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function T(e){let t;try{t=await n(e,`utf8`)}catch(t){throw F(t)&&t.code===`ENOENT`?new w(e,`missing required page.yaml with a Codicon icon`):new w(e,`could not read page metadata`,t)}let r=c(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new w(e,r.errors[0]?.message??`invalid YAML`);let i=f.safeParse(r.toJS());if(!i.success)throw new w(e,l.prettifyError(i.error));return i.data}function E(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=p.safeParse(e);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;M(a.id,r,`page id`),M(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new w(r,`page title must not be empty`);if(!a.routeModule.trim())throw new w(r,`page routeModule must not be empty`);let s=a.description?.trim();if(a.description!==void 0&&!s)throw new w(r,`page description must not be empty`);return{id:a.id,path:a.path,title:o,icon:a.icon,...s?{description:s}:{},...a.layout?{layout:a.layout}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function D(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=h.safeParse(e.navigation);if(!i.success)throw new w(r,l.prettifyError(i.error));let a=i.data;if(M(e.id,r,`plugin id`),M(a.path,r,`navigation path`),!a.title.trim())throw new w(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new w(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new w(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=j(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return E({id:e.id,path:a.path,title:a.title,icon:a.icon,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function O(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new w(r.routeModule,`duplicate page id "${r.id}" also contributed by ${e.routeModule}`);t.set(r.id,r);let i=n.get(r.path);if(i)throw new w(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function k(e,t){return e.environments?e.environments.includes(t):!0}function A(e){let t=g.safeParse(e);if(!t.success)throw new w(`dashboard.config.ts`,l.prettifyError(t.error));return e}function j(t,n){let r=e(t);if(!r)throw new w(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new w(`dashboard.config.ts plugin "${t.id}"`,`API id "${t.api.id}" does not match the plugin id`);for(let e of[`apiModule`,`localImplementationModule`]){let n=r[e];if(typeof n!=`string`||!n.trim())throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "${e}" must be a non-empty module reference`)}if(r.deployedImplementationModule!==void 0&&(typeof r.deployedImplementationModule!=`string`||!r.deployedImplementationModule.trim()))throw new w(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function M(e,t,n){if(!u.test(e))throw new w(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function N(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function P(e,t){return e<t?-1:+(e>t)}function F(e){return e instanceof Error&&`code`in e}export{w as DashboardCompositionError,v as composeDashboardManifest,y as composeDashboardPluginTarget,x as composeDashboardRoutes,_ as discoverDashboardPages,b as renderDashboardPluginTargetModule,C as resolveDashboardModuleReference,S as resolveDashboardRouteModules};
@@ -2,6 +2,8 @@ import { DashboardPluginApi } from "./api/contract.js";
2
2
 
3
3
  //#region src/config.d.ts
4
4
  type DashboardEnvironment = "local" | "deployed";
5
+ /** Presentation supplied around a dashboard page route. */
6
+ type DashboardPageLayout = "default" | "standalone";
5
7
  interface DashboardPageContribution {
6
8
  /** Stable page identity. It must be a lowercase, URL-safe slug. */
7
9
  id: string;
@@ -11,6 +13,8 @@ interface DashboardPageContribution {
11
13
  /** Codicon name, for example `settings-gear`. */
12
14
  icon: string;
13
15
  description?: string;
16
+ /** Presentation supplied around the route. Defaults to the dashboard shell. */
17
+ layout?: DashboardPageLayout;
14
18
  /** React Router framework route module, resolved by the dashboard build. */
15
19
  routeModule: string;
16
20
  /** Environments where the page can be included. Defaults to both. */
@@ -63,6 +67,7 @@ interface DashboardPageManifestEntry {
63
67
  /** Codicon name, for example `settings-gear`. */
64
68
  icon: string;
65
69
  description?: string;
70
+ layout?: DashboardPageLayout;
66
71
  routeModule: string;
67
72
  source: "app" | "plugin";
68
73
  pluginId?: string;
@@ -78,4 +83,4 @@ declare function definePlugin<const Plugin extends DashboardPlugin>(plugin: Plug
78
83
  /** @internal Used by the dashboard build composer to read package-owned target metadata. */
79
84
  declare function getDashboardPluginBuild(plugin: DashboardPlugin): DashboardPluginBuild | undefined;
80
85
  //#endregion
81
- export { DashboardConfig, DashboardEnvironment, DashboardPageContribution, DashboardPageManifestEntry, DashboardPlugin, DashboardPluginBuild, DashboardPluginNavigation, defineConfig, definePlugin, getDashboardPluginBuild };
86
+ export { DashboardConfig, DashboardEnvironment, DashboardPageContribution, DashboardPageLayout, DashboardPageManifestEntry, DashboardPlugin, DashboardPluginBuild, DashboardPluginNavigation, defineConfig, definePlugin, getDashboardPluginBuild };
@@ -1 +1 @@
1
- import{icons as e}from"@iconify-json/codicon";import{useEffect as t,useRef as n,useState as r}from"react";import{Link as i,NavLink as a,Navigate as o,Outlet as s,isRouteErrorResponse as c,useLocation as l,useNavigation as u,useRouteError as d}from"react-router";import{jsx as f,jsxs as p}from"react/jsx-runtime";function m({pages:i,application:o}){let c=l(),d=u(),[m,h]=r(()=>globalThis.window!==void 0&&globalThis.matchMedia(`(max-width: 47.999rem)`).matches),[g,_]=r(!1),[y,b]=r(!1),x=n(null),S=n(null),C=n(!1),w=v(i,c.pathname);t(()=>{let e=globalThis.matchMedia(`(max-width: 47.999rem)`),t=()=>h(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),t(()=>{m&&(g?S.current?.focus():C.current&&x.current?.focus(),C.current=g)},[m,g]),t(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&_(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g]);let T=m?g:!y;return p(`div`,{className:`coreframe-dashboard`,"data-collapsed":!m&&y?`true`:`false`,"data-drawer-open":m&&g?`true`:`false`,children:[f(`button`,{type:`button`,className:`coreframe-dashboard__backdrop`,"aria-label":`Close dashboard navigation`,tabIndex:m&&g?0:-1,onClick:()=>_(!1)}),f(`aside`,{className:`coreframe-dashboard__sidebar`,role:m?`dialog`:void 0,"aria-label":m?`Dashboard navigation`:void 0,"aria-modal":m&&g?!0:void 0,"aria-hidden":m&&!g?!0:void 0,inert:m&&!g?!0:void 0,children:p(`nav`,{ref:S,id:`coreframe-dashboard-navigation`,className:`coreframe-dashboard__navigation`,"aria-label":`Dashboard`,tabIndex:m?-1:void 0,children:[p(`div`,{className:`coreframe-dashboard__sidebar-header`,children:[p(`div`,{className:`coreframe-dashboard__brand`,"aria-label":o?.name,children:[o?f(`img`,{src:o.favicon,alt:``,className:`coreframe-dashboard__mark`}):null,f(`span`,{className:`coreframe-dashboard__navigation-text`,children:o?.name})]}),m?f(`button`,{type:`button`,className:`coreframe-dashboard__drawer-close`,"aria-label":`Close dashboard navigation`,onClick:()=>_(!1),children:f(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:f(`path`,{d:`m6 6 12 12M6 18 18 6`})})}):null]}),i.length>0?f(`ul`,{className:`coreframe-dashboard__navigation-list`,children:i.map(t=>f(`li`,{children:p(a,{className:`coreframe-dashboard__navigation-link`,to:`/${t.path}`,title:t.title,onClick:()=>_(!1),children:[f(`svg`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-icon`,width:`20`,height:`20`,viewBox:`0 0 ${e.width} ${e.height}`,fill:`currentColor`,dangerouslySetInnerHTML:{__html:e.icons[t.icon].body}}),f(`span`,{className:`coreframe-dashboard__navigation-text`,children:t.title})]})},t.id))}):f(`p`,{className:`coreframe-dashboard__navigation-empty`,children:`No pages`})]})}),p(`main`,{className:`coreframe-dashboard__main`,inert:m&&g?!0:void 0,children:[p(`header`,{className:`coreframe-dashboard__page-header`,children:[f(`button`,{ref:x,type:`button`,className:`coreframe-dashboard__toggle`,"aria-controls":`coreframe-dashboard-navigation`,"aria-expanded":T,"aria-label":T?`Collapse dashboard navigation`:`Expand dashboard navigation`,title:T?`Collapse dashboard navigation`:`Expand dashboard navigation`,onClick:()=>{m?_(e=>!e):b(e=>!e)},children:p(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[f(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`3`}),f(`path`,{d:`M9 3v18`}),f(`path`,{d:T?`m16 9-3 3 3 3`:`m13 9 3 3-3 3`})]})}),w?p(`div`,{className:`coreframe-dashboard__page-heading`,children:[f(`h1`,{children:w.title}),w.description?f(`p`,{children:w.description}):null]}):null,d.state===`idle`?null:f(`div`,{className:`coreframe-dashboard__pending`,role:`status`,children:`Loading page…`})]}),f(`div`,{className:`coreframe-dashboard__content`,children:f(s,{})})]})]})}function h({pages:e}){let t=e[0];return t?f(o,{replace:!0,to:`/${t.path}`}):f(g,{})}function g(){return p(`section`,{className:`coreframe-dashboard__state`,"aria-labelledby":`dashboard-empty-title`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),f(`h1`,{id:`dashboard-empty-title`,children:`No dashboard pages yet`}),p(`p`,{children:[`Add a page under `,f(`code`,{children:`dashboard/pages/`}),` or register a plugin in`,` `,f(`code`,{children:`dashboard.config.ts`}),`.`]})]})}function _(){let e=d(),t=c(e)&&e.status===404,n=import.meta.env.DEV&&e instanceof Error?e.message:t?`The requested dashboard page does not exist.`:`The dashboard hit an unexpected error.`;return p(`main`,{className:`coreframe-dashboard__state`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Coreframe Dashboard`}),f(`h1`,{children:t?`Page not found`:`Dashboard unavailable`}),f(`p`,{children:n}),f(i,{className:`coreframe-dashboard__button`,to:`/`,children:`Go to dashboard`})]})}function v(e,t){let n=t.split(`/`).filter(Boolean)[0];return e.find(e=>e.path===n)??(n?void 0:e[0])}export{g as DashboardEmptyState,_ as DashboardErrorBoundary,h as DashboardIndexRedirect,m as DashboardShell};
1
+ import{icons as e}from"@iconify-json/codicon";import{useEffect as t,useRef as n,useState as r}from"react";import{Link as i,NavLink as a,Navigate as o,Outlet as s,isRouteErrorResponse as c,useLocation as l,useNavigation as u,useRouteError as d}from"react-router";import{jsx as f,jsxs as p}from"react/jsx-runtime";function m({pages:e,application:t}){let n=y(e,l().pathname);return n?.layout===`standalone`?f(s,{}):f(h,{activePage:n,pages:e,application:t})}function h({activePage:i,pages:o,application:c}){let l=u(),[d,m]=r(()=>globalThis.window!==void 0&&globalThis.matchMedia(`(max-width: 47.999rem)`).matches),[h,g]=r(!1),[_,v]=r(!1),y=n(null),b=n(null),x=n(!1);t(()=>{let e=globalThis.matchMedia(`(max-width: 47.999rem)`),t=()=>m(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),t(()=>{d&&(h?b.current?.focus():x.current&&y.current?.focus(),x.current=h)},[d,h]),t(()=>{if(!h)return;let e=e=>{e.key===`Escape`&&g(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[h]);let S=d?h:!_;return p(`div`,{className:`coreframe-dashboard`,"data-collapsed":!d&&_?`true`:`false`,"data-drawer-open":d&&h?`true`:`false`,children:[f(`button`,{type:`button`,className:`coreframe-dashboard__backdrop`,"aria-label":`Close dashboard navigation`,tabIndex:d&&h?0:-1,onClick:()=>g(!1)}),f(`aside`,{className:`coreframe-dashboard__sidebar`,role:d?`dialog`:void 0,"aria-label":d?`Dashboard navigation`:void 0,"aria-modal":d&&h?!0:void 0,"aria-hidden":d&&!h?!0:void 0,inert:d&&!h?!0:void 0,children:p(`nav`,{ref:b,id:`coreframe-dashboard-navigation`,className:`coreframe-dashboard__navigation`,"aria-label":`Dashboard`,tabIndex:d?-1:void 0,children:[p(`div`,{className:`coreframe-dashboard__sidebar-header`,children:[p(`div`,{className:`coreframe-dashboard__brand`,"aria-label":c?.name,children:[c?f(`img`,{src:c.favicon,alt:``,className:`coreframe-dashboard__mark`}):null,f(`span`,{className:`coreframe-dashboard__navigation-text`,children:c?.name})]}),d?f(`button`,{type:`button`,className:`coreframe-dashboard__drawer-close`,"aria-label":`Close dashboard navigation`,onClick:()=>g(!1),children:f(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:f(`path`,{d:`m6 6 12 12M6 18 18 6`})})}):null]}),o.length>0?f(`ul`,{className:`coreframe-dashboard__navigation-list`,children:o.map(t=>f(`li`,{children:p(a,{className:`coreframe-dashboard__navigation-link`,to:`/${t.path}`,title:t.title,onClick:()=>g(!1),children:[f(`svg`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-icon`,width:`20`,height:`20`,viewBox:`0 0 ${e.width} ${e.height}`,fill:`currentColor`,dangerouslySetInnerHTML:{__html:e.icons[t.icon].body}}),f(`span`,{className:`coreframe-dashboard__navigation-text`,children:t.title})]})},t.id))}):f(`p`,{className:`coreframe-dashboard__navigation-empty`,children:`No pages`})]})}),p(`main`,{className:`coreframe-dashboard__main`,inert:d&&h?!0:void 0,children:[p(`header`,{className:`coreframe-dashboard__page-header`,children:[f(`button`,{ref:y,type:`button`,className:`coreframe-dashboard__toggle`,"aria-controls":`coreframe-dashboard-navigation`,"aria-expanded":S,"aria-label":S?`Collapse dashboard navigation`:`Expand dashboard navigation`,title:S?`Collapse dashboard navigation`:`Expand dashboard navigation`,onClick:()=>{d?g(e=>!e):v(e=>!e)},children:p(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[f(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`3`}),f(`path`,{d:`M9 3v18`}),f(`path`,{d:S?`m16 9-3 3 3 3`:`m13 9 3 3-3 3`})]})}),i?p(`div`,{className:`coreframe-dashboard__page-heading`,children:[f(`h1`,{children:i.title}),i.description?f(`p`,{children:i.description}):null]}):null,l.state===`idle`?null:f(`div`,{className:`coreframe-dashboard__pending`,role:`status`,children:`Loading page…`})]}),f(`div`,{className:`coreframe-dashboard__content`,children:f(s,{})})]})]})}function g({pages:e}){let t=e[0];return t?f(o,{replace:!0,to:`/${t.path}`}):f(_,{})}function _(){return p(`section`,{className:`coreframe-dashboard__state`,"aria-labelledby":`dashboard-empty-title`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),f(`h1`,{id:`dashboard-empty-title`,children:`No dashboard pages yet`}),p(`p`,{children:[`Add a page under `,f(`code`,{children:`dashboard/pages/`}),` or register a plugin in`,` `,f(`code`,{children:`dashboard.config.ts`}),`.`]})]})}function v(){let e=d(),t=c(e)&&e.status===404,n=import.meta.env.DEV&&e instanceof Error?e.message:t?`The requested dashboard page does not exist.`:`The dashboard hit an unexpected error.`;return p(`main`,{className:`coreframe-dashboard__state`,children:[f(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Coreframe Dashboard`}),f(`h1`,{children:t?`Page not found`:`Dashboard unavailable`}),f(`p`,{children:n}),f(i,{className:`coreframe-dashboard__button`,to:`/`,children:`Go to dashboard`})]})}function y(e,t){let n=t.split(`/`).filter(Boolean)[0];return e.find(e=>e.path===n)??(n?void 0:e[0])}export{_ as DashboardEmptyState,v as DashboardErrorBoundary,g as DashboardIndexRedirect,m as DashboardShell};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/dashboard",
3
- "version": "0.3.28",
3
+ "version": "0.3.29",
4
4
  "description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -88,8 +88,8 @@
88
88
  "rouzer": "^6.0.1",
89
89
  "yaml": "^2.9.0",
90
90
  "zod": "^4.4.3",
91
- "@coreframe/deploy": "0.1.19",
92
91
  "@coreframe/diagnostics": "0.2.3",
92
+ "@coreframe/deploy": "0.1.19",
93
93
  "@coreframe/lib": "^0.2.17"
94
94
  },
95
95
  "devDependencies": {