@coreframe/dashboard 0.3.10 → 0.3.12
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 +51 -0
- package/dist/package/app-client.d.ts +86 -0
- package/dist/package/app-client.js +1 -0
- package/dist/package/plugins/diagnostics/web.js +1 -1
- package/dist/package/server.js +1 -1
- package/dist/package/styled-css.js +1 -1
- package/dist/package/web/dashboard/dashboard-section.js +1 -1
- package/dist/package/web/styled-system/css/cx.js +1 -0
- package/dist/package/web/styled-system/helpers.js +1 -1
- package/dist/package/web/styled-system/recipes/dashboard-button.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-confirm-dialog.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-empty-state.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-error-state.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-field.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-page.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-section.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-status.js +1 -0
- package/dist/package/web/styled-system/recipes/dashboard-tabs.js +1 -0
- package/dist/package/web/styled-system/recipes/runtime.js +1 -0
- package/dist/package/web/ui/index.d.ts +157 -0
- package/dist/package/web/ui/index.js +1 -0
- package/dist/package/web/ui/styles.js +1 -0
- package/dist/package/web-shell/shell.js +1 -1
- package/dist/package/worker.js +1 -1
- package/package.json +14 -4
package/README.md
CHANGED
|
@@ -72,6 +72,57 @@ credentials, Worker bindings, environment secrets, and the raw request remain ou
|
|
|
72
72
|
contract. Typed operation errors expose safe error codes, and a failed local initialization can be
|
|
73
73
|
retried without restarting the host.
|
|
74
74
|
|
|
75
|
+
## App API client
|
|
76
|
+
|
|
77
|
+
App-owned dashboard pages can call the hosting app's API with the signed-in app user's session. The
|
|
78
|
+
browser-only `@coreframe/dashboard/app-client` entry fixes the origin to the current page, uses
|
|
79
|
+
`/api/` as the client base, and refreshes through `POST /api/auth/token`.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { $type } from "rouzer"
|
|
83
|
+
import * as http from "rouzer/http"
|
|
84
|
+
import {
|
|
85
|
+
DashboardAppSessionBoundary,
|
|
86
|
+
createDashboardAppClient,
|
|
87
|
+
} from "@coreframe/dashboard/app-client"
|
|
88
|
+
|
|
89
|
+
const routes = {
|
|
90
|
+
account: http.get("account", { response: $type<{ email: string }>() }),
|
|
91
|
+
}
|
|
92
|
+
const { client, session } = createDashboardAppClient(routes)
|
|
93
|
+
|
|
94
|
+
export function AccountPage() {
|
|
95
|
+
return (
|
|
96
|
+
<DashboardAppSessionBoundary
|
|
97
|
+
pending={<p>Checking the app session.</p>}
|
|
98
|
+
session={session}
|
|
99
|
+
unauthenticated={<p>Sign in to continue.</p>}
|
|
100
|
+
unknown={(current) => (
|
|
101
|
+
<button onClick={() => void current.refresh()}>Retry session check</button>
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
<Account />
|
|
105
|
+
</DashboardAppSessionBoundary>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function Account() {
|
|
110
|
+
// Use client.account() from the page's query or loader.
|
|
111
|
+
return <p>Authenticated app content</p>
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The factory resolves an unknown session before the boundary renders its children. A current
|
|
116
|
+
authenticated or unauthenticated observation is reused until it expires. Network and server
|
|
117
|
+
failures stay `unknown`, so the caller decides how to retry. The session exposes only `status`,
|
|
118
|
+
`expiresAt`, `refresh()`, and subscription methods. It does not expose access tokens, cookies,
|
|
119
|
+
dashboard credentials, or user IDs.
|
|
120
|
+
|
|
121
|
+
App requests use credentialed same-origin transport. Explicit invalid-token challenges refresh and
|
|
122
|
+
replay once through the app transport. Other response statuses keep their normal meaning, including
|
|
123
|
+
distinct `401` and `403` failures. The dashboard password and plugin `DashboardSuperuser` actor are
|
|
124
|
+
separate from app authentication, and the client does not proxy or translate between them.
|
|
125
|
+
|
|
75
126
|
## Built-in diagnostics
|
|
76
127
|
|
|
77
128
|
The diagnostics plugin preserves the full local production-readiness inspection and provides a
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AuthSessionHintStore } from "@coreframe/lib/auth-transport";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { RouzerClient } from "rouzer";
|
|
4
|
+
import { HttpRouteTree } from "rouzer/http";
|
|
5
|
+
|
|
6
|
+
//#region src/app-client.d.ts
|
|
7
|
+
/** The authentication states exposed by a dashboard app session. */
|
|
8
|
+
type DashboardAppSessionStatus = "authenticated" | "checking" | "unauthenticated" | "unknown";
|
|
9
|
+
/** The browser-only seams accepted by {@link createDashboardAppClient}. */
|
|
10
|
+
type DashboardAppClientOptions = Readonly<{
|
|
11
|
+
/** Replaces the browser fetch implementation in focused transport tests. */fetch?: typeof globalThis.fetch; /** Replaces the browser session hint store in focused session tests. */
|
|
12
|
+
sessionHint?: AuthSessionHintStore;
|
|
13
|
+
}>;
|
|
14
|
+
/** The public state of a dashboard app session at one point in time. */
|
|
15
|
+
type DashboardAppSessionSnapshot = Readonly<{
|
|
16
|
+
expiresAt: number | null;
|
|
17
|
+
isPending: boolean;
|
|
18
|
+
status: DashboardAppSessionStatus;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* The session boundary shared by dashboard pages.
|
|
22
|
+
*
|
|
23
|
+
* The object contains session state without exposing an access token, cookie, dashboard credential,
|
|
24
|
+
* or application identity. Subscribe to it directly or pass it to
|
|
25
|
+
* {@link DashboardAppSessionBoundary}.
|
|
26
|
+
*/
|
|
27
|
+
interface DashboardAppSession {
|
|
28
|
+
readonly expiresAt: number | null;
|
|
29
|
+
readonly isPending: boolean;
|
|
30
|
+
readonly status: DashboardAppSessionStatus;
|
|
31
|
+
/** Returns the current immutable session snapshot. */
|
|
32
|
+
get(): DashboardAppSessionSnapshot;
|
|
33
|
+
/** Refreshes the app session and returns the resulting state. */
|
|
34
|
+
refresh(): Promise<DashboardAppSessionSnapshot>;
|
|
35
|
+
/** Subscribes to session changes and returns an unsubscribe function. */
|
|
36
|
+
subscribe(listener: () => void): () => void;
|
|
37
|
+
/** Stops timers and browser event listeners owned by this session. */
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
/** A typed Rouzer client for an app's same-origin `/api/` route tree. */
|
|
41
|
+
type DashboardAppClient<Routes extends HttpRouteTree> = RouzerClient<Routes>;
|
|
42
|
+
/** The client and session created for one dashboard page bundle. */
|
|
43
|
+
type DashboardAppClientResult<Routes extends HttpRouteTree> = Readonly<{
|
|
44
|
+
client: DashboardAppClient<Routes>;
|
|
45
|
+
session: DashboardAppSession;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates an authenticated browser client for the app hosting the dashboard.
|
|
49
|
+
*
|
|
50
|
+
* The client always targets the current page origin and `/api/`. It refreshes through the app's
|
|
51
|
+
* fixed `POST /api/auth/token` endpoint and sends credentialed same-origin requests. Dashboard
|
|
52
|
+
* Basic Auth remains owned by the dashboard host and is not part of this client.
|
|
53
|
+
*/
|
|
54
|
+
declare function createDashboardAppClient<const Routes extends HttpRouteTree>(routes: Routes, options?: DashboardAppClientOptions): DashboardAppClientResult<Routes>;
|
|
55
|
+
/** The props accepted by {@link DashboardAppSessionBoundary}. */
|
|
56
|
+
type DashboardAppSessionBoundaryProps = Readonly<{
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
pending?: DashboardAppSessionFallback;
|
|
59
|
+
session: DashboardAppSession;
|
|
60
|
+
unauthenticated?: DashboardAppSessionFallback;
|
|
61
|
+
unknown?: DashboardAppSessionFallback;
|
|
62
|
+
}>;
|
|
63
|
+
/** A caller-owned fallback rendered for one of the non-content session states. */
|
|
64
|
+
type DashboardAppSessionFallback = ReactNode | ((session: DashboardAppSession) => ReactNode);
|
|
65
|
+
/** Reads a dashboard session with React's external-store subscription contract. */
|
|
66
|
+
declare function useDashboardAppSession(session: DashboardAppSession): DashboardAppSessionSnapshot;
|
|
67
|
+
/**
|
|
68
|
+
* Holds protected dashboard children until app authentication resolves.
|
|
69
|
+
*
|
|
70
|
+
* An operational refresh failure produces `unknown`, which never renders `children` unless the
|
|
71
|
+
* caller retries and the app reports `authenticated`.
|
|
72
|
+
*/
|
|
73
|
+
declare function DashboardAppSessionBoundary({
|
|
74
|
+
children,
|
|
75
|
+
pending,
|
|
76
|
+
session,
|
|
77
|
+
unauthenticated,
|
|
78
|
+
unknown
|
|
79
|
+
}: DashboardAppSessionBoundaryProps): ReactNode;
|
|
80
|
+
/** A typed HTTP failure that preserves the app response status. */
|
|
81
|
+
declare class DashboardAppResponseError extends Error {
|
|
82
|
+
readonly status: number;
|
|
83
|
+
constructor(status: number);
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { DashboardAppClient, DashboardAppClientOptions, DashboardAppClientResult, DashboardAppResponseError, DashboardAppSession, DashboardAppSessionBoundary, DashboardAppSessionBoundaryProps, DashboardAppSessionFallback, DashboardAppSessionSnapshot, DashboardAppSessionStatus, createDashboardAppClient, useDashboardAppSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createAuthSessionHintStore as e}from"@coreframe/lib/auth-transport";import{createBrowserAuthSessionHintPersistence as t,createBrowserAuthenticatedFetch as n}from"@coreframe/lib/auth-transport/browser";import{useSyncExternalStore as r}from"react";import{createClient as i}from"rouzer";function a(e,t={}){let r=p(),a=m(t.fetch??((e,t)=>globalThis.fetch(e,t)),r),o=t.sessionHint??f(),s=n({appOrigin:r,fetch:a,refreshAccess:()=>a(new URL(`/api/auth/token`,r),{credentials:`include`,method:`POST`}),sessionHint:o});return{client:i({baseURL:new URL(`/api/`,r).href,fetch:s.fetch,headers:{"content-type":`application/json`},onJsonError:h,routes:e}),session:l(s,o)}}function o(e){return r(e.subscribe,e.get,e.get)}function s({children:e,pending:t,session:n,unauthenticated:r,unknown:i}){switch(o(n).status){case`authenticated`:return e;case`checking`:return g(t,n);case`unauthenticated`:return g(r,n);case`unknown`:return g(i,n)}}var c=class extends Error{status;constructor(e){super(`Request failed with status ${e}.`),this.name=`DashboardAppResponseError`,this.status=e}};function l(e,t){let n=u(t.get()),r,i,a=!1;function o(){return n}function s(e,t){let r=d(e,t);r.status===n.status&&r.expiresAt===n.expiresAt||(n=r,l())}let c=new Set;function l(){for(let e of c)e()}function f(e){return c.add(e),()=>c.delete(e)}function p(){i!==void 0&&(clearTimeout(i),i=void 0)}function m(e){p(),i=setTimeout(()=>{i=void 0,t.get(),h()},Math.max(0,e-Date.now()))}function h(){if(a)return;let e=t.get();if(e.status===`authenticated`){s(`authenticated`,e.validUntil),m(e.validUntil);return}if(e.status===`unauthenticated`){s(`unauthenticated`,null),m(e.validUntil);return}p(),s(`checking`,null),g()}function g(){if(a)return Promise.resolve(n);if(t.get().status!==`unknown`)return h(),Promise.resolve(n);if(s(`checking`,null),r)return r;let i=e.refreshAccessToken().then(r=>{if(a)return n;let i=t.get();return i.status===`authenticated`||i.status===`unauthenticated`?h():r?s(`unknown`,null):(e.setUnauthenticated(),h()),n}).catch(()=>{if(!a){let e=t.get();e.status===`authenticated`||e.status===`unauthenticated`?h():s(`unknown`,null)}return n});return r=i,i.then(()=>{r===i&&(r=void 0)}),i}function _(){return a?Promise.resolve(n):(t.invalidate(),g())}let v=t.subscribe(h),y=()=>t.syncFromPersistence(),b=()=>{n.status===`unknown`&&g()};return globalThis.window!==void 0&&(globalThis.addEventListener(`storage`,y),globalThis.addEventListener(`online`,b)),h(),{get expiresAt(){return n.expiresAt},get isPending(){return n.isPending},get status(){return n.status},dispose(){a||(a=!0,p(),v(),globalThis.window!==void 0&&(globalThis.removeEventListener(`storage`,y),globalThis.removeEventListener(`online`,b)))},get:o,refresh:_,subscribe:f}}function u(e){return e.status===`authenticated`?d(`authenticated`,e.validUntil):e.status===`unauthenticated`?d(`unauthenticated`,null):d(`checking`,null)}function d(e,t){return Object.freeze({expiresAt:t,isPending:e!==`authenticated`&&e!==`unauthenticated`,status:e})}function f(){let n=!1;if(globalThis.window!==void 0)try{n=t({key:`coreframe.auth-session-observation.v1`,storage:globalThis.localStorage})}catch{n=!1}return e({persistence:n,unauthenticatedTtlMs:3e5})}function p(){let e=globalThis.location?.origin;if(!e)throw Error(`createDashboardAppClient() requires a browser location.`);let t;try{t=new URL(e)}catch{throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`createDashboardAppClient() requires an HTTP(S) browser origin.`);return t.origin}function m(e,t){return(n,r)=>{if(new URL(n instanceof Request?n.url:n.toString(),t).origin!==t)throw TypeError(`Dashboard app client only allows same-origin requests.`);return e(n,{...r,credentials:`include`})}}async function h(e){throw new c(e.status)}function g(e,t){return typeof e==`function`?e(t):e??null}export{c as DashboardAppResponseError,s as DashboardAppSessionBoundary,a as createDashboardAppClient,o as useDashboardAppSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Button as e,EmptyState as t,ErrorState as n}from"../../web/ui/index.js";import{DashboardPage as r}from"../../web/dashboard/dashboard-page.js";import{DeployedDashboardPage as i}from"../../web/dashboard/deployed-dashboard-page.js";import a from"../../web/root.style.js";import{diagnosticsQueries as o}from"./web/queries.js";import{useQuery as s}from"@tanstack/react-query";import{jsx as c}from"react/jsx-runtime";function l(){let t=s(o.overview());return t.isPending?c(u,{title:`Loading dashboard`,message:`Reading the latest project diagnostics.`}):t.isError?c(u,{error:!0,title:`Dashboard unavailable`,message:t.error.message,action:c(e,{className:a.button,onClick:()=>void t.refetch(),children:`Retry`})}):t.data.mode===`deployed`?c(i,{payload:t.data,onRefresh:()=>void t.refetch()}):c(r,{payload:t.data,onRefresh:()=>void t.refetch()})}function u({title:e,message:r,action:i,error:o=!1}){return c(o?n:t,{action:i,className:a.statePage,message:r,title:e})}export{l as default};
|
package/dist/package/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{DashboardRequestError as t}from"./request-error.js";import{assertDashboardApiRequestOrigin as n,assertLocalDashboardHost as r,getDashboardRequestId as i}from"./host-policy.js";import{handleFetchRequest as a}from"./node-fetch-adapter.js";import{readFile as o,stat as s}from"node:fs/promises";import{extname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{createServer as m}from"node:http";function h(e){let t=g(e),n=m(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function g(o){let s=e(o.plugins,{host:Object.freeze({projectRoot:o.projectRoot}),getRequestId:i});return{dispose:async()=>void 0,async handle(e,i){try{r(e);let t=e.headers[`x-forwarded-proto`]===`https`?`https`:`http`,c=new URL(e.url??`/`,`${t}://${e.headers.host??`127.0.0.1`}`);if(c.pathname.startsWith(`/__dashboard/api/plugins/`)){n(e,c),await a(e,i,s);return}if(c.pathname===`/__dashboard/api`||c.pathname.startsWith(`/__dashboard/api/`)){v(i,404,{error:`Not found`});return}if(!o.clientDist){v(i,404,{error:`Not found`});return}if(c.pathname===`/__dashboard`){i.writeHead(302,{location:`/__dashboard/`}),i.end();return}if(c.pathname.startsWith(`/__dashboard/`)){if(e.method!==`GET`&&e.method!==`HEAD`){v(i,405,{error:`Method not allowed`});return}await _(e,i,c.pathname.slice(12)||`/`,o.clientDist);return}v(i,404,{error:`Not found`})}catch(e){v(i,e instanceof t?e.status:500,{error:e instanceof Error?e.message:String(e)})}}}}async function _(e,t,n,r){let i=y(r,n);if(!i){v(t,404,{error:`Client asset not found`});return}let a=await b(i),o=!a&&c(n)===``,s=u(r,`index.html`),l=o?await b(s):void 0,d=a?i:s,f=a??l;if(!f){v(t,404,{error:`Client asset not found`});return}t.writeHead(200,{"content-type":x(d),"cache-control":d.endsWith(`index.html`)?`no-store`:`public, max-age=31536000, immutable`}),t.end(e.method===`HEAD`?void 0:f)}function v(e,t,n){e.writeHead(t,{"content-type":`application/json; charset=utf-8`,"cache-control":`no-store`}),e.end(JSON.stringify(n))}function y(e,n){let r;try{r=decodeURIComponent(n)}catch{throw new t(`Dashboard request path is invalid.`,400)}if(r.includes(`\0`))throw new t(`Dashboard request path is invalid.`,400);let i=f(e,r===`/`?`index.html`:r.slice(1)),a=d(e,i);if(!(a===``||a===`..`||a.startsWith(`..${p}`)||l(a)))return i}async function b(e){try{return(await s(e)).isFile()?await o(e):void 0}catch(e){if(S(e)&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function x(e){switch(c(e)){case`.css`:return`text/css; charset=utf-8`;case`.html`:return`text/html; charset=utf-8`;case`.ico`:return`image/x-icon`;case`.jpeg`:case`.jpg`:return`image/jpeg`;case`.js`:case`.mjs`:return`text/javascript; charset=utf-8`;case`.json`:case`.map`:return`application/json; charset=utf-8`;case`.png`:return`image/png`;case`.svg`:return`image/svg+xml`;case`.ttf`:return`font/ttf`;case`.wasm`:return`application/wasm`;case`.webp`:return`image/webp`;case`.woff`:return`font/woff`;case`.woff2`:return`font/woff2`;default:return`application/octet-stream`}}function S(e){return e instanceof Error&&`code`in e}export{g as createDashboardRequestHandler,h as createDashboardServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css as e}from"./web/styled-system/css/css.js";export{e as css};
|
|
1
|
+
import{css as e}from"./web/styled-system/css/css.js";import{cx as t}from"./web/styled-system/css/cx.js";export{e as css,t as cx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./dashboard.style.js";import{jsx as
|
|
1
|
+
import e from"./dashboard.style.js";import{EmptyState as t}from"../ui/index.js";import{jsx as n,jsxs as r}from"react/jsx-runtime";function i({title:t,description:i}){return r(`header`,{className:e.sectionHeader,children:[n(`h2`,{id:`${t}-title`,children:t}),n(`p`,{children:i})]})}function a({title:r,message:i}){return n(t,{className:e.empty,title:r,message:i})}export{a as EmptyState,i as SectionHeader};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(...e){let t=``,n=0,r;for(;n<arguments.length;)(r=arguments[n++])&&typeof r==`string`&&(t&&(t+=` `),t+=r);return t}export{e as cx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const t=Object.prototype.hasOwnProperty;function n(e){return e===`base`}function r(e){let t=[];for(let r=0;r<e.length;r++)n(e[r])||t.push(e[r]);return t}function i(e){let t=5381;for(let n=e.length;n;)t=t*33^e.charCodeAt(--n);let n=t>>>0,r=``;for(;n>52;n=n/52|0){let e=n%52;r=String.fromCharCode(e+(e>25?39:97))+r}let i=n%52;return String.fromCharCode(i+(i>25?39:97))+r}function a(e,t){let n=Object.create(null);for(let r=0;r<e.length;r++)e[r]!=null&&(n[t[r]]=e[r]);return n}function
|
|
1
|
+
function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const t=Object.prototype.hasOwnProperty;function n(e){return e===`base`}function r(e){let t=[];for(let r=0;r<e.length;r++)n(e[r])||t.push(e[r]);return t}function i(e){let t=5381;for(let n=e.length;n;)t=t*33^e.charCodeAt(--n);let n=t>>>0,r=``;for(;n>52;n=n/52|0){let e=n%52;r=String.fromCharCode(e+(e>25?39:97))+r}let i=n%52;return String.fromCharCode(i+(i>25?39:97))+r}function a(e){let t=Object.create(null);if(!e)return t;for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function o(e,t){return{...e,...a(t)}}function s(e,t,n){let r=[];outer:for(let i of e){for(let e in i){if(e===`css`||e===`className`||e===`classNames`)continue;let n=i[e],r=t[e];if(Array.isArray(n)){if(!n.includes(r))continue outer}else if(r!==n)continue outer}i.className&&r.push(n?n(i.className):i.className)}return r.join(` `)}function c(e,t){let n=[];for(let r of e){let e=r.css?.[t],i=r.classNames?.[t]??r.className;if(!e&&!i)continue;let a=e?{css:e}:{};for(let e in r)e===`css`||e===`className`||e===`classNames`||(a[e]=r[e]);i&&(a.className=i),n.push(a)}return n}function l(e,t){let n=Object.create(null);for(let r=0;r<e.length;r++)e[r]!=null&&(n[t[r]]=e[r]);return n}function u(e,n,r){r||={};let{stop:i,getKey:a}=r,o=(e,r=[])=>{if(!e||typeof e!=`object`||i?.(e,r))return n(e,r);let s=Array.isArray(e)?[]:Object.create(null);for(let n in e){if(!t.call(e,n))continue;let i=a?.(n,e[n])??n;r.push(i);let c=o(e[n],r);r.pop(),c!=null&&(s[i]=c)}return s};return o(e)}function d(e,t,n){let{utility:r,conditions:i}=t,{hasShorthand:a,resolveShorthand:o}=r;return n=n!==!1,u(e,e=>Array.isArray(e)?l(e,i.breakpoints.keys):e,{stop:Array.isArray,getKey:n?e=>a?o(e):e:void 0})}function f(e){let t=new Map;return((...n)=>{let r=JSON.stringify(n);if(t.has(r)){let e=t.get(r);return t.delete(r),t.set(r,e),e}let i=e(...n);return t.set(r,i),t.size>500&&t.delete(t.keys().next().value),i})}function p(e){let t=new WeakMap;return(n=>{if(!n||typeof n!=`object`)return e(n);if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r})}function m(...n){let r=Object.create(null);for(let i of n)if(i)for(let n in i){if(!t.call(i,n)||n===`__proto__`||n===`constructor`||n===`prototype`)continue;let a=r[n],o=i[n];r[n]=e(a)&&e(o)?m(a,o):o}return r}function h(t){let{utility:n,hash:a,conditions:o}=t,s=e=>n.prefix?n.prefix+`-`+e:e,c=(e,t)=>{let r=o.finalize(e);return r.push(a?t:s(t)),a?s(n.toHash(r,i)):r.join(`:`)},l=p(function({base:e,...i}={}){let a=d(e?Object.assign(i,e):i,t),s=new Set;u(a,(e,t)=>{if(e==null)return;let i=C(e),[a,...l]=o.shift(t),u=r(l),d=n.transform(a,S(w(e))),f=c(u,d.className);i&&(f+=`!`),s.add(f)});let l=``;for(let e of s)l+=l?` `+e:e;return l}),f=n=>{let r=[],i=t=>{for(let n=0;n<t.length;n++){let a=t[n];if(Array.isArray(a)){i(a);continue}if(e(a)){for(let e in a)if(a[e]!==void 0){r.push(a);break}}}};if(i(n),r.length<2)return r;for(let e=0;e<r.length;e++)r[e]=d(r[e],t);return r};return{serializeCss:l,mergeCss:function(){return m(...f(arguments))},assignCss:function(){let e={},t=f(arguments);for(let n=0;n<t.length;n++)Object.assign(e,t[n]);return e}}}function g(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,`-$&`).replace(/^ms-/,`-ms-`).toLowerCase()}function _(e,...t){let n=Object.getOwnPropertyDescriptors(e),r=Object.keys(n),i=e=>{let t=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r];n[i]&&(Object.defineProperty(t,i,n[i]),delete n[i])}return t},a=[];for(let e of t){if(Array.isArray(e)){a.push(i(e));continue}let t=[];for(let n=0;n<r.length;n++)e(r[n])&&t.push(r[n]);a.push(i(t))}return a.push(i(r)),a}const v=[`htmlSize`,`htmlTranslate`,`htmlWidth`,`htmlHeight`];function y(e){return v.includes(e)?e.replace(`html`,``).toLowerCase():e}function b(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[y(e),t]))}b.keys=v;function x(...e){let t=new Set;for(let n of e)if(n)for(let e=0;e<n.length;e++)t.add(n[e]);return Array.from(t)}function S(e){return typeof e==`string`&&e.indexOf(` `)>=0?e.replaceAll(` `,`_`):e}function C(e){return typeof e==`string`?/\s*!(important)?/i.test(e):!1}function w(e){return typeof e==`string`?e.replace(/\s*!(important)?/i,``).trim():e}export{a as compact,h as createCssRuntime,r as filterBaseConditions,s as getCompoundVariantClassNames,c as getSlotCompoundVariant,g as hypenateProperty,n as isBaseCondition,C as isImportant,e as isObject,f as memo,m as mergeProps,b as normalizeHTMLProps,d as normalizeStyleObject,_ as splitProps,i as toHash,l as toResponsiveObject,x as uniq,u as walkObject,p as weakMemo,o as withDefaults,w as withoutImportant,S as withoutSpace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRecipe as e}from"./runtime.js";const t=e({name:`dashboardButton`,className:`dashboard-button`,defaultVariants:{size:`md`,tone:`accent`,variant:`solid`},compoundVariants:[{tone:`neutral`,variant:`solid`,className:`dashboard-button--compound__tone_neutral__variant_solid`},{tone:`accent`,variant:`solid`,className:`dashboard-button--compound__tone_accent__variant_solid`},{tone:`danger`,variant:`solid`,className:`dashboard-button--compound__tone_danger__variant_solid`},{tone:`accent`,variant:`outline`,className:`dashboard-button--compound__tone_accent__variant_outline`},{tone:`danger`,variant:`outline`,className:`dashboard-button--compound__tone_danger__variant_outline`},{tone:`accent`,variant:`quiet`,className:`dashboard-button--compound__tone_accent__variant_quiet`},{tone:`danger`,variant:`quiet`,className:`dashboard-button--compound__tone_danger__variant_quiet`}],variantMap:{size:[`lg`,`md`,`sm`],tone:[`accent`,`danger`,`neutral`],variant:[`outline`,`quiet`,`solid`]}});export{t as dashboardButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardConfirmDialog`,className:`dashboard-confirm-dialog`,slots:[`backdrop`,`content`,`title`,`description`,`actions`,`cancel`,`confirm`]});export{t as dashboardConfirmDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardEmptyState`,className:`dashboard-empty-state`,slots:[`root`,`title`,`message`,`action`]});export{t as dashboardEmptyState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardErrorState`,className:`dashboard-error-state`,slots:[`root`,`title`,`message`,`action`]});export{t as dashboardErrorState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardField`,className:`dashboard-field`,slots:[`root`,`label`,`control`,`description`,`error`]});export{t as dashboardField};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRecipe as e}from"./runtime.js";const t=e({name:`dashboardPage`,className:`dashboard-page`});export{t as dashboardPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardSection`,className:`dashboard-section`,slots:[`root`,`header`,`heading`,`description`,`actions`,`content`]});export{t as dashboardSection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRecipe as e}from"./runtime.js";const t=e({name:`dashboardStatus`,className:`dashboard-status`,defaultVariants:{tone:`neutral`},variantMap:{tone:[`danger`,`info`,`neutral`,`success`,`warning`]}});export{t as dashboardStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSlotRecipe as e}from"./runtime.js";const t=e({name:`dashboardTabs`,className:`dashboard-tabs`,slots:[`root`,`list`,`trigger`,`panel`]});export{t as dashboardTabs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCssRuntime as e,getCompoundVariantClassNames as t,getSlotCompoundVariant as n,memo as r,splitProps as i,toHash as a,uniq as o,withDefaults as s,withoutSpace as c}from"../helpers.js";import{breakpointKeys as l,finalizeConditions as u,sortConditions as d}from"../css/conditions.js";import{cx as f}from"../css/cx.js";function p(e){let t=e.variantMap??{};return{name:e.name,className:e.className??e.name,slots:e.slots??[],variantMap:t,variantKeys:Object.keys(t),defaults:e.defaultVariants??{},compounds:e.compoundVariants??[]}}function m(n){let{name:i,className:o,variantMap:m,variantKeys:h,defaults:v,compounds:y}=p(n),{serializeCss:b}=e({hash:!1,conditions:{shift:d,finalize:u,breakpoints:{keys:l}},utility:{prefix:null,toHash:a,transform(e,t){return{className:t===`__ignore__`?o:`${o}--${e}_${c(t)}`}}}}),x=e=>e;function S(e={}){return{[o]:`__ignore__`,...s(v,e)}}function C(e){if(y.length!==0)for(let t of h){let n=e[t];if(typeof n==`object`&&n)throw Error(`[recipe:${o}:${t}] Conditions are not supported when using compound variants.`)}}function w(e){return t(y,S(e),x)}let T=_(r(function(e={},t=!0){C(e);let n=b(S(e));return t?f(n,w(e)):n}),i,h,m,S);return T.__recipe__=!0,T.__getCompoundVariantClasses__=w,T.merge=function(e){return g(T,e)},T}function h(e){let{name:t,className:i,slots:a,variantMap:o,variantKeys:c,defaults:l,compounds:u}=p(e),d=a.map(function(e){return[e,m({name:t,className:`${i}__${e}`,variantMap:o,defaultVariants:l,compoundVariants:n(u,e)})]}),f=r(function(e={}){let t={};for(let[n,r]of d)t[n]=r(e);return t});return _(f,t,c,o,function(e={}){return s(l,e)}),f.__recipe__=!1,f.classNameMap={},f}function g(e,t){if(e&&!t)return e;if(!e&&t)return t;function n(...n){let r=e(...n),i=t(...n);return r&&i?`${r} ${i}`:r||i}let r=o(e.variantKeys,t.variantKeys),i={};for(let n of r)i[n]=o(e.variantMap[n],t.variantMap[n]);return _(n,`${e.__name__} ${t.__name__}`,r,i,function(e){return e}),n.__recipe__=!0,n}function _(e,t,n,r,a){return e.__name__=t,e.raw=function(e){return e},e.variantKeys=n,e.variantMap=r,e.splitVariantProps=function(e){return i(e,n)},e.getVariantProps=a,e}export{m as createRecipe,h as createSlotRecipe};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, HTMLAttributes, ReactElement, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/web/ui/index.d.ts
|
|
4
|
+
interface PageProps extends HTMLAttributes<HTMLDivElement> {}
|
|
5
|
+
/** Content layout for a dashboard route. The route shell owns the page heading. */
|
|
6
|
+
declare function Page({
|
|
7
|
+
className,
|
|
8
|
+
...props
|
|
9
|
+
}: PageProps): import("react").JSX.Element;
|
|
10
|
+
interface SectionProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
|
|
11
|
+
title?: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
actions?: ReactNode;
|
|
14
|
+
headingId?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function Section({
|
|
17
|
+
actions,
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
description,
|
|
21
|
+
headingId,
|
|
22
|
+
title,
|
|
23
|
+
...props
|
|
24
|
+
}: SectionProps): import("react").JSX.Element;
|
|
25
|
+
interface TabsProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
value: string;
|
|
27
|
+
onValueChange: (value: string) => void;
|
|
28
|
+
orientation?: "horizontal" | "vertical";
|
|
29
|
+
}
|
|
30
|
+
/** Controlled tabs with roving focus and automatic activation on arrow-key navigation. */
|
|
31
|
+
declare function TabsRoot({
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
id,
|
|
35
|
+
onValueChange,
|
|
36
|
+
orientation,
|
|
37
|
+
value,
|
|
38
|
+
...props
|
|
39
|
+
}: TabsProps): import("react").JSX.Element;
|
|
40
|
+
interface TabsListProps extends HTMLAttributes<HTMLDivElement> {}
|
|
41
|
+
declare function TabsList({
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}: TabsListProps): import("react").JSX.Element;
|
|
45
|
+
interface TabsTriggerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "value"> {
|
|
46
|
+
value: string;
|
|
47
|
+
}
|
|
48
|
+
declare function TabsTrigger({
|
|
49
|
+
children,
|
|
50
|
+
className,
|
|
51
|
+
disabled,
|
|
52
|
+
onClick,
|
|
53
|
+
onKeyDown,
|
|
54
|
+
value,
|
|
55
|
+
...props
|
|
56
|
+
}: TabsTriggerProps): import("react").JSX.Element;
|
|
57
|
+
interface TabsPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
58
|
+
value: string;
|
|
59
|
+
forceMount?: boolean;
|
|
60
|
+
}
|
|
61
|
+
declare function TabsPanel({
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
forceMount,
|
|
65
|
+
value,
|
|
66
|
+
...props
|
|
67
|
+
}: TabsPanelProps): import("react").JSX.Element | null;
|
|
68
|
+
declare const Tabs: typeof TabsRoot & {
|
|
69
|
+
List: typeof TabsList;
|
|
70
|
+
Panel: typeof TabsPanel;
|
|
71
|
+
Trigger: typeof TabsTrigger;
|
|
72
|
+
};
|
|
73
|
+
type StatusTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
74
|
+
interface StatusProps extends HTMLAttributes<HTMLSpanElement> {
|
|
75
|
+
tone?: StatusTone;
|
|
76
|
+
}
|
|
77
|
+
declare function Status({
|
|
78
|
+
className,
|
|
79
|
+
role,
|
|
80
|
+
tone,
|
|
81
|
+
...props
|
|
82
|
+
}: StatusProps): import("react").JSX.Element;
|
|
83
|
+
type ButtonVariant = "solid" | "outline" | "quiet";
|
|
84
|
+
type ButtonTone = "neutral" | "accent" | "danger";
|
|
85
|
+
type ButtonSize = "sm" | "md" | "lg";
|
|
86
|
+
interface ButtonOptions {
|
|
87
|
+
busy?: boolean;
|
|
88
|
+
busyLabel?: string;
|
|
89
|
+
children?: ReactNode;
|
|
90
|
+
className?: string;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
size?: ButtonSize;
|
|
93
|
+
tone?: ButtonTone;
|
|
94
|
+
variant?: ButtonVariant;
|
|
95
|
+
}
|
|
96
|
+
type ButtonProps = ButtonOptions & ((Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonOptions | "href"> & {
|
|
97
|
+
href?: undefined;
|
|
98
|
+
}) | (Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof ButtonOptions> & {
|
|
99
|
+
href: string;
|
|
100
|
+
}));
|
|
101
|
+
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
102
|
+
interface FieldProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
103
|
+
children: ReactElement;
|
|
104
|
+
description?: ReactNode;
|
|
105
|
+
error?: ReactNode;
|
|
106
|
+
id?: string;
|
|
107
|
+
label: ReactNode;
|
|
108
|
+
required?: boolean;
|
|
109
|
+
}
|
|
110
|
+
declare function Field({
|
|
111
|
+
children,
|
|
112
|
+
className,
|
|
113
|
+
description,
|
|
114
|
+
error,
|
|
115
|
+
id,
|
|
116
|
+
label,
|
|
117
|
+
required,
|
|
118
|
+
...props
|
|
119
|
+
}: FieldProps): import("react").JSX.Element;
|
|
120
|
+
interface StateProps extends Omit<HTMLAttributes<HTMLElement>, "children" | "title"> {
|
|
121
|
+
action?: ReactNode;
|
|
122
|
+
children?: ReactNode;
|
|
123
|
+
message?: ReactNode;
|
|
124
|
+
title: ReactNode;
|
|
125
|
+
}
|
|
126
|
+
declare function EmptyState(props: StateProps): import("react").JSX.Element;
|
|
127
|
+
declare function ErrorState(props: StateProps): import("react").JSX.Element;
|
|
128
|
+
interface ConfirmDialogProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "title"> {
|
|
129
|
+
busy?: boolean;
|
|
130
|
+
cancelLabel?: ReactNode;
|
|
131
|
+
children?: ReactNode;
|
|
132
|
+
confirmLabel?: ReactNode;
|
|
133
|
+
confirmTone?: ButtonTone;
|
|
134
|
+
description?: ReactNode;
|
|
135
|
+
onConfirm: () => void | Promise<void>;
|
|
136
|
+
onOpenChange: (open: boolean) => void;
|
|
137
|
+
open: boolean;
|
|
138
|
+
title: ReactNode;
|
|
139
|
+
}
|
|
140
|
+
/** Controlled confirmation dialog. Mutation state stays with the consumer via `busy`. */
|
|
141
|
+
declare function ConfirmDialog({
|
|
142
|
+
busy,
|
|
143
|
+
cancelLabel,
|
|
144
|
+
children,
|
|
145
|
+
className,
|
|
146
|
+
confirmLabel,
|
|
147
|
+
confirmTone,
|
|
148
|
+
description,
|
|
149
|
+
onConfirm,
|
|
150
|
+
onMouseDown,
|
|
151
|
+
onOpenChange,
|
|
152
|
+
open,
|
|
153
|
+
title,
|
|
154
|
+
...props
|
|
155
|
+
}: ConfirmDialogProps): import("react").JSX.Element | null;
|
|
156
|
+
//#endregion
|
|
157
|
+
export { Button, ButtonProps, ButtonSize, ButtonTone, ButtonVariant, ConfirmDialog, ConfirmDialogProps, EmptyState, ErrorState, Field, FieldProps, Page, PageProps, Section, SectionProps, StateProps, Status, StatusProps, StatusTone, Tabs, TabsListProps, TabsPanelProps, TabsProps, TabsTriggerProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cx as e}from"../styled-system/css/cx.js";import{styles as t}from"./styles.js";import{cloneElement as n,createContext as r,forwardRef as i,useCallback as a,useContext as o,useEffect as s,useId as c,useMemo as l,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p({className:n,...r}){return d(`div`,{...r,className:e(t.page(),n),"data-dashboard-page":`true`})}function m({actions:n,children:r,className:i,description:a,headingId:o,title:s,...l}){let u=c(),p=t.section(),m=s!=null||a!=null||n!=null,h=o??`dashboard-section-${k(u)}`;return f(`section`,{...l,className:e(p.root,i),"aria-labelledby":s==null?l[`aria-labelledby`]:h,children:[m?f(`header`,{className:p.header,children:[f(`div`,{children:[s==null?null:d(`h2`,{className:p.heading,id:h,children:s}),a==null?null:d(`p`,{className:p.description,children:a})]}),n==null?null:d(`div`,{className:p.actions,children:n})]}):null,d(`div`,{className:p.content,children:r})]})}const h=r(null);function g({children:n,className:r,id:i,onValueChange:o,orientation:s=`horizontal`,value:f,...p}){let m=c(),g=k(i??`dashboard-tabs-${m}`),_=u(new Map),v=a(e=>{e!==f&&o(e)},[o,f]),y=a((e,t)=>{t?_.current.set(e,t):_.current.delete(e)},[]),b=l(()=>({baseId:g,orientation:s,registerTrigger:y,select:v,triggerRefs:_,value:f}),[g,s,y,v,f]),x=t.tabs();return d(h.Provider,{value:b,children:d(`div`,{...p,className:e(x.root,r),"data-dashboard-tabs":`true`,"data-orientation":s,id:i??g,children:n})})}function _({className:n,...r}){let i=O(),a=t.tabs();return d(`div`,{...r,className:e(a.list,n),role:`tablist`,"aria-orientation":i.orientation})}function v({children:n,className:r,disabled:i=!1,onClick:a,onKeyDown:o,value:c,...l}){let f=O(),p=u(null),m=t.tabs(),h=`${f.baseId}-tab-${k(c)}`,g=`${f.baseId}-panel-${k(c)}`,_=f.value===c;s(()=>(f.registerTrigger(h,p.current),()=>f.registerTrigger(h,null)),[f,h]);function v(e){let t=e.key,n=f.orientation===`horizontal`,r=n&&t===`ArrowRight`||!n&&t===`ArrowDown`?1:n&&t===`ArrowLeft`||!n&&t===`ArrowUp`?-1:0,i=Array.from(f.triggerRefs.current.values()).filter(e=>!e.disabled);if(t!==`Home`&&t!==`End`&&r===0||i.length===0)return;let a=i.indexOf(e.currentTarget),o=i[t===`Home`?0:t===`End`?i.length-1:(a+r+i.length)%i.length];if(!o)return;e.preventDefault(),o.focus();let s=o.dataset.dashboardTabValue;s&&f.select(s)}return d(`button`,{...l,ref:p,className:e(m.trigger,r),type:`button`,role:`tab`,id:h,"aria-controls":g,"aria-selected":_,"data-dashboard-tab-value":c,disabled:i,tabIndex:_?0:-1,onClick:e=>{a?.(e),!e.defaultPrevented&&!i&&f.select(c)},onKeyDown:e=>{o?.(e),e.defaultPrevented||v(e)},children:n})}function y({children:n,className:r,forceMount:i=!1,value:a,...o}){let s=O(),c=t.tabs(),l=`${s.baseId}-panel-${k(a)}`,u=`${s.baseId}-tab-${k(a)}`,f=s.value===a;return!f&&!i?null:d(`div`,{...o,className:e(c.panel,r),id:l,role:`tabpanel`,"aria-labelledby":u,hidden:!f,tabIndex:0,children:n})}const b=Object.assign(g,{List:_,Panel:y,Trigger:v});function x({className:n,role:r=`status`,tone:i=`neutral`,...a}){return d(`span`,{...a,className:e(t.status({tone:i}),n),role:r})}const S=i(function({busy:n=!1,busyLabel:r=`Loading`,children:i,className:a,disabled:o=!1,href:s,size:c=`md`,tone:l=`accent`,variant:u=`solid`,...f},p){let m=f[`aria-label`],h=e(t.button({size:c,tone:l,variant:u}),a);if(s!==void 0){let{onClick:e,...t}=f;return d(`a`,{...t,ref:p,href:s,className:h,"aria-label":n?r:m,"aria-busy":n||void 0,"aria-disabled":o||n||void 0,tabIndex:o||n?-1:t.tabIndex,onClick:t=>{if(o||n){t.preventDefault();return}e?.(t)},children:i})}let{onClick:g,type:_=`button`,...v}=f;return d(`button`,{...v,ref:p,className:h,type:_,disabled:o||n,"aria-label":n?r:m,"aria-busy":n||void 0,onClick:e=>g?.(e),children:i})});function C({children:r,className:i,description:a,error:o,id:s,label:l,required:u=!1,...p}){let m=c(),h=t.field(),g=r.props,_=s??g.id??`dashboard-field-${k(m)}`,v=a==null?void 0:`${_}-description`,y=o==null?void 0:`${_}-error`,b=o!=null&&o!==!1,x=[g[`aria-describedby`],v,y].filter(Boolean).join(` `),S=n(r,{id:_,required:u||g.required,"aria-describedby":x||void 0,"aria-invalid":b||g[`aria-invalid`]||void 0,"aria-required":u||g[`aria-required`]||void 0});return f(`div`,{...p,className:e(h.root,i),"data-invalid":b?`true`:void 0,children:[f(`label`,{className:h.label,htmlFor:_,children:[l,u?d(`span`,{"aria-hidden":`true`,children:` *`}):null]}),S,a==null?null:d(`p`,{className:h.description,id:v,children:a}),b?d(`p`,{className:h.error,id:y,role:`alert`,children:o}):null]})}function w({action:n,children:r,className:i,message:a,title:o,variant:s,...l}){let u=c(),p=(s===`empty`?t.emptyState:t.errorState)(),m=`dashboard-${s}-${k(u)}`;return f(`section`,{...l,className:e(p.root,i),"aria-labelledby":l[`aria-labelledby`]??m,role:s===`error`?`alert`:void 0,children:[d(`h2`,{className:p.title,id:m,children:o}),a==null?null:d(`p`,{className:p.message,children:a}),r,n==null?null:d(`div`,{className:p.action,children:n})]})}function T(e){return d(w,{...e,variant:`empty`})}function E(e){return d(w,{...e,variant:`error`})}function D({busy:n=!1,cancelLabel:r=`Cancel`,children:i,className:a,confirmLabel:o=`Confirm`,confirmTone:l=`danger`,description:p,onConfirm:m,onMouseDown:h,onOpenChange:g,open:_,title:v,...y}){let b=c(),x=t.confirmDialog(),C=u(null),w=u(null),T=u(null),E=u(null),D=`dashboard-confirm-title-${k(b)}`,O=p==null?void 0:`dashboard-confirm-description-${k(b)}`;return s(()=>{if(!_){E.current?.focus(),E.current=null;return}E.current||=document.activeElement instanceof HTMLElement?document.activeElement:null,n?C.current?.focus():w.current?.focus()},[n,_]),s(()=>{if(!_)return;function e(e){if(e.key===`Escape`){if(n)return;e.preventDefault(),g(!1);return}if(e.key!==`Tab`)return;let t=C.current?Array.from(C.current.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[];if(t.length===0)return;let r=t[0],i=t[t.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r?.focus())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,g,_]),_?d(`div`,{...y,className:e(x.backdrop,a),"data-dashboard-confirm-dialog":`true`,onMouseDown:e=>{h?.(e),!e.defaultPrevented&&e.target===e.currentTarget&&!n&&g(!1)},children:f(`div`,{ref:C,className:x.content,role:`dialog`,"aria-modal":`true`,"aria-busy":n||void 0,"aria-labelledby":D,"aria-describedby":O,tabIndex:-1,children:[d(`h2`,{className:x.title,id:D,children:v}),p==null?null:d(`p`,{className:x.description,id:O,children:p}),i,f(`div`,{className:x.actions,children:[d(S,{ref:w,className:x.cancel,variant:`outline`,disabled:n,onClick:()=>g(!1),children:r}),d(S,{ref:T,className:x.confirm,busy:n,tone:l,onClick:()=>void m(),children:o})]})]})}):null}function O(){let e=o(h);if(!e)throw Error(`Dashboard Tabs compound components must be used inside <Tabs>`);return e}function k(e){return e.replace(/[^a-zA-Z0-9_-]/gu,`-`)}export{S as Button,D as ConfirmDialog,T as EmptyState,E as ErrorState,C as Field,p as Page,m as Section,x as Status,b as Tabs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cx as e}from"../styled-system/css/cx.js";import"../../styled-css.js";import{dashboardButton as t}from"../styled-system/recipes/dashboard-button.js";import{dashboardConfirmDialog as n}from"../styled-system/recipes/dashboard-confirm-dialog.js";import{dashboardEmptyState as r}from"../styled-system/recipes/dashboard-empty-state.js";import{dashboardErrorState as i}from"../styled-system/recipes/dashboard-error-state.js";import{dashboardField as a}from"../styled-system/recipes/dashboard-field.js";import{dashboardPage as o}from"../styled-system/recipes/dashboard-page.js";import{dashboardSection as s}from"../styled-system/recipes/dashboard-section.js";import{dashboardStatus as c}from"../styled-system/recipes/dashboard-status.js";import{dashboardTabs as l}from"../styled-system/recipes/dashboard-tabs.js";const u={button:t,confirmDialog:n,emptyState:r,errorState:i,field:a,page:o,section:s,status:c,tabs:l};export{e as cx,u as styles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as e,useRef as t,useState as n}from"react";import{Link as r,NavLink as i,Navigate as a,Outlet as o,isRouteErrorResponse as s,useLocation as c,useNavigation as l,useRouteError as u}from"react-router";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p({pages:r}){let a=c(),s=l(),[u,p]=n(()=>
|
|
1
|
+
import{useEffect as e,useRef as t,useState as n}from"react";import{Link as r,NavLink as i,Navigate as a,Outlet as o,isRouteErrorResponse as s,useLocation as c,useNavigation as l,useRouteError as u}from"react-router";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p({pages:r}){let a=c(),s=l(),[u,p]=n(()=>globalThis.window!==void 0&&globalThis.matchMedia(`(max-width: 47.999rem)`).matches),[m,h]=n(!1),[g,v]=n(!1),y=t(null),b=t(null),x=t(!1),S=_(r,a.pathname);e(()=>{let e=globalThis.matchMedia(`(max-width: 47.999rem)`),t=()=>p(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),e(()=>{u&&(m?b.current?.focus():x.current&&y.current?.focus(),x.current=m)},[u,m]),e(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&h(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m]);let C=u?m:!g;return f(`div`,{className:`coreframe-dashboard`,"data-collapsed":!u&&g?`true`:`false`,"data-drawer-open":u&&m?`true`:`false`,children:[d(`button`,{ref:y,type:`button`,className:`coreframe-dashboard__toggle`,"aria-controls":`coreframe-dashboard-navigation`,"aria-expanded":C,"aria-label":C?`Collapse dashboard navigation`:`Expand dashboard navigation`,onClick:()=>{u?h(e=>!e):v(e=>!e)},children:d(`span`,{"aria-hidden":`true`,children:C?`←`:`☰`})}),d(`button`,{type:`button`,className:`coreframe-dashboard__backdrop`,"aria-label":`Close dashboard navigation`,tabIndex:u&&m?0:-1,onClick:()=>h(!1)}),d(`aside`,{className:`coreframe-dashboard__sidebar`,role:u?`dialog`:void 0,"aria-label":u?`Dashboard navigation`:void 0,"aria-modal":u&&m?!0:void 0,"aria-hidden":u&&!m?!0:void 0,inert:u&&!m?!0:void 0,children:f(`nav`,{ref:b,id:`coreframe-dashboard-navigation`,className:`coreframe-dashboard__navigation`,"aria-label":`Dashboard`,tabIndex:u?-1:void 0,children:[f(`div`,{className:`coreframe-dashboard__brand`,"aria-label":`Coreframe Dashboard`,children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__mark`,children:`C`}),d(`span`,{className:`coreframe-dashboard__navigation-text`,children:`Coreframe`})]}),r.length>0?d(`ul`,{className:`coreframe-dashboard__navigation-list`,children:r.map(e=>d(`li`,{children:f(i,{className:`coreframe-dashboard__navigation-link`,to:`/${e.path}`,onClick:()=>h(!1),children:[d(`span`,{"aria-hidden":`true`,className:`coreframe-dashboard__navigation-dot`}),d(`span`,{className:`coreframe-dashboard__navigation-text`,children:e.title})]})},e.id))}):d(`p`,{className:`coreframe-dashboard__navigation-empty`,children:`No pages`})]})}),f(`main`,{className:`coreframe-dashboard__main`,children:[S?f(`header`,{className:`coreframe-dashboard__page-header`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),d(`h1`,{children:S.title}),S.description?d(`p`,{children:S.description}):null]}):null,s.state===`idle`?null:d(`div`,{className:`coreframe-dashboard__pending`,role:`status`,children:`Loading page…`}),d(`div`,{className:`coreframe-dashboard__content`,children:d(o,{})})]})]})}function m({pages:e}){let t=e[0];return t?d(a,{replace:!0,to:`/${t.path}`}):d(h,{})}function h(){return f(`section`,{className:`coreframe-dashboard__state`,"aria-labelledby":`dashboard-empty-title`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Dashboard`}),d(`h1`,{id:`dashboard-empty-title`,children:`No dashboard pages yet`}),f(`p`,{children:[`Add a page under `,d(`code`,{children:`dashboard/pages/`}),` or register a plugin in`,` `,d(`code`,{children:`dashboard.config.ts`}),`.`]})]})}function g(){let e=u(),t=s(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 f(`main`,{className:`coreframe-dashboard__state`,children:[d(`p`,{className:`coreframe-dashboard__eyebrow`,children:`Coreframe Dashboard`}),d(`h1`,{children:t?`Page not found`:`Dashboard unavailable`}),d(`p`,{children:n}),d(r,{className:`coreframe-dashboard__button`,to:`/`,children:`Go to dashboard`})]})}function _(e,t){let n=t.split(`/`).filter(Boolean)[0];return e.find(e=>e.path===n)??(n?void 0:e[0])}export{h as DashboardEmptyState,g as DashboardErrorBoundary,m as DashboardIndexRedirect,p as DashboardShell};
|
package/dist/package/worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{getDashboardRequestId as t,isSameOriginDashboardMutation as n}from"./host-policy.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(n){let r=e(n.plugins,{getRequestId:t});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,t,a,o,s){if(!t.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,t.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return n(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,t,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!t.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await t.ASSETS.fetch(new Request(a,e)),d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createDashboardWorkerHandler,s as handleDashboardRequest};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/dashboard",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/coreframe-js/coreframe.git",
|
|
8
8
|
"directory": "node/dashboard"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -36,10 +36,18 @@
|
|
|
36
36
|
"types": "./dist/package/plugin-api.d.ts",
|
|
37
37
|
"default": "./dist/package/plugin-api.js"
|
|
38
38
|
},
|
|
39
|
+
"./app-client": {
|
|
40
|
+
"types": "./dist/package/app-client.d.ts",
|
|
41
|
+
"default": "./dist/package/app-client.js"
|
|
42
|
+
},
|
|
39
43
|
"./web": {
|
|
40
44
|
"types": "./dist/package/web-shell/index.d.ts",
|
|
41
45
|
"default": "./dist/package/web-shell/index.js"
|
|
42
46
|
},
|
|
47
|
+
"./ui": {
|
|
48
|
+
"types": "./dist/package/web/ui/index.d.ts",
|
|
49
|
+
"default": "./dist/package/web/ui/index.js"
|
|
50
|
+
},
|
|
43
51
|
"./app": {
|
|
44
52
|
"types": "./dist/package/app/index.d.ts",
|
|
45
53
|
"default": "./dist/package/app/index.js"
|
|
@@ -75,8 +83,9 @@
|
|
|
75
83
|
"rouzer": "^6.0.1",
|
|
76
84
|
"yaml": "^2.9.0",
|
|
77
85
|
"zod": "^4.4.3",
|
|
86
|
+
"@coreframe/deploy": "0.1.10",
|
|
78
87
|
"@coreframe/diagnostics": "0.2.3",
|
|
79
|
-
"@coreframe/
|
|
88
|
+
"@coreframe/lib": "^0.2.12"
|
|
80
89
|
},
|
|
81
90
|
"devDependencies": {
|
|
82
91
|
"@pandacss/dev": "2.0.0-beta.8",
|
|
@@ -89,7 +98,8 @@
|
|
|
89
98
|
"tsdown": "0.22.3",
|
|
90
99
|
"typescript": "6.0.3",
|
|
91
100
|
"vite": "^8.1.4",
|
|
92
|
-
"vitest": "^4.1.10"
|
|
101
|
+
"vitest": "^4.1.10",
|
|
102
|
+
"@coreframe/panda": "0.1.5"
|
|
93
103
|
},
|
|
94
104
|
"scripts": {
|
|
95
105
|
"build": "pnpm --dir ../diagnostics build && pnpm build:server && pnpm build:check",
|