basalt-ui 2.16.0 → 2.18.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/CHANGELOG.md +165 -124
- package/MIGRATING.md +133 -15
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +3 -3
- package/configs/oxlint-plugin.js +2 -2
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +2 -2
- package/dist/charts/DualPanel.js +2 -2
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +2 -2
- package/dist/charts/MirroredBars.js +2 -2
- package/dist/charts/Sparkline.d.ts +4 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +3 -3
- package/dist/charts/compile.d.ts +8 -3
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +19 -9
- package/dist/charts/cursor.d.ts +14 -1
- package/dist/charts/cursor.d.ts.map +1 -1
- package/dist/charts/cursor.js +29 -3
- package/dist/charts/date-tick-format.d.ts +17 -0
- package/dist/charts/date-tick-format.d.ts.map +1 -0
- package/dist/charts/date-tick-format.js +81 -0
- package/dist/charts/panel.d.ts +2 -1
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +3 -2
- package/dist/charts/types.d.ts +5 -1
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -2
- package/dist/cli/shot/capture.d.ts +28 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +96 -13
- package/dist/cli/shot/index.d.ts +10 -1
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +40 -5
- package/dist/cli/shot/playwright.d.ts +4 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/real-data.d.ts +35 -0
- package/dist/cli/shot/real-data.d.ts.map +1 -0
- package/dist/cli/shot/real-data.js +120 -0
- package/dist/cli/shot/serve.d.ts +2 -2
- package/dist/cli/shot/serve.d.ts.map +1 -1
- package/dist/cli/shot/serve.js +16 -2
- package/dist/dashboard/bar-list.d.ts +29 -0
- package/dist/dashboard/bar-list.d.ts.map +1 -0
- package/dist/dashboard/bar-list.js +52 -0
- package/dist/dashboard/bar-list.module.css +73 -0
- package/dist/dashboard/bar-list.module.css.d.ts +16 -0
- package/dist/dashboard/delta-badge.d.ts +2 -2
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +12 -14
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-model.d.ts +78 -0
- package/dist/dashboard/meter-model.d.ts.map +1 -0
- package/dist/dashboard/meter-model.js +91 -0
- package/dist/dashboard/meter-parts.d.ts +42 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -0
- package/dist/dashboard/meter-parts.js +163 -0
- package/dist/dashboard/meter.d.ts +112 -0
- package/dist/dashboard/meter.d.ts.map +1 -0
- package/dist/dashboard/meter.js +43 -0
- package/dist/dashboard/meter.module.css +150 -0
- package/dist/dashboard/meter.module.css.d.ts +28 -0
- package/dist/dashboard/query-state.d.ts +35 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +12 -1
- package/dist/dashboard/scale.d.ts +9 -0
- package/dist/dashboard/scale.d.ts.map +1 -0
- package/dist/dashboard/scale.js +10 -0
- package/dist/dashboard/stat-card-parts.d.ts +40 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -0
- package/dist/dashboard/stat-card-parts.js +55 -0
- package/dist/dashboard/stat-card.d.ts +46 -34
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +148 -79
- package/dist/dashboard/stat-card.module.css +220 -7
- package/dist/dashboard/stat-card.module.css.d.ts +20 -0
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +73 -9
- package/dist/dashboard/widget-header.module.css +25 -17
- package/dist/guard/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/theme/chrome-vars.d.ts +82 -0
- package/dist/theme/chrome-vars.d.ts.map +1 -0
- package/dist/theme/chrome-vars.js +36 -0
- package/dist/theme/controls.module.css +20 -1
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +30 -33
- package/dist/tokens/derive.d.ts +11 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +9 -24
- package/dist/tokens/status-text.d.ts +26 -0
- package/dist/tokens/status-text.d.ts.map +1 -0
- package/dist/tokens/status-text.js +68 -0
- package/llms.txt +36 -4
- package/package.json +1 -1
- package/src/charts/Donut.tsx +2 -2
- package/src/charts/DualPanel.tsx +2 -2
- package/src/charts/Heatmap.tsx +2 -2
- package/src/charts/MirroredBars.tsx +2 -2
- package/src/charts/Sparkline.tsx +7 -5
- package/src/charts/compile.ts +31 -11
- package/src/charts/cursor.ts +48 -3
- package/src/charts/date-tick-format.ts +132 -0
- package/src/charts/panel.tsx +5 -3
- package/src/charts/types.ts +5 -1
- package/src/cli/help.ts +22 -2
- package/src/cli/shot/capture.ts +133 -12
- package/src/cli/shot/index.ts +50 -4
- package/src/cli/shot/playwright.ts +1 -1
- package/src/cli/shot/real-data.ts +165 -0
- package/src/cli/shot/serve.ts +28 -3
- package/src/dashboard/bar-list.module.css +73 -0
- package/src/dashboard/bar-list.module.css.d.ts +16 -0
- package/src/dashboard/bar-list.tsx +112 -0
- package/src/dashboard/delta-badge.tsx +24 -18
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +161 -0
- package/src/dashboard/meter-parts.tsx +223 -0
- package/src/dashboard/meter.module.css +150 -0
- package/src/dashboard/meter.module.css.d.ts +28 -0
- package/src/dashboard/meter.tsx +162 -0
- package/src/dashboard/query-state.tsx +38 -0
- package/src/dashboard/scale.ts +13 -0
- package/src/dashboard/stat-card-parts.tsx +108 -0
- package/src/dashboard/stat-card.module.css +220 -7
- package/src/dashboard/stat-card.module.css.d.ts +20 -0
- package/src/dashboard/stat-card.tsx +282 -174
- package/src/dashboard/widget-header.module.css +25 -17
- package/src/dashboard/widget-header.tsx +103 -7
- package/src/guard/index.ts +2 -2
- package/src/index.ts +4 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +128 -40
- package/src/theme/chrome-vars.ts +111 -0
- package/src/theme/controls.module.css +20 -1
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +39 -101
- package/src/tokens/derive.ts +19 -26
- package/src/tokens/status-text.ts +85 -0
package/dist/cli/shot/index.js
CHANGED
|
@@ -15,12 +15,13 @@ import { parseArgs } from "node:util";
|
|
|
15
15
|
import { buildBoard } from "./board.js";
|
|
16
16
|
import { capture } from "./capture.js";
|
|
17
17
|
import { INSTALL_LINE, ShotError, resolvePlaywright, withBrowser } from "./playwright.js";
|
|
18
|
+
import { apiProxy, parseApi, parseHeaders, parseStorage } from "./real-data.js";
|
|
18
19
|
import { serveDist } from "./serve.js";
|
|
19
20
|
import { SCHEMES, STATES, VIEWPORTS } from "./types.js";
|
|
20
21
|
const HOME = ".basalt/shots";
|
|
21
22
|
const DEFAULT_OUT = `${HOME}/latest`;
|
|
22
|
-
const USAGE_LINE = "usage: basalt-ui shot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]";
|
|
23
|
-
function parseShotArgs(flags) {
|
|
23
|
+
const USAGE_LINE = "usage: basalt-ui shot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>] [--local-storage k=@env:X] [--api /p=origin] [--header n=@env:X] [--api-allow-writes] [--wait ms] [--auto-anchors]";
|
|
24
|
+
function parseShotArgs(flags, src = { env: process.env, cwd: process.cwd() }) {
|
|
24
25
|
let parsed;
|
|
25
26
|
try {
|
|
26
27
|
parsed = parseArgs({
|
|
@@ -30,7 +31,13 @@ function parseShotArgs(flags) {
|
|
|
30
31
|
base: { type: "string" },
|
|
31
32
|
dist: { type: "string" },
|
|
32
33
|
out: { type: "string" },
|
|
33
|
-
states: { type: "string" }
|
|
34
|
+
states: { type: "string" },
|
|
35
|
+
"local-storage": { type: "string", multiple: true },
|
|
36
|
+
api: { type: "string", multiple: true },
|
|
37
|
+
header: { type: "string", multiple: true },
|
|
38
|
+
wait: { type: "string" },
|
|
39
|
+
"auto-anchors": { type: "boolean" },
|
|
40
|
+
"api-allow-writes": { type: "boolean" }
|
|
34
41
|
}
|
|
35
42
|
});
|
|
36
43
|
} catch (error) {
|
|
@@ -51,8 +58,31 @@ ${USAGE_LINE}`);
|
|
|
51
58
|
const states = values.states ? values.states.split(",").map((s) => s.trim()).filter(Boolean) : [...STATES];
|
|
52
59
|
const unknown = states.find((s) => !STATES.includes(s));
|
|
53
60
|
if (unknown) throw new ShotError(`unknown state '${unknown}'. Known: ${STATES.join(", ")}`);
|
|
61
|
+
const secrets = (values.header?.length ?? 0) + (values["local-storage"]?.length ?? 0) > 0;
|
|
62
|
+
const api = parseApi(values.api ?? [], secrets);
|
|
63
|
+
if (api.length > 0 && !values.dist)
|
|
64
|
+
throw new ShotError(`--api needs --dist (it proxies the static server).
|
|
65
|
+
${USAGE_LINE}`);
|
|
66
|
+
if ((values.header?.length ?? 0) > 0 && new Set(api.map((r) => r.origin)).size > 1)
|
|
67
|
+
throw new ShotError(
|
|
68
|
+
`--header goes to every --api origin; it is refused when --api names more than one.
|
|
69
|
+
${USAGE_LINE}`
|
|
70
|
+
);
|
|
71
|
+
if ((values.header?.length ?? 0) > 0 && api.length === 0)
|
|
72
|
+
throw new ShotError(`--header is sent on --api requests only; pass --api.
|
|
73
|
+
${USAGE_LINE}`);
|
|
74
|
+
const wait = values.wait ?? "networkidle";
|
|
75
|
+
if (wait !== "networkidle" && !/^\d+$/.test(wait))
|
|
76
|
+
throw new ShotError(`--wait takes milliseconds or 'networkidle'.
|
|
77
|
+
${USAGE_LINE}`);
|
|
54
78
|
return {
|
|
55
79
|
routes: positionals,
|
|
80
|
+
localStorage: parseStorage(values["local-storage"] ?? [], src),
|
|
81
|
+
api,
|
|
82
|
+
headers: parseHeaders(values.header ?? [], src),
|
|
83
|
+
wait: wait === "networkidle" ? 0 : Number(wait),
|
|
84
|
+
allowWrites: values["api-allow-writes"] ?? false,
|
|
85
|
+
autoAnchors: values["auto-anchors"] ?? false,
|
|
56
86
|
...values.base ? { base: values.base.replace(/\/+$/, "") } : {},
|
|
57
87
|
...values.dist ? { dist: values.dist } : {},
|
|
58
88
|
out: values.out ?? DEFAULT_OUT,
|
|
@@ -198,14 +228,15 @@ async function shot(flags, cwd, deps = {}) {
|
|
|
198
228
|
const stops = [];
|
|
199
229
|
const uninstall = exitOnSignal(stops);
|
|
200
230
|
try {
|
|
201
|
-
const args = parseShotArgs(flags);
|
|
231
|
+
const args = parseShotArgs(flags, { env: process.env, cwd });
|
|
202
232
|
const outDir = planOut(cwd, args.out);
|
|
203
233
|
recoverOut(outDir);
|
|
204
234
|
const pw = (deps.resolve ?? resolvePlaywright)(cwd);
|
|
205
235
|
if (!pw) throw new ShotError(INSTALL_LINE);
|
|
206
236
|
const now = (deps.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
207
237
|
sweepStaleTmp(join(cwd, HOME), now);
|
|
208
|
-
const
|
|
238
|
+
const proxy = args.api.length > 0 ? apiProxy(args.api, args.headers, { log, allowWrites: args.allowWrites }) : null;
|
|
239
|
+
const server = args.dist ? serveDist(resolve(cwd, args.dist), proxy?.handle) : null;
|
|
209
240
|
if (server) stops.push(server.stop);
|
|
210
241
|
let tmp = "";
|
|
211
242
|
stops.push(() => tmp && rmSync(tmp, { recursive: true, force: true }));
|
|
@@ -226,6 +257,10 @@ async function shot(flags, cwd, deps = {}) {
|
|
|
226
257
|
routes: args.routes,
|
|
227
258
|
states: args.states,
|
|
228
259
|
pngDir: join(tmp, "png"),
|
|
260
|
+
localStorage: args.localStorage,
|
|
261
|
+
wait: args.wait,
|
|
262
|
+
autoAnchors: args.autoAnchors,
|
|
263
|
+
...proxy && { apiProblems: proxy.drain },
|
|
229
264
|
log
|
|
230
265
|
});
|
|
231
266
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/playwright.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,YAAY,+FACqE,CAAA;AAI9F,MAAM,MAAM,GAAG,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,GAAG,CAAA;CACX,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,IAAI,SAAS,CAAA;IAClB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACxB,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/playwright.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,YAAY,+FACqE,CAAA;AAI9F,MAAM,MAAM,GAAG,GAAG;I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AAC,CAAC,SAAS,SAAS,EAAE,CAAC,EACtD,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,EACjB,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC/C,EAAE,QAAgC,EAAE,KAAK,EAAE,GAAE,aAAkB,GAC9D,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ApiRoute = {
|
|
2
|
+
prefix: string;
|
|
3
|
+
origin: string;
|
|
4
|
+
};
|
|
5
|
+
export type Pair = readonly [name: string, value: string];
|
|
6
|
+
export type Source = {
|
|
7
|
+
env: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
cwd: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const parseStorage: (list: readonly string[], src: Source) => Pair[];
|
|
11
|
+
/** `--header` pairs: a valid, forwardable name and a value that cannot split the request. */
|
|
12
|
+
export declare const parseHeaders: (list: readonly string[], src: Source) => Pair[];
|
|
13
|
+
/** `--api <prefix>=<origin>`; with any secret configured (`--header`, `--local-storage`), a remote origin must be https. */
|
|
14
|
+
export declare function parseApi(list: readonly string[], secrets: boolean): ApiRoute[];
|
|
15
|
+
export type ApiProxy = {
|
|
16
|
+
handle: (req: Request) => Promise<Response | null>;
|
|
17
|
+
/** The calls since the last drain that make a board untrustworthy: a 3xx, 401, 403, 404, 5xx or no answer. */
|
|
18
|
+
drain: () => string[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The static server's API hook: a GET/HEAD under a prefix goes to `<origin><path>?<query>` with the
|
|
22
|
+
* `--header` values added, except on a navigation; any other method is a 405 unless `allowWrites`.
|
|
23
|
+
* Anything else is null (served from `--dist`). Every non-2xx or failed call is logged by method,
|
|
24
|
+
* path and status or error class, never a header or a query.
|
|
25
|
+
*/
|
|
26
|
+
export declare function apiProxy(api: readonly ApiRoute[], headers: readonly Pair[], opts: {
|
|
27
|
+
log: (line: string) => void;
|
|
28
|
+
allowWrites?: boolean;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}): ApiProxy;
|
|
31
|
+
/** The page global the seed script reports through: `origin`, or the keys it could not set. */
|
|
32
|
+
export declare const SEED_FLAG = "__shotSeedFailed";
|
|
33
|
+
/** The init script that seeds localStorage, only on `origin` and only for an absent key (a token the app rotates survives), before any page script runs. */
|
|
34
|
+
export declare const seedScript: (entries: readonly Pair[], origin: string) => string;
|
|
35
|
+
//# sourceMappingURL=real-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-data.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/real-data.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AACzD,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACzD,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAyBvF,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,KAAK,MAAM,KAAG,IAAI,EAIpE,CAAA;AAMJ,6FAA6F;AAC7F,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,KAAK,MAAM,KAAG,IAAI,EASpE,CAAA;AAIJ,4HAA4H;AAC5H,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,EAAE,CAmB9E;AAaD,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;IAClD,8GAA8G;IAC9G,KAAK,EAAE,MAAM,MAAM,EAAE,CAAA;CACtB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,SAAS,QAAQ,EAAE,EACxB,OAAO,EAAE,SAAS,IAAI,EAAE,EACxB,IAAI,EAAE;IAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/E,QAAQ,CAiDV;AAED,+FAA+F;AAC/F,eAAO,MAAM,SAAS,qBAAqB,CAAA;AAE3C,4JAA4J;AAC5J,eAAO,MAAM,UAAU,GAAI,SAAS,SAAS,IAAI,EAAE,EAAE,QAAQ,MAAM,KAAG,MAGf,CAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { ShotError } from "./playwright.js";
|
|
4
|
+
function splitPair(flag, raw) {
|
|
5
|
+
const at = raw.indexOf("=");
|
|
6
|
+
if (at <= 0) throw new ShotError(`--${flag} expects <name>=<value>`);
|
|
7
|
+
return [raw.slice(0, at), raw.slice(at + 1)];
|
|
8
|
+
}
|
|
9
|
+
function resolveValue(flag, raw, src) {
|
|
10
|
+
const [, kind, ref = ""] = /^@(env|file):(.*)$/s.exec(raw) ?? [];
|
|
11
|
+
let value;
|
|
12
|
+
if (kind === "env") value = Object.hasOwn(src.env, ref) ? src.env[ref] : void 0;
|
|
13
|
+
else if (kind === "file") {
|
|
14
|
+
try {
|
|
15
|
+
value = readFileSync(resolve(src.cwd, ref), "utf8").trim();
|
|
16
|
+
} catch {
|
|
17
|
+
throw new ShotError(`--${flag}: cannot read @file:${ref}`);
|
|
18
|
+
}
|
|
19
|
+
} else throw new ShotError(`--${flag} takes @env:NAME or @file:path, never a literal`);
|
|
20
|
+
if (!value) throw new ShotError(`--${flag}: ${raw} is empty`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
const parseStorage = (list, src) => list.map((raw) => {
|
|
24
|
+
const [key, value] = splitPair("local-storage", raw);
|
|
25
|
+
return [key, resolveValue("local-storage", value, src)];
|
|
26
|
+
});
|
|
27
|
+
const NOT_FORWARDED = /* @__PURE__ */ new Set(["host", "origin", "referer", "connection", "content-length"]);
|
|
28
|
+
const HEADER_NAME = /^[!#$%&'*+.^_`|~\w-]+$/;
|
|
29
|
+
const HEADER_VALUE = /^[\t\x20-\x7e]*$/;
|
|
30
|
+
const parseHeaders = (list, src) => list.map((raw) => {
|
|
31
|
+
const [name, value] = splitPair("header", raw);
|
|
32
|
+
if (!HEADER_NAME.test(name) || NOT_FORWARDED.has(name.toLowerCase()))
|
|
33
|
+
throw new ShotError(`--header ${name}: not a header shot can send`);
|
|
34
|
+
const resolved = resolveValue("header", value, src);
|
|
35
|
+
if (!HEADER_VALUE.test(resolved))
|
|
36
|
+
throw new ShotError(`--header ${name}: value has characters a header cannot carry`);
|
|
37
|
+
return [name, resolved];
|
|
38
|
+
});
|
|
39
|
+
const LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
40
|
+
function parseApi(list, secrets) {
|
|
41
|
+
return list.map((raw) => {
|
|
42
|
+
const [given, target] = splitPair("api", raw);
|
|
43
|
+
const prefix = given.replace(/\/+$/, "");
|
|
44
|
+
if (!prefix.startsWith("/"))
|
|
45
|
+
throw new ShotError('--api prefix must start with "/" and name a path, not "/"');
|
|
46
|
+
let url;
|
|
47
|
+
try {
|
|
48
|
+
url = new URL(target ?? "");
|
|
49
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("protocol");
|
|
50
|
+
} catch {
|
|
51
|
+
throw new ShotError("--api <prefix>=<origin>: origin must be an http(s) URL");
|
|
52
|
+
}
|
|
53
|
+
if (secrets && url.protocol !== "https:" && !LOOPBACK.has(url.hostname))
|
|
54
|
+
throw new ShotError(
|
|
55
|
+
`--api ${prefix}: with a secret configured (--header, --local-storage) the origin must be https (loopback excepted)`
|
|
56
|
+
);
|
|
57
|
+
return { prefix, origin: url.origin };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const NOT_RETURNED = ["content-encoding", "content-length", "transfer-encoding"];
|
|
61
|
+
const READ_ONLY = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
62
|
+
const UNTRUSTED = (status) => status >= 500 || status >= 300 && status < 400 || status === 401 || status === 403 || status === 404;
|
|
63
|
+
const TIMEOUT_MS = 2e4;
|
|
64
|
+
function apiProxy(api, headers, opts) {
|
|
65
|
+
let problems = [];
|
|
66
|
+
const handle = async (req) => {
|
|
67
|
+
const url = new URL(req.url);
|
|
68
|
+
const route = api.find(
|
|
69
|
+
(r) => url.pathname === r.prefix || url.pathname.startsWith(r.prefix + "/")
|
|
70
|
+
);
|
|
71
|
+
if (!route) return null;
|
|
72
|
+
const depth = url.pathname.slice(route.prefix.length).split("/").filter(Boolean).length;
|
|
73
|
+
const label = `${req.method} ${route.prefix} +${depth}`;
|
|
74
|
+
if (!opts.allowWrites && !READ_ONLY.has(req.method)) {
|
|
75
|
+
opts.log(`[shot] api ${label} blocked: read-only run (--api-allow-writes lifts it)`);
|
|
76
|
+
return new Response("read-only", { status: 405 });
|
|
77
|
+
}
|
|
78
|
+
const out = new Headers();
|
|
79
|
+
for (const [name, value] of req.headers) if (!NOT_FORWARDED.has(name)) out.set(name, value);
|
|
80
|
+
const navigating = req.headers.get("sec-fetch-mode") === "navigate" || req.headers.get("sec-fetch-dest") === "document";
|
|
81
|
+
if (!navigating) for (const [name, value] of headers) out.set(name, value);
|
|
82
|
+
try {
|
|
83
|
+
const res = await fetch(route.origin + url.pathname + url.search, {
|
|
84
|
+
method: req.method,
|
|
85
|
+
headers: out,
|
|
86
|
+
redirect: "manual",
|
|
87
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? TIMEOUT_MS),
|
|
88
|
+
...READ_ONLY.has(req.method) ? {} : { body: await req.arrayBuffer() }
|
|
89
|
+
});
|
|
90
|
+
if (!res.ok) opts.log(`[shot] api ${label} \u2192 ${res.status}`);
|
|
91
|
+
if (UNTRUSTED(res.status)) problems.push(`${label} ${res.status}`);
|
|
92
|
+
const back = new Headers(res.headers);
|
|
93
|
+
for (const name of NOT_RETURNED) back.delete(name);
|
|
94
|
+
return new Response(res.body, { status: res.status, headers: back });
|
|
95
|
+
} catch (error) {
|
|
96
|
+
const kind = error instanceof Error ? error.name : "Error";
|
|
97
|
+
opts.log(`[shot] api ${label} failed: ${kind}`);
|
|
98
|
+
problems.push(`${label} ${kind}`);
|
|
99
|
+
return new Response("proxy error", { status: 502 });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
handle,
|
|
104
|
+
drain: () => {
|
|
105
|
+
const seen = problems;
|
|
106
|
+
problems = [];
|
|
107
|
+
return seen;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const SEED_FLAG = "__shotSeedFailed";
|
|
112
|
+
const seedScript = (entries, origin) => `(()=>{if(location.origin!==${JSON.stringify(origin)}){globalThis.${SEED_FLAG}='origin';return}const f=[];for(const [k,v] of ${JSON.stringify(entries)}){try{if(localStorage.getItem(k)===null)localStorage.setItem(k,v)}catch{f.push(k)}}if(f.length)globalThis.${SEED_FLAG}=f.join(',')})()`;
|
|
113
|
+
export {
|
|
114
|
+
SEED_FLAG,
|
|
115
|
+
apiProxy,
|
|
116
|
+
parseApi,
|
|
117
|
+
parseHeaders,
|
|
118
|
+
parseStorage,
|
|
119
|
+
seedScript
|
|
120
|
+
};
|
package/dist/cli/shot/serve.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** Static server for a built SPA dir: real files as-is, extensionless misses fall back to index.html. */
|
|
2
|
-
export declare function serveDist(distDir: string): {
|
|
1
|
+
/** Static server for a built SPA dir: real files as-is, extensionless misses fall back to index.html; `proxy` answers first. */
|
|
2
|
+
export declare function serveDist(distDir: string, proxy?: (req: Request) => Promise<Response | null>): {
|
|
3
3
|
origin: string;
|
|
4
4
|
stop: () => void;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/serve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/serve.ts"],"names":[],"mappings":"AAsBA,gIAAgI;AAChI,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GACjD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CAiCtC"}
|
package/dist/cli/shot/serve.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { existsSync, statSync } from "node:fs";
|
|
2
2
|
import { join, normalize, resolve, sep } from "node:path";
|
|
3
3
|
import { ShotError } from "./playwright.js";
|
|
4
|
-
|
|
4
|
+
const FETCH_MODES = /* @__PURE__ */ new Set(["cors", "same-origin", "navigate"]);
|
|
5
|
+
function fromOwnBrowser(req, own) {
|
|
6
|
+
const origin = req.headers.get("origin");
|
|
7
|
+
const mode = req.headers.get("sec-fetch-mode");
|
|
8
|
+
const site = req.headers.get("sec-fetch-site");
|
|
9
|
+
if (req.headers.get("host") !== own) return false;
|
|
10
|
+
if (origin !== null) return origin === `http://${own}`;
|
|
11
|
+
if (site === "cross-site") return false;
|
|
12
|
+
return mode === null || FETCH_MODES.has(mode) || site === "same-origin";
|
|
13
|
+
}
|
|
14
|
+
function serveDist(distDir, proxy) {
|
|
5
15
|
const root = resolve(distDir);
|
|
6
16
|
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
7
17
|
throw new ShotError(`--dist ${distDir} is not a directory`);
|
|
@@ -17,8 +27,12 @@ function serveDist(distDir) {
|
|
|
17
27
|
const server = Bun.serve({
|
|
18
28
|
port: 0,
|
|
19
29
|
hostname: "127.0.0.1",
|
|
20
|
-
fetch(req) {
|
|
30
|
+
async fetch(req) {
|
|
21
31
|
try {
|
|
32
|
+
const own = `127.0.0.1:${server.port}`;
|
|
33
|
+
if (proxy && !fromOwnBrowser(req, own)) return new Response("forbidden", { status: 403 });
|
|
34
|
+
const proxied = await proxy?.(req);
|
|
35
|
+
if (proxied) return proxied;
|
|
22
36
|
const file = fileFor(new URL(req.url).pathname);
|
|
23
37
|
return file ? new Response(Bun.file(file), { headers: { "cache-control": "no-store" } }) : new Response("not found", { status: 404 });
|
|
24
38
|
} catch {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BasaltProps } from '../common/props.js';
|
|
3
|
+
type BarListItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: number;
|
|
6
|
+
secondary?: ReactNode;
|
|
7
|
+
key?: string;
|
|
8
|
+
};
|
|
9
|
+
export type BarListProps = BasaltProps & {
|
|
10
|
+
/** Accessible name of the list. Required. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Rows in display order (sort them yourself; the list does not reorder). */
|
|
13
|
+
items: readonly BarListItem[];
|
|
14
|
+
/** Formats each value. Default: the number as written. */
|
|
15
|
+
format?: (value: number) => string;
|
|
16
|
+
/** Scale end shared by every bar. Default: the largest value. */
|
|
17
|
+
max?: number;
|
|
18
|
+
/** The first row's bar takes the accent. Off by default. */
|
|
19
|
+
accentLeader?: boolean;
|
|
20
|
+
/** Renders row-shaped skeletons. */
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
/** Skeleton rows while loading. Default 5. */
|
|
23
|
+
loadingRows?: number;
|
|
24
|
+
/** Muted line shown when `items` is empty. */
|
|
25
|
+
emptyText?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function BarList({ label, items, format, max, accentLeader, loading, loadingRows, emptyText, className, style, }: BarListProps): import("react").JSX.Element;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=bar-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-list.d.ts","sourceRoot":"","sources":["../../src/dashboard/bar-list.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIlD,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAExF,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;IAC7B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,KAAK,EACL,MAAe,EACf,GAAG,EACH,YAAoB,EACpB,OAAe,EACf,WAAe,EACf,SAAqB,EACrB,SAAS,EACT,KAAK,GACN,EAAE,YAAY,+BAkDd"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton, VisuallyHidden } from "@mantine/core";
|
|
3
|
+
import { cx } from "../common/props.js";
|
|
4
|
+
import classes from "./bar-list.module.css";
|
|
5
|
+
import { asText, barPercent } from "./scale.js";
|
|
6
|
+
function BarList({
|
|
7
|
+
label,
|
|
8
|
+
items,
|
|
9
|
+
format = asText,
|
|
10
|
+
max,
|
|
11
|
+
accentLeader = false,
|
|
12
|
+
loading = false,
|
|
13
|
+
loadingRows = 5,
|
|
14
|
+
emptyText = "No data",
|
|
15
|
+
className,
|
|
16
|
+
style
|
|
17
|
+
}) {
|
|
18
|
+
if (loading) {
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", { className: cx(classes.root, className), style, "aria-busy": "true", children: [
|
|
20
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${label}` }),
|
|
21
|
+
Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonRow, "data-bar-skeleton": true }, i))
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
if (items.length === 0) {
|
|
25
|
+
return /* @__PURE__ */ jsx("output", { className: cx(classes.root, className), style, "aria-label": label, children: /* @__PURE__ */ jsx("span", { className: classes.empty, children: emptyText }) });
|
|
26
|
+
}
|
|
27
|
+
const scale = max ?? items.reduce((top, i) => Number.isFinite(i.value) ? Math.max(top, i.value) : top, 0);
|
|
28
|
+
return (
|
|
29
|
+
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
30
|
+
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
31
|
+
/* @__PURE__ */ jsx("ul", { className: cx(classes.root, className), style, role: "list", "aria-label": label, children: items.map((item, i) => {
|
|
32
|
+
const isLeader = accentLeader && i === 0;
|
|
33
|
+
return /* @__PURE__ */ jsxs("li", { className: classes.row, children: [
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
"span",
|
|
36
|
+
{
|
|
37
|
+
className: cx(classes.bar, isLeader && classes.leader),
|
|
38
|
+
style: { width: `${barPercent(item.value, scale)}%` },
|
|
39
|
+
"data-bar-leader": isLeader ? "" : void 0,
|
|
40
|
+
"aria-hidden": true
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ jsx("span", { className: classes.label, title: item.label, children: item.label }),
|
|
44
|
+
/* @__PURE__ */ jsx("span", { className: classes.value, children: Number.isFinite(item.value) ? format(item.value) : "\u2014" }),
|
|
45
|
+
item.secondary !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.secondary, children: item.secondary })
|
|
46
|
+
] }, item.key ?? `${item.label}-${i}`);
|
|
47
|
+
}) })
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
BarList
|
|
52
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* BarList — ranked rows on one shared scale (docs/waves/design-parity/SPEC.md § 6.4). The bar sits
|
|
3
|
+
* BEHIND the label and value; the row never wraps: the label truncates, the value is nowrap.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.root {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.row {
|
|
17
|
+
position: relative;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--vx-space-control-gap, 0.375rem);
|
|
21
|
+
min-width: 0;
|
|
22
|
+
min-height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
|
|
23
|
+
padding-inline: var(--vx-space-stack-sm);
|
|
24
|
+
font-size: var(--vx-text-sm);
|
|
25
|
+
color: var(--vx-ink);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.bar {
|
|
29
|
+
position: absolute;
|
|
30
|
+
inset-block: 0;
|
|
31
|
+
inset-inline-start: 0;
|
|
32
|
+
border-radius: var(--vx-radius-fine);
|
|
33
|
+
background: color-mix(in srgb, var(--vx-line) 30%, transparent);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.leader {
|
|
37
|
+
background: color-mix(in srgb, var(--vx-accent) 28%, transparent);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.label {
|
|
41
|
+
position: relative;
|
|
42
|
+
flex: 1 1 0;
|
|
43
|
+
min-width: 0;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.value {
|
|
50
|
+
position: relative;
|
|
51
|
+
flex: none;
|
|
52
|
+
font-family: var(--basalt-font-mono);
|
|
53
|
+
text-align: end;
|
|
54
|
+
white-space: nowrap;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.secondary {
|
|
58
|
+
position: relative;
|
|
59
|
+
flex: none;
|
|
60
|
+
font-family: var(--basalt-font-mono);
|
|
61
|
+
font-size: var(--vx-text-xs);
|
|
62
|
+
color: var(--vx-muted);
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.empty {
|
|
67
|
+
font-size: var(--vx-text-sm);
|
|
68
|
+
color: var(--vx-muted);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.skeletonRow {
|
|
72
|
+
height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
|
|
73
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly root: string
|
|
7
|
+
readonly row: string
|
|
8
|
+
readonly bar: string
|
|
9
|
+
readonly leader: string
|
|
10
|
+
readonly label: string
|
|
11
|
+
readonly value: string
|
|
12
|
+
readonly secondary: string
|
|
13
|
+
readonly empty: string
|
|
14
|
+
readonly skeletonRow: string
|
|
15
|
+
}
|
|
16
|
+
export default classes
|
|
@@ -11,8 +11,8 @@ export type DeltaBadgeProps = {
|
|
|
11
11
|
format?: (value: number) => string;
|
|
12
12
|
/** Render the ▲/▼ direction glyph. Defaults to `true`; a zero value never shows a glyph. */
|
|
13
13
|
withGlyph?: boolean;
|
|
14
|
-
/** Optional comparison timeframe rendered directly after the value
|
|
15
|
-
*
|
|
14
|
+
/** Optional comparison timeframe rendered directly after the value, muted (e.g. `MoM`, `WoW`,
|
|
15
|
+
* `YTD`) — states what the delta is measured against without a hover. */
|
|
16
16
|
period?: string | undefined;
|
|
17
17
|
};
|
|
18
18
|
export declare function DeltaBadge({ value, polarity, format, withGlyph, period, }: DeltaBadgeProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delta-badge.d.ts","sourceRoot":"","sources":["../../src/dashboard/delta-badge.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delta-badge.d.ts","sourceRoot":"","sources":["../../src/dashboard/delta-badge.tsx"],"names":[],"mappings":"AA6BA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAA;IACb;;;kCAG8B;IAC9B,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,4FAA4F;IAC5F,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;6EACyE;IACzE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B,CAAA;AAkBD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAoB,EACpB,MAAsB,EACtB,SAAgB,EAChB,MAAM,GACP,EAAE,eAAe,+BAYjB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { VX } from "../tokens/index.js";
|
|
3
3
|
import classes from "./widget-header.module.css";
|
|
4
4
|
const defaultFormat = (value) => `${Math.abs(value).toFixed(1)}%`;
|
|
5
5
|
function resolveTone(value, polarity) {
|
|
@@ -8,6 +8,11 @@ function resolveTone(value, polarity) {
|
|
|
8
8
|
const good = polarity === "up-good" ? rose : !rose;
|
|
9
9
|
return good ? VX.status.good : VX.status.bad;
|
|
10
10
|
}
|
|
11
|
+
function directionGlyph(value) {
|
|
12
|
+
if (value > 0) return "\u25B2";
|
|
13
|
+
if (value < 0) return "\u25BC";
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
11
16
|
function DeltaBadge({
|
|
12
17
|
value,
|
|
13
18
|
polarity = "up-good",
|
|
@@ -16,20 +21,13 @@ function DeltaBadge({
|
|
|
16
21
|
period
|
|
17
22
|
}) {
|
|
18
23
|
const tone = resolveTone(value, polarity);
|
|
19
|
-
const glyph = value
|
|
24
|
+
const glyph = directionGlyph(value);
|
|
20
25
|
const showGlyph = withGlyph && glyph !== void 0;
|
|
21
|
-
return /* @__PURE__ */ jsxs(
|
|
22
|
-
"span",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
children: [
|
|
27
|
-
showGlyph && /* @__PURE__ */ jsx("span", { className: classes.deltaGlyph, children: glyph }),
|
|
28
|
-
format(value),
|
|
29
|
-
period !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.deltaPeriod, children: period })
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
);
|
|
26
|
+
return /* @__PURE__ */ jsxs("span", { className: classes.deltaBadge, style: { color: tone }, children: [
|
|
27
|
+
showGlyph && /* @__PURE__ */ jsx("span", { className: classes.deltaGlyph, children: glyph }),
|
|
28
|
+
format(value),
|
|
29
|
+
period !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.deltaPeriod, children: period })
|
|
30
|
+
] });
|
|
33
31
|
}
|
|
34
32
|
export {
|
|
35
33
|
DeltaBadge
|
|
@@ -5,4 +5,6 @@ export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from
|
|
|
5
5
|
export { StatGroup } from './stat-group.js';
|
|
6
6
|
export { EmptyState } from './empty-state.js';
|
|
7
7
|
export { SettingsSection, SettingsRow, DangerZone } from './settings-section.js';
|
|
8
|
+
export { Meter, type MeterProps } from './meter.js';
|
|
9
|
+
export { BarList, type BarListProps } from './bar-list.js';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/dashboard/index.js
CHANGED
|
@@ -5,10 +5,14 @@ import { StatCard } from "./stat-card.js";
|
|
|
5
5
|
import { StatGroup } from "./stat-group.js";
|
|
6
6
|
import { EmptyState } from "./empty-state.js";
|
|
7
7
|
import { SettingsSection, SettingsRow, DangerZone } from "./settings-section.js";
|
|
8
|
+
import { Meter } from "./meter.js";
|
|
9
|
+
import { BarList } from "./bar-list.js";
|
|
8
10
|
export {
|
|
11
|
+
BarList,
|
|
9
12
|
DangerZone,
|
|
10
13
|
DeltaBadge,
|
|
11
14
|
EmptyState,
|
|
15
|
+
Meter,
|
|
12
16
|
Section,
|
|
13
17
|
SettingsRow,
|
|
14
18
|
SettingsSection,
|