@mcpview/components 0.0.0-stage → 0.10.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/LICENSE +21 -0
- package/README.md +575 -2
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/fonts.d.ts +13 -0
- package/esm/fonts.d.ts.map +1 -0
- package/esm/fonts.js +12 -0
- package/esm/layout.d.ts +14 -0
- package/esm/layout.d.ts.map +1 -0
- package/esm/layout.js +13 -0
- package/esm/mod.d.ts +19 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +14 -0
- package/esm/package.json +3 -0
- package/esm/preact-components.d.ts +22 -0
- package/esm/preact-components.d.ts.map +1 -0
- package/esm/preact-components.js +20 -0
- package/esm/preact.d.ts +10 -0
- package/esm/preact.d.ts.map +1 -0
- package/esm/preact.js +9 -0
- package/esm/src/component-primitives.d.ts +41 -0
- package/esm/src/component-primitives.d.ts.map +1 -0
- package/esm/src/component-primitives.js +121 -0
- package/esm/src/components.d.ts +50 -0
- package/esm/src/components.d.ts.map +1 -0
- package/esm/src/components.js +283 -0
- package/esm/src/font-families.d.ts +16 -0
- package/esm/src/font-families.d.ts.map +1 -0
- package/esm/src/font-families.js +11 -0
- package/esm/src/fonts-data.d.ts +2 -0
- package/esm/src/fonts-data.d.ts.map +1 -0
- package/esm/src/fonts-data.js +42 -0
- package/esm/src/fonts.d.ts +12 -0
- package/esm/src/fonts.d.ts.map +1 -0
- package/esm/src/fonts.js +19 -0
- package/esm/src/i18n.d.ts +44 -0
- package/esm/src/i18n.d.ts.map +1 -0
- package/esm/src/i18n.js +98 -0
- package/esm/src/layout/hooks.d.ts +60 -0
- package/esm/src/layout/hooks.d.ts.map +1 -0
- package/esm/src/layout/hooks.js +121 -0
- package/esm/src/layout/mod.d.ts +6 -0
- package/esm/src/layout/mod.d.ts.map +1 -0
- package/esm/src/layout/mod.js +3 -0
- package/esm/src/layout/viewer-layout.d.ts +82 -0
- package/esm/src/layout/viewer-layout.d.ts.map +1 -0
- package/esm/src/layout/viewer-layout.js +74 -0
- package/esm/src/preact/components.d.ts +215 -0
- package/esm/src/preact/components.d.ts.map +1 -0
- package/esm/src/preact/components.js +176 -0
- package/esm/src/preact/focused-view.d.ts +42 -0
- package/esm/src/preact/focused-view.d.ts.map +1 -0
- package/esm/src/preact/focused-view.js +20 -0
- package/esm/src/preact/mod.d.ts +6 -0
- package/esm/src/preact/mod.d.ts.map +1 -0
- package/esm/src/preact/mod.js +3 -0
- package/esm/src/preact/plots.d.ts +119 -0
- package/esm/src/preact/plots.d.ts.map +1 -0
- package/esm/src/preact/plots.js +152 -0
- package/esm/src/preact/semantic-element.d.ts +103 -0
- package/esm/src/preact/semantic-element.d.ts.map +1 -0
- package/esm/src/preact/semantic-element.js +103 -0
- package/esm/src/preact/structural.d.ts +178 -0
- package/esm/src/preact/structural.d.ts.map +1 -0
- package/esm/src/preact/structural.js +147 -0
- package/esm/src/preact/surface.d.ts +37 -0
- package/esm/src/preact/surface.d.ts.map +1 -0
- package/esm/src/preact/surface.js +47 -0
- package/esm/src/surface-app.d.ts +188 -0
- package/esm/src/surface-app.d.ts.map +1 -0
- package/esm/src/surface-app.js +374 -0
- package/esm/src/theme.d.ts +65 -0
- package/esm/src/theme.d.ts.map +1 -0
- package/esm/src/theme.js +1877 -0
- package/esm/surface.d.ts +12 -0
- package/esm/surface.d.ts.map +1 -0
- package/esm/surface.js +10 -0
- package/package.json +68 -4
- package/script/_dnt.polyfills.d.ts +12 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +16 -0
- package/script/fonts.d.ts +13 -0
- package/script/fonts.d.ts.map +1 -0
- package/script/fonts.js +19 -0
- package/script/layout.d.ts +14 -0
- package/script/layout.d.ts.map +1 -0
- package/script/layout.js +29 -0
- package/script/mod.d.ts +19 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +40 -0
- package/script/package.json +3 -0
- package/script/preact-components.d.ts +22 -0
- package/script/preact-components.d.ts.map +1 -0
- package/script/preact-components.js +68 -0
- package/script/preact.d.ts +10 -0
- package/script/preact.d.ts.map +1 -0
- package/script/preact.js +25 -0
- package/script/src/component-primitives.d.ts +41 -0
- package/script/src/component-primitives.d.ts.map +1 -0
- package/script/src/component-primitives.js +127 -0
- package/script/src/components.d.ts +50 -0
- package/script/src/components.d.ts.map +1 -0
- package/script/src/components.js +297 -0
- package/script/src/font-families.d.ts +16 -0
- package/script/src/font-families.d.ts.map +1 -0
- package/script/src/font-families.js +14 -0
- package/script/src/fonts-data.d.ts +2 -0
- package/script/src/fonts-data.d.ts.map +1 -0
- package/script/src/fonts-data.js +45 -0
- package/script/src/fonts.d.ts +12 -0
- package/script/src/fonts.d.ts.map +1 -0
- package/script/src/fonts.js +24 -0
- package/script/src/i18n.d.ts +44 -0
- package/script/src/i18n.d.ts.map +1 -0
- package/script/src/i18n.js +102 -0
- package/script/src/layout/hooks.d.ts +60 -0
- package/script/src/layout/hooks.d.ts.map +1 -0
- package/script/src/layout/hooks.js +126 -0
- package/script/src/layout/mod.d.ts +6 -0
- package/script/src/layout/mod.d.ts.map +1 -0
- package/script/src/layout/mod.js +17 -0
- package/script/src/layout/viewer-layout.d.ts +82 -0
- package/script/src/layout/viewer-layout.d.ts.map +1 -0
- package/script/src/layout/viewer-layout.js +83 -0
- package/script/src/preact/components.d.ts +215 -0
- package/script/src/preact/components.d.ts.map +1 -0
- package/script/src/preact/components.js +199 -0
- package/script/src/preact/focused-view.d.ts +42 -0
- package/script/src/preact/focused-view.d.ts.map +1 -0
- package/script/src/preact/focused-view.js +24 -0
- package/script/src/preact/mod.d.ts +6 -0
- package/script/src/preact/mod.d.ts.map +1 -0
- package/script/src/preact/mod.js +55 -0
- package/script/src/preact/plots.d.ts +119 -0
- package/script/src/preact/plots.d.ts.map +1 -0
- package/script/src/preact/plots.js +157 -0
- package/script/src/preact/semantic-element.d.ts +103 -0
- package/script/src/preact/semantic-element.d.ts.map +1 -0
- package/script/src/preact/semantic-element.js +115 -0
- package/script/src/preact/structural.d.ts +178 -0
- package/script/src/preact/structural.d.ts.map +1 -0
- package/script/src/preact/structural.js +158 -0
- package/script/src/preact/surface.d.ts +37 -0
- package/script/src/preact/surface.d.ts.map +1 -0
- package/script/src/preact/surface.js +53 -0
- package/script/src/surface-app.d.ts +188 -0
- package/script/src/surface-app.d.ts.map +1 -0
- package/script/src/surface-app.js +379 -0
- package/script/src/theme.d.ts +65 -0
- package/script/src/theme.d.ts.map +1 -0
- package/script/src/theme.js +1881 -0
- package/script/surface.d.ts +12 -0
- package/script/surface.d.ts.map +1 -0
- package/script/surface.js +15 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { createElement as _createElement } from "preact";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
3
|
+
/** @jsxImportSource preact */
|
|
4
|
+
/** Shared Preact presentation primitives for composable MCP Apps. */
|
|
5
|
+
import { createElement, render } from "preact";
|
|
6
|
+
/** Simple vertical composition primitive; it carries no domain semantics. */
|
|
7
|
+
export function Stack({ gap = "md", className, children }) {
|
|
8
|
+
return (_jsx("div", { class: classes("mcp-view-stack", className), "data-gap": gap, children: children }));
|
|
9
|
+
}
|
|
10
|
+
/** Horizontal fact or control row; its contents and meaning remain caller-owned. */
|
|
11
|
+
export function Row({ label, responsive = false, className, children, }) {
|
|
12
|
+
return (_jsx("div", { "aria-label": label, class: classes("mcp-view-row", responsive ? "mcp-view-row-responsive" : undefined, className), role: label ? "group" : undefined, children: children }));
|
|
13
|
+
}
|
|
14
|
+
/** The canonical MCP component container. */
|
|
15
|
+
export function Card({ title, eyebrow, actions, className, children, }) {
|
|
16
|
+
return (_jsxs("section", { class: classes("mcp-view-card", className), children: [(title || eyebrow || actions) && (_jsxs("header", { class: "mcp-view-card-header", children: [_jsxs("div", { class: "mcp-view-card-heading", children: [eyebrow && _jsx("p", { class: "mcp-view-card-eyebrow", children: eyebrow }), title && _jsx("h2", { class: "mcp-view-card-title", children: title })] }), actions && _jsx("div", { class: "mcp-view-card-actions", children: actions })] })), children] }));
|
|
17
|
+
}
|
|
18
|
+
/** Accessible wrapping group for compact status and classification badges. */
|
|
19
|
+
export function BadgeGroup({ label, className, children, }) {
|
|
20
|
+
return (_jsx("div", { "aria-label": label, class: classes("mcp-view-badges", className), role: "group", children: children }));
|
|
21
|
+
}
|
|
22
|
+
/** Compact status or classification label. */
|
|
23
|
+
export function Badge({ tone = "neutral", children, className }) {
|
|
24
|
+
return (_jsx("span", { class: classes("mcp-view-badge", className), "data-tone": tone, children: children }));
|
|
25
|
+
}
|
|
26
|
+
/** One unit-bearing reading. Callers remain responsible for the value and its tone. */
|
|
27
|
+
export function Metric({ id, label, value, unit, detail, tone = "neutral", className, }) {
|
|
28
|
+
return (_jsxs("article", { class: classes("mcp-view-metric", className), "data-metric": id, "data-tone": tone, children: [_jsx("span", { class: "mcp-view-metric-label", children: label }), _jsx("strong", { class: "mcp-view-metric-value", children: value }), unit && _jsx("small", { class: "mcp-view-metric-unit", children: unit }), detail && _jsx("small", { class: "mcp-view-metric-detail", children: detail })] }));
|
|
29
|
+
}
|
|
30
|
+
/** Responsive, container-aware metrics with stable semantic slots. */
|
|
31
|
+
export function MetricGrid({ items, className }) {
|
|
32
|
+
return (_jsx("div", { class: classes("mcp-view-metrics", className), children: items.map((metric) => _createElement(Metric, { ...metric, key: metric.id })) }));
|
|
33
|
+
}
|
|
34
|
+
/** Provenance and identity facts with safe wrapping for hashes and URIs. */
|
|
35
|
+
export function KeyValueList({ items, layout = "inspector", className, }) {
|
|
36
|
+
return (_jsx("dl", { class: classes("mcp-view-key-values", className), "data-layout": layout === "inspector" ? undefined : layout, children: items.map((item) => (_jsxs("div", { class: "mcp-view-key-value", children: [_jsx("dt", { children: item.label }), _jsx("dd", { children: item.value })] }, item.id))) }));
|
|
37
|
+
}
|
|
38
|
+
/** Accessible compact table; selection behavior is opt-in and keyboard-safe. */
|
|
39
|
+
export function DataTable({ label, rows, columns, rowKey, selected, onSelect, emptyLabel = "No matching data", className, }) {
|
|
40
|
+
if (rows.length === 0) {
|
|
41
|
+
return (_jsx("div", { "aria-label": label, class: classes("mcp-view-table-wrap", className), role: "status", children: _jsx(EmptyState, { children: emptyLabel }) }));
|
|
42
|
+
}
|
|
43
|
+
return (_jsx("div", { class: classes("mcp-view-table-wrap", className), children: _jsxs("table", { class: "mcp-view-table", "aria-label": label, children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", "data-align": column.align ?? "left", children: column.label }, column.id))) }) }), _jsx("tbody", { children: rows.map((row) => {
|
|
44
|
+
const interactive = onSelect !== undefined;
|
|
45
|
+
const isSelected = selected?.(row);
|
|
46
|
+
const choose = () => onSelect?.(row);
|
|
47
|
+
return (_jsx("tr", { "aria-selected": selected ? isSelected : undefined, class: isSelected ? "mcp-view-selected" : undefined, "data-interactive": interactive ? "true" : undefined, tabIndex: interactive ? 0 : undefined, onClick: interactive
|
|
48
|
+
? (event) => {
|
|
49
|
+
if (eventStartedInInteractiveChild(event.currentTarget, event.target))
|
|
50
|
+
return;
|
|
51
|
+
choose();
|
|
52
|
+
}
|
|
53
|
+
: undefined, onKeyDown: interactive
|
|
54
|
+
? (event) => {
|
|
55
|
+
if (event.target !== event.currentTarget)
|
|
56
|
+
return;
|
|
57
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
58
|
+
return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
choose();
|
|
61
|
+
}
|
|
62
|
+
: undefined, children: columns.map((column) => (_jsx("td", { "data-align": column.align ?? "left", children: column.render(row) }, column.id))) }, rowKey(row)));
|
|
63
|
+
}) })] }) }));
|
|
64
|
+
}
|
|
65
|
+
/** Small dashboard-safe action, never a product-wide navigation control. */
|
|
66
|
+
export function Button({ type = "button", pressed, disabled, title, className, onClick, children, }) {
|
|
67
|
+
return (_jsx("button", { "aria-pressed": pressed, class: classes("mcp-view-button", className), disabled: disabled, onClick: onClick, title: title, type: type, children: children }));
|
|
68
|
+
}
|
|
69
|
+
/** Compact controlled text input with a mandatory accessible label. */
|
|
70
|
+
export function TextInput({ label, value, placeholder, type = "search", disabled, className, onValueInput, }) {
|
|
71
|
+
return (_jsx("input", { "aria-label": label, class: classes("mcp-view-text-input", className), disabled: disabled, onInput: (event) => onValueInput?.(event.currentTarget.value), placeholder: placeholder, type: type, value: value }));
|
|
72
|
+
}
|
|
73
|
+
/** Bounded preformatted content for expressions, source excerpts, and exact text. */
|
|
74
|
+
export function CodeBlock({ label, className, children }) {
|
|
75
|
+
return (_jsx("pre", { "aria-label": label, class: classes("mcp-view-code-block", className), children: _jsx("code", { children: children }) }));
|
|
76
|
+
}
|
|
77
|
+
/** Inline exact text with safe wrapping for fingerprints, identifiers, and URIs. */
|
|
78
|
+
export function InlineCode({ title, className, children, }) {
|
|
79
|
+
return (_jsx("code", { class: classes("mcp-view-inline-code", className), title: title, children: children }));
|
|
80
|
+
}
|
|
81
|
+
export function Toolbar({ label, className, children, }) {
|
|
82
|
+
return (_jsx("div", { "aria-label": label, class: classes("mcp-view-toolbar", className), role: "group", children: children }));
|
|
83
|
+
}
|
|
84
|
+
export function EmptyState({ children, className, }) {
|
|
85
|
+
return _jsx("p", { class: classes("mcp-view-empty", className), children: children });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Frame-first loading placeholder: the structure of a recorded view appears
|
|
89
|
+
* before its values, so nothing shifts once the values arrive.
|
|
90
|
+
*/
|
|
91
|
+
export function Skeleton({ label, lines = 3, className }) {
|
|
92
|
+
if (!Number.isInteger(lines) || lines < 1) {
|
|
93
|
+
throw new RangeError("Skeleton lines must be a positive integer");
|
|
94
|
+
}
|
|
95
|
+
return (_jsx("div", { "aria-busy": "true", "aria-label": label, class: classes("mcp-view-skeleton", className), role: "status", children: Array.from({ length: lines }, (_unused, index) => _jsx("span", { "aria-hidden": "true", class: "mcp-view-skeleton-line" }, index)) }));
|
|
96
|
+
}
|
|
97
|
+
/** Compact inline notice that keeps surrounding values visible. */
|
|
98
|
+
export function Message({ tone = "neutral", children, className, }) {
|
|
99
|
+
return (_jsx("div", { class: classes("mcp-view-message", className), "data-tone": tone, role: tone === "danger" ? "alert" : "status", children: children }));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Short notices gathered under one severity heading.
|
|
103
|
+
*
|
|
104
|
+
* Renders nothing when there is nothing to say, so a caller never has to guard
|
|
105
|
+
* the call site. Truncation is stated by the caller: the group displays the
|
|
106
|
+
* notices it was handed and never counts what it was not.
|
|
107
|
+
*/
|
|
108
|
+
export function NoticeGroup({ label, items, tone = "neutral", omittedLabel, className, }) {
|
|
109
|
+
// `{count && `${count} more`}` yields 0 and `{text && text}` yields "" for a
|
|
110
|
+
// caller who means nothing was left out. Counting those as content would
|
|
111
|
+
// render the very group this contract promises to hide.
|
|
112
|
+
const omitted = omittedLabel !== undefined && omittedLabel !== null &&
|
|
113
|
+
omittedLabel !== false && omittedLabel !== "" && omittedLabel !== 0;
|
|
114
|
+
if (items.length === 0 && !omitted)
|
|
115
|
+
return null;
|
|
116
|
+
return (_jsxs("section", { "aria-label": label, class: classes("mcp-view-notice-group", className), "data-tone": tone,
|
|
117
|
+
// One live region for the group, not one per notice. Wrapping each item
|
|
118
|
+
// in Message announced N separate alerts for what reads on screen as a
|
|
119
|
+
// single severity heading with its list underneath.
|
|
120
|
+
role: tone === "danger" ? "alert" : "status", children: [_jsx("strong", { class: "mcp-view-notice-group-label", children: label }), _jsx("ul", { class: "mcp-view-notice-group-items", children: items.map((item, index) => _jsx("li", { class: "mcp-view-notice-group-item", children: item }, index)) }), omitted && _jsx("small", { class: "mcp-view-notice-group-omitted", children: omittedLabel })] }));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Render a `StateMessage` into a real DOM node and hand that node back.
|
|
124
|
+
*
|
|
125
|
+
* `defineView` returns a native element, so every viewer built on it has to
|
|
126
|
+
* bridge Preact to the DOM itself. Hand-written bridges drift — the tone, the
|
|
127
|
+
* alert role and the class stop matching between surfaces of the same product.
|
|
128
|
+
* This is that bridge, so one status looks like every other status.
|
|
129
|
+
*/
|
|
130
|
+
export function renderStatusMessage(detail, options = {}) {
|
|
131
|
+
const host = options.container ?? document.createElement("div");
|
|
132
|
+
render(createElement(StateMessage, {
|
|
133
|
+
busy: options.busy,
|
|
134
|
+
className: options.className,
|
|
135
|
+
title: options.title,
|
|
136
|
+
tone: options.tone,
|
|
137
|
+
}, detail), host);
|
|
138
|
+
// Without a container the caller mounts what comes back — typically as the
|
|
139
|
+
// return of `defineView`, which hands its element straight to the router.
|
|
140
|
+
// Returning the bare wrapper gave them a div carrying neither the class nor
|
|
141
|
+
// the alert role, so `replaceChildren` produced a root that no viewer stylesheet
|
|
142
|
+
// and no assistive technology could see. The container form returns the node
|
|
143
|
+
// the caller already owns.
|
|
144
|
+
if (options.container)
|
|
145
|
+
return options.container;
|
|
146
|
+
const rendered = host.firstElementChild;
|
|
147
|
+
if (!rendered)
|
|
148
|
+
throw new Error("renderStatusMessage rendered no element");
|
|
149
|
+
return rendered;
|
|
150
|
+
}
|
|
151
|
+
/** Read-only projection of a selection coordinated by an owning host. */
|
|
152
|
+
export function CrossSelection({ label, value, status, className, }) {
|
|
153
|
+
return (_jsxs("div", { class: classes("mcp-view-cross-selection", className), role: "status", children: [_jsx("span", { class: "mcp-view-cross-selection-label", children: label }), _jsx("strong", { class: "mcp-view-cross-selection-value", children: value }), status && _jsx("span", { class: "mcp-view-cross-selection-status", children: status })] }));
|
|
154
|
+
}
|
|
155
|
+
export function StateMessage({ title, tone = "neutral", busy, children, className, }) {
|
|
156
|
+
return (_jsxs("div", { "aria-busy": busy, class: classes("mcp-view-state", className), "data-tone": tone, role: tone === "danger" ? "alert" : "status", children: [busy && _jsx("span", { "aria-hidden": "true", class: "mcp-view-state-busy" }), title && _jsx("strong", { children: title }), children && _jsx("div", { class: "mcp-view-state-detail", children: children })] }));
|
|
157
|
+
}
|
|
158
|
+
const INTERACTIVE_CHILD_SELECTOR = [
|
|
159
|
+
"a[href]",
|
|
160
|
+
"button",
|
|
161
|
+
"input",
|
|
162
|
+
"select",
|
|
163
|
+
"textarea",
|
|
164
|
+
"[role='button']",
|
|
165
|
+
"[role='link']",
|
|
166
|
+
].join(",");
|
|
167
|
+
function eventStartedInInteractiveChild(row, target) {
|
|
168
|
+
const candidate = target;
|
|
169
|
+
if (!candidate || typeof candidate.closest !== "function")
|
|
170
|
+
return false;
|
|
171
|
+
const interactive = candidate.closest(INTERACTIVE_CHILD_SELECTOR);
|
|
172
|
+
return interactive !== null && interactive !== row && row.contains(interactive);
|
|
173
|
+
}
|
|
174
|
+
function classes(...values) {
|
|
175
|
+
return values.filter(Boolean).join(" ");
|
|
176
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @jsxImportSource preact */
|
|
2
|
+
/** Presentation slots for one useful view and its optional technical details. */
|
|
3
|
+
import type { ComponentChildren, JSX } from "preact";
|
|
4
|
+
import type { LayoutHostHints, ViewerLayout } from "../layout/viewer-layout.js";
|
|
5
|
+
export interface DisclosureProps {
|
|
6
|
+
/** Visible, caller-worded summary and accessible name of the native control. */
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly children?: ComponentChildren;
|
|
9
|
+
/** Omit for a native disclosure that starts closed. */
|
|
10
|
+
readonly open?: boolean;
|
|
11
|
+
readonly onToggle?: (open: boolean) => void;
|
|
12
|
+
readonly className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Native keyboard and disclosure semantics; never hides a caller's critical status by itself. */
|
|
15
|
+
export declare function Disclosure({ label, children, open, onToggle, className, }: DisclosureProps): JSX.Element;
|
|
16
|
+
interface FocusedViewSlots {
|
|
17
|
+
/** Accessible name for this bounded group, supplied by the viewer. */
|
|
18
|
+
readonly label: string;
|
|
19
|
+
/** The visualization or reading that gives this viewer its purpose. */
|
|
20
|
+
readonly primary: ComponentChildren;
|
|
21
|
+
/** Critical recorded state belongs here, outside the collapsed details. */
|
|
22
|
+
readonly status?: ComponentChildren;
|
|
23
|
+
/** Passed by value; this component imports no MCP Apps lifecycle. */
|
|
24
|
+
readonly hostContext?: LayoutHostHints;
|
|
25
|
+
/** Optional review override; otherwise the host, container and pointer decide. */
|
|
26
|
+
readonly layout?: ViewerLayout;
|
|
27
|
+
readonly className?: string;
|
|
28
|
+
}
|
|
29
|
+
export type FocusedViewProps = FocusedViewSlots & ({
|
|
30
|
+
readonly details?: never;
|
|
31
|
+
readonly detailsLabel?: never;
|
|
32
|
+
} | {
|
|
33
|
+
readonly details: ComponentChildren;
|
|
34
|
+
readonly detailsLabel: string;
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* One primary view, an overt status and a closed technical disclosure. The
|
|
38
|
+
* outer MCP surface supplies the frame. The viewer owns every value and label.
|
|
39
|
+
*/
|
|
40
|
+
export declare function FocusedView({ label, primary, status, details, detailsLabel, hostContext, layout: forced, className, }: FocusedViewProps): JSX.Element;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=focused-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focused-view.d.ts","sourceRoot":"","sources":["../../../src/src/preact/focused-view.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,iFAAiF;AAEjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,uDAAuD;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAA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3
|
+
/** Native keyboard and disclosure semantics; never hides a caller's critical status by itself. */
|
|
4
|
+
export function Disclosure({ label, children, open, onToggle, className, }) {
|
|
5
|
+
return (_jsxs("details", { class: classes("mcp-view-disclosure", className), open: open, onToggle: onToggle ? (event) => onToggle(event.currentTarget.open) : undefined, children: [_jsx("summary", { class: "mcp-view-disclosure-summary", children: label }), _jsx("div", { class: "mcp-view-disclosure-body", children: children })] }));
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One primary view, an overt status and a closed technical disclosure. The
|
|
9
|
+
* outer MCP surface supplies the frame. The viewer owns every value and label.
|
|
10
|
+
*/
|
|
11
|
+
export function FocusedView({ label, primary, status, details, detailsLabel, hostContext, layout: forced, className, }) {
|
|
12
|
+
const { ref, layout, boundsStyle } = useViewerLayout(hostContext, { forced });
|
|
13
|
+
return (_jsxs("div", { ref: ref, role: "group", "aria-label": label, class: classes("mcp-view-focused-view", className), "data-layout": layout, style: boundsStyle, children: [isPresent(status) && _jsx("div", { class: "mcp-view-focused-status", children: status }), _jsx("div", { class: "mcp-view-focused-primary", children: primary }), isPresent(details) && detailsLabel !== undefined && (_jsx(Disclosure, { label: detailsLabel, children: details }))] }));
|
|
14
|
+
}
|
|
15
|
+
function isPresent(value) {
|
|
16
|
+
return value !== undefined && value !== null && value !== false;
|
|
17
|
+
}
|
|
18
|
+
function classes(...values) {
|
|
19
|
+
return values.filter(Boolean).join(" ");
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Preact integration for `@mcpview/components` surfaces. */
|
|
2
|
+
export { definePreactComponent, preactSurfaceRenderer, startPreactSurfaceApp, SurfaceAppError, } from "./surface.js";
|
|
3
|
+
export { ArtifactRow, Badge, BadgeGroup, Button, Card, CodeBlock, CollectionCard, CrossSelection, DataTable, Disclosure, DrillHint, ElementBody, ElementIdent, ElementLimit, ElementProvenance, ElementReading, ElementSection, ElementVerdict, EmptyState, FocusedView, InlineCode, IntervalPlot, KeyValueList, LimitGauge, Message, Metric, MetricGrid, NoticeGroup, PATH_BAR_DEFAULT_MAX_VISIBLE, PathBar, renderStatusMessage, Row, SemanticElement, SemanticList, SeriesChart, Skeleton, Slot3D, Sparkline, Stack, StaleBanner, StateMessage, TextInput, Toolbar, TreeList, TypeBadge, } from "../../preact-components.js";
|
|
4
|
+
export type { PreactComponentRenderer, PreactSurfaceAppOptions, PreactSurfaceAppState, PreactSurfaceComponentProps, PreactSurfaceContext, SurfaceAppErrorCode, SurfaceAppHandle, SurfaceAppRuntime, SurfaceDisplayState, SurfaceHostAccess, SurfaceLabel, SurfaceMessageKind, SurfaceProjection, SurfaceStatus, SurfaceStatusTone, SurfaceToolResult, SurfaceViewerSession, } from "./surface.js";
|
|
5
|
+
export type { ArtifactFingerprint, ArtifactRowProps, ArtifactVerification, BadgeGroupProps, BadgeProps, ButtonProps, CardProps, CodeBlockProps, CollectionCardProps, CrossSelectionProps, DataTableColumn, DataTableProps, DisclosureProps, DrillHintDirection, DrillHintProps, ElementBodyProps, ElementIdentProps, ElementLimitProps, ElementProvenanceProps, ElementReadingProps, ElementSectionProps, ElementVerdictProps, EmptyStateProps, FocusedViewProps, InlineCodeProps, IntervalPlotInterval, IntervalPlotProps, KeyValueItem, KeyValueLayout, KeyValueListProps, LimitGaugeLimit, LimitGaugeProps, MessageProps, MetricGridProps, MetricItem, MetricProps, NoticeGroupProps, PathBarItem, PathBarProps, PresentationTone, RowProps, SemanticElementDensity, SemanticElementProps, SemanticListProps, SeriesChartCursor, SeriesChartProps, SeriesChartReadout, SeriesChartSeries, SeriesChartSummaryItem, SeriesPoint, SkeletonProps, Slot3DProps, SparklineProps, StackProps, StaleBannerAction, StaleBannerProps, StateMessageProps, StatusMessageMount, TextInputProps, ToolbarProps, TreeListNode, TreeListProps, TypeBadgeProps, ViewKind, } from "../../preact-components.js";
|
|
6
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/preact/mod.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,KAAK,EACL,UAAU,EACV,MAAM,EACN,IAAI,EACJ,SAAS,EACT,cAAc,EACd,cAAc,EACd,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,WAAW,EACX,4BAA4B,EAC5B,OAAO,EACP,mBAAmB,EACnB,GAAG,EACH,eAAe,EACf,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,QAAQ,EACR,SAAS,GACV,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EACf,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,QAAQ,GACT,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Preact integration for `@mcpview/components` surfaces. */
|
|
2
|
+
export { definePreactComponent, preactSurfaceRenderer, startPreactSurfaceApp, SurfaceAppError, } from "./surface.js";
|
|
3
|
+
export { ArtifactRow, Badge, BadgeGroup, Button, Card, CodeBlock, CollectionCard, CrossSelection, DataTable, Disclosure, DrillHint, ElementBody, ElementIdent, ElementLimit, ElementProvenance, ElementReading, ElementSection, ElementVerdict, EmptyState, FocusedView, InlineCode, IntervalPlot, KeyValueList, LimitGauge, Message, Metric, MetricGrid, NoticeGroup, PATH_BAR_DEFAULT_MAX_VISIBLE, PathBar, renderStatusMessage, Row, SemanticElement, SemanticList, SeriesChart, Skeleton, Slot3D, Sparkline, Stack, StaleBanner, StateMessage, TextInput, Toolbar, TreeList, TypeBadge, } from "../../preact-components.js";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** @jsxImportSource preact */
|
|
2
|
+
/**
|
|
3
|
+
* Data marks for recorded numeric evidence.
|
|
4
|
+
*
|
|
5
|
+
* Every plot draws exactly the samples, bounds, and wording the caller passes.
|
|
6
|
+
* None of them resamples, interpolates a missing point, formats a number, picks
|
|
7
|
+
* a unit, derives an extremum, or owns pointer state: a cursor is declared by
|
|
8
|
+
* the provider that already resolved the reading behind it.
|
|
9
|
+
*/
|
|
10
|
+
import type { JSX } from "preact";
|
|
11
|
+
import type { PresentationTone } from "./components.js";
|
|
12
|
+
export interface SparklineProps {
|
|
13
|
+
/** Accessible name of the sampled quantity. */
|
|
14
|
+
readonly label: string;
|
|
15
|
+
/** At least two finite samples, already ordered by the caller. */
|
|
16
|
+
readonly values: readonly number[];
|
|
17
|
+
/** Caller-formatted summary, including units. */
|
|
18
|
+
readonly summaryLabel: string;
|
|
19
|
+
readonly tone?: PresentationTone;
|
|
20
|
+
readonly className?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Compact shape of one recorded series, readable at chip and row density. */
|
|
23
|
+
export declare function Sparkline({ label, values, summaryLabel, tone, className, }: SparklineProps): JSX.Element;
|
|
24
|
+
export interface SeriesPoint {
|
|
25
|
+
readonly x: number;
|
|
26
|
+
readonly y: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* How one series may be drawn.
|
|
30
|
+
*
|
|
31
|
+
* `line` connects consecutive samples, which asserts the quantity existed
|
|
32
|
+
* between them — only true when the series is sampled densely enough for that
|
|
33
|
+
* claim to hold. `bar` draws each recorded sample on its own and claims nothing
|
|
34
|
+
* in between. The provider knows its sampling, so it declares the mark; the
|
|
35
|
+
* chart never infers one from point spacing.
|
|
36
|
+
*/
|
|
37
|
+
export type SeriesMark = "line" | "bar";
|
|
38
|
+
export interface SeriesChartSeries {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
/** Declared, never inferred. A sparse series drawn as a line invents values. */
|
|
42
|
+
readonly mark: SeriesMark;
|
|
43
|
+
/** At least two finite points, already ordered by the caller. */
|
|
44
|
+
readonly points: readonly SeriesPoint[];
|
|
45
|
+
readonly tone?: PresentationTone;
|
|
46
|
+
}
|
|
47
|
+
export interface SeriesChartReadout {
|
|
48
|
+
/** Must name one declared series. */
|
|
49
|
+
readonly seriesId: string;
|
|
50
|
+
/** Caller-formatted value at the cursor, including units. */
|
|
51
|
+
readonly valueLabel: string;
|
|
52
|
+
}
|
|
53
|
+
export interface SeriesChartCursor {
|
|
54
|
+
/** Position on the shared x scale. The chart resolves nothing itself. */
|
|
55
|
+
readonly x: number;
|
|
56
|
+
/** Caller-formatted position, such as an instant. */
|
|
57
|
+
readonly label: string;
|
|
58
|
+
/**
|
|
59
|
+
* Values the provider actually recorded at that position. A series with no
|
|
60
|
+
* sample there is simply absent: the chart never interpolates between two
|
|
61
|
+
* samples, never snaps to a neighbour, and never fills a gap to look complete.
|
|
62
|
+
*/
|
|
63
|
+
readonly readouts: readonly SeriesChartReadout[];
|
|
64
|
+
}
|
|
65
|
+
export interface SeriesChartSummaryItem {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
/** Caller wording for the extremum, such as min, max, or final. */
|
|
68
|
+
readonly label: string;
|
|
69
|
+
/** Caller-formatted value, including units and where it occurred. */
|
|
70
|
+
readonly valueLabel: string;
|
|
71
|
+
}
|
|
72
|
+
export interface SeriesChartProps {
|
|
73
|
+
/** Accessible name of the chart. */
|
|
74
|
+
readonly label: string;
|
|
75
|
+
readonly series: readonly SeriesChartSeries[];
|
|
76
|
+
readonly xMin: number;
|
|
77
|
+
readonly xMax: number;
|
|
78
|
+
readonly yMin: number;
|
|
79
|
+
readonly yMax: number;
|
|
80
|
+
/** Caller-formatted ticks, left to right. */
|
|
81
|
+
readonly axisLabels?: readonly string[];
|
|
82
|
+
/** Caller-computed extrema. The chart never scans the samples for them. */
|
|
83
|
+
readonly summary?: readonly SeriesChartSummaryItem[];
|
|
84
|
+
/** Declared cursor. Omit it and the chart shows no readout. */
|
|
85
|
+
readonly cursor?: SeriesChartCursor;
|
|
86
|
+
/**
|
|
87
|
+
* Pointer position on the shared x scale, or `undefined` once the pointer
|
|
88
|
+
* leaves. The chart reports screen geometry only; which recorded sample that
|
|
89
|
+
* position corresponds to — or that none does — stays the provider's call.
|
|
90
|
+
*/
|
|
91
|
+
readonly onScrub?: (x: number | undefined) => void;
|
|
92
|
+
readonly className?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Multi-series plot on one shared finite scale, with a declared cursor readout. */
|
|
95
|
+
export declare function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, summary, cursor, onScrub, className, }: SeriesChartProps): JSX.Element;
|
|
96
|
+
export interface IntervalPlotInterval {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
/** Caller wording for the interval, such as a tolerance class. */
|
|
99
|
+
readonly label: string;
|
|
100
|
+
readonly lower: number;
|
|
101
|
+
readonly upper: number;
|
|
102
|
+
/** Caller-formatted deviations, including units. */
|
|
103
|
+
readonly lowerLabel: string;
|
|
104
|
+
readonly upperLabel: string;
|
|
105
|
+
readonly tone?: PresentationTone;
|
|
106
|
+
}
|
|
107
|
+
export interface IntervalPlotProps {
|
|
108
|
+
/** Accessible name of the plot. */
|
|
109
|
+
readonly label: string;
|
|
110
|
+
readonly min: number;
|
|
111
|
+
readonly max: number;
|
|
112
|
+
/** Caller wording for the zero reference, such as the nominal size. */
|
|
113
|
+
readonly zeroLabel: string;
|
|
114
|
+
readonly intervals: readonly IntervalPlotInterval[];
|
|
115
|
+
readonly className?: string;
|
|
116
|
+
}
|
|
117
|
+
/** Caller-declared deviation intervals laid out against a shared zero line. */
|
|
118
|
+
export declare function IntervalPlot({ label, min, max, zeroLabel, intervals, className, }: IntervalPlotProps): JSX.Element;
|
|
119
|
+
//# sourceMappingURL=plots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plots.d.ts","sourceRoot":"","sources":["../../../src/src/preact/plots.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG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EACP,SAAS,GACV,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAoHhC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,GAAG,EACH,GAAG,EACH,SAAS,EACT,SAAS,EACT,SAAS,GACV,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CA6CjC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
const SPARKLINE_VIEWBOX_HEIGHT = 24;
|
|
3
|
+
const SERIES_CHART_VIEWBOX_HEIGHT = 40;
|
|
4
|
+
const VIEWBOX_WIDTH = 100;
|
|
5
|
+
/** Compact shape of one recorded series, readable at chip and row density. */
|
|
6
|
+
export function Sparkline({ label, values, summaryLabel, tone = "info", className, }) {
|
|
7
|
+
validateSamples(values, "Sparkline values");
|
|
8
|
+
const min = Math.min(...values);
|
|
9
|
+
const max = Math.max(...values);
|
|
10
|
+
const points = values
|
|
11
|
+
.map((value, index) => {
|
|
12
|
+
const x = (index / (values.length - 1)) * VIEWBOX_WIDTH;
|
|
13
|
+
const y = SPARKLINE_VIEWBOX_HEIGHT -
|
|
14
|
+
normalize(value, min, max) * SPARKLINE_VIEWBOX_HEIGHT;
|
|
15
|
+
return `${round(x)},${round(y)}`;
|
|
16
|
+
})
|
|
17
|
+
.join(" ");
|
|
18
|
+
return (_jsx("svg", { "aria-label": `${label}: ${summaryLabel}`, class: classes("mcp-view-sparkline", className), "data-tone": tone, preserveAspectRatio: "none", role: "img", viewBox: `0 0 ${VIEWBOX_WIDTH} ${SPARKLINE_VIEWBOX_HEIGHT}`, children: _jsx("polyline", { class: "mcp-view-sparkline-line", points: points, "vector-effect": "non-scaling-stroke" }) }));
|
|
19
|
+
}
|
|
20
|
+
/** Multi-series plot on one shared finite scale, with a declared cursor readout. */
|
|
21
|
+
export function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, summary, cursor, onScrub, className, }) {
|
|
22
|
+
validateSeriesChart(series, xMin, xMax, yMin, yMax, cursor);
|
|
23
|
+
const baselineY = yMin <= 0 && 0 <= yMax
|
|
24
|
+
? SERIES_CHART_VIEWBOX_HEIGHT - normalize(0, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT
|
|
25
|
+
: undefined;
|
|
26
|
+
const cursorX = cursor === undefined
|
|
27
|
+
? undefined
|
|
28
|
+
: normalize(cursor.x, xMin, xMax) * VIEWBOX_WIDTH;
|
|
29
|
+
const seriesLabels = series.map((one) => one.label).join(", ");
|
|
30
|
+
return (_jsxs("figure", { class: classes("mcp-view-series-chart", className), children: [_jsxs("svg", { "aria-label": `${label}: ${seriesLabels}`, class: "mcp-view-series-chart-plot", preserveAspectRatio: "none", role: "img", viewBox: `0 0 ${VIEWBOX_WIDTH} ${SERIES_CHART_VIEWBOX_HEIGHT}`, onPointerLeave: onScrub === undefined ? undefined : () => onScrub(undefined), onPointerMove: onScrub === undefined ? undefined : (event) => {
|
|
31
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
32
|
+
if (box.width === 0)
|
|
33
|
+
return;
|
|
34
|
+
const ratio = (event.clientX - box.left) / box.width;
|
|
35
|
+
if (ratio < 0 || ratio > 1)
|
|
36
|
+
return;
|
|
37
|
+
onScrub(xMin + ratio * (xMax - xMin));
|
|
38
|
+
}, children: [baselineY !== undefined && (_jsx("line", { class: "mcp-view-series-chart-baseline", "vector-effect": "non-scaling-stroke", x1: 0, x2: VIEWBOX_WIDTH, y1: round(baselineY), y2: round(baselineY) })), cursorX !== undefined && (_jsx("line", { class: "mcp-view-series-chart-cursor", "vector-effect": "non-scaling-stroke", x1: round(cursorX), x2: round(cursorX), y1: 0, y2: SERIES_CHART_VIEWBOX_HEIGHT })), series.map((one) => {
|
|
39
|
+
const placed = one.points.map((point) => ({
|
|
40
|
+
x: normalize(point.x, xMin, xMax) * VIEWBOX_WIDTH,
|
|
41
|
+
y: SERIES_CHART_VIEWBOX_HEIGHT -
|
|
42
|
+
normalize(point.y, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT,
|
|
43
|
+
}));
|
|
44
|
+
if (one.mark === "line") {
|
|
45
|
+
return (_jsx("polyline", { class: "mcp-view-series-chart-line", "data-tone": one.tone ?? "info", points: placed.map((at) => `${round(at.x)},${round(at.y)}`).join(" "), "vector-effect": "non-scaling-stroke" }, one.id));
|
|
46
|
+
}
|
|
47
|
+
// Each recorded sample stands alone, anchored on the drawn baseline
|
|
48
|
+
// when the scale carries zero, otherwise on the floor of the scale.
|
|
49
|
+
const foot = baselineY ?? SERIES_CHART_VIEWBOX_HEIGHT;
|
|
50
|
+
return (_jsx("g", { class: "mcp-view-series-chart-bars", "data-tone": one.tone ?? "info", children: placed.map((at, index) => (_jsx("line", { "vector-effect": "non-scaling-stroke", x1: round(at.x), x2: round(at.x), y1: round(foot), y2: round(at.y) }, one.points[index].x))) }, one.id));
|
|
51
|
+
})] }), axisLabels && axisLabels.length > 0 && (_jsx("div", { "aria-hidden": "true", class: "mcp-view-series-chart-axis", children: axisLabels.map((tick) => _jsx("span", { children: tick }, tick)) })), cursor && (_jsxs("div", { class: "mcp-view-series-chart-readout", children: [_jsx("span", { class: "mcp-view-series-chart-readout-position", children: cursor.label }), _jsx("dl", { class: "mcp-view-series-chart-readout-values", children: cursor.readouts.map((readout) => {
|
|
52
|
+
const owner = series.find((one) => one.id === readout.seriesId);
|
|
53
|
+
return (_jsxs("div", { class: "mcp-view-series-chart-readout-value", children: [_jsx("dt", { "data-tone": owner?.tone ?? "info", children: owner?.label }), _jsx("dd", { children: readout.valueLabel })] }, readout.seriesId));
|
|
54
|
+
}) })] })), summary && summary.length > 0 && (_jsx("figcaption", { class: "mcp-view-series-chart-summary", children: summary.map((item) => (_jsxs("span", { class: "mcp-view-series-chart-summary-item", children: [_jsx("span", { class: "mcp-view-series-chart-summary-label", children: item.label }), _jsx("span", { class: "mcp-view-series-chart-summary-value", children: item.valueLabel })] }, item.id))) }))] }));
|
|
55
|
+
}
|
|
56
|
+
/** Caller-declared deviation intervals laid out against a shared zero line. */
|
|
57
|
+
export function IntervalPlot({ label, min, max, zeroLabel, intervals, className, }) {
|
|
58
|
+
validateIntervalPlot(min, max, intervals);
|
|
59
|
+
const zeroOffset = `${round(normalize(0, min, max) * 100)}%`;
|
|
60
|
+
return (_jsxs("div", { "aria-label": label, class: classes("mcp-view-interval-plot", className), role: "group", children: [_jsxs("div", { class: "mcp-view-interval-plot-scale", children: [_jsx("span", { "aria-hidden": "true", class: "mcp-view-interval-plot-zero", style: { left: zeroOffset } }), _jsx("span", { class: "mcp-view-interval-plot-zero-label", style: { left: zeroOffset }, children: zeroLabel })] }), intervals.map((interval) => (_jsxs("div", { class: "mcp-view-interval-plot-row", "data-tone": interval.tone ?? "neutral", children: [_jsx("span", { class: "mcp-view-interval-plot-label", children: interval.label }), _jsxs("span", { class: "mcp-view-interval-plot-track", children: [_jsx("span", { "aria-hidden": "true", class: "mcp-view-interval-plot-zero", style: { left: zeroOffset } }), _jsx("span", { class: "mcp-view-interval-plot-box", style: {
|
|
61
|
+
left: `${round(normalize(interval.lower, min, max) * 100)}%`,
|
|
62
|
+
width: `${round(((interval.upper - interval.lower) / (max - min)) * 100)}%`,
|
|
63
|
+
} })] }), _jsxs("span", { class: "mcp-view-interval-plot-bounds", children: [_jsx("span", { class: "mcp-view-interval-plot-lower", children: interval.lowerLabel }), _jsx("span", { class: "mcp-view-interval-plot-upper", children: interval.upperLabel })] })] }, interval.id)))] }));
|
|
64
|
+
}
|
|
65
|
+
function validateSamples(values, subject) {
|
|
66
|
+
if (values.length < 2)
|
|
67
|
+
throw new RangeError(`${subject} need at least two samples`);
|
|
68
|
+
for (const value of values) {
|
|
69
|
+
if (!Number.isFinite(value))
|
|
70
|
+
throw new TypeError(`${subject} must all be finite`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function validateSeriesChart(series, xMin, xMax, yMin, yMax, cursor) {
|
|
74
|
+
for (const [name, candidate] of [["xMin", xMin], ["xMax", xMax], ["yMin", yMin], [
|
|
75
|
+
"yMax",
|
|
76
|
+
yMax,
|
|
77
|
+
]]) {
|
|
78
|
+
if (!Number.isFinite(candidate))
|
|
79
|
+
throw new TypeError(`SeriesChart ${name} must be finite`);
|
|
80
|
+
}
|
|
81
|
+
if (xMax <= xMin)
|
|
82
|
+
throw new RangeError("SeriesChart xMax must be greater than xMin");
|
|
83
|
+
if (yMax <= yMin)
|
|
84
|
+
throw new RangeError("SeriesChart yMax must be greater than yMin");
|
|
85
|
+
if (series.length === 0)
|
|
86
|
+
throw new TypeError("SeriesChart series must not be empty");
|
|
87
|
+
const ids = new Set();
|
|
88
|
+
for (const one of series) {
|
|
89
|
+
if (ids.has(one.id))
|
|
90
|
+
throw new TypeError(`SeriesChart series id ${one.id} is duplicated`);
|
|
91
|
+
ids.add(one.id);
|
|
92
|
+
if (one.points.length < 2) {
|
|
93
|
+
throw new RangeError(`SeriesChart series ${one.id} needs at least two points`);
|
|
94
|
+
}
|
|
95
|
+
for (const point of one.points) {
|
|
96
|
+
if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {
|
|
97
|
+
throw new TypeError(`SeriesChart series ${one.id} points must be finite`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (cursor === undefined)
|
|
102
|
+
return;
|
|
103
|
+
if (!Number.isFinite(cursor.x))
|
|
104
|
+
throw new TypeError("SeriesChart cursor x must be finite");
|
|
105
|
+
if (cursor.x < xMin || cursor.x > xMax) {
|
|
106
|
+
throw new RangeError("SeriesChart cursor x must be within xMin and xMax");
|
|
107
|
+
}
|
|
108
|
+
for (const readout of cursor.readouts) {
|
|
109
|
+
if (!ids.has(readout.seriesId)) {
|
|
110
|
+
throw new TypeError(`SeriesChart cursor readout ${readout.seriesId} names no declared series`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function validateIntervalPlot(min, max, intervals) {
|
|
115
|
+
for (const [name, candidate] of [["min", min], ["max", max]]) {
|
|
116
|
+
if (!Number.isFinite(candidate))
|
|
117
|
+
throw new TypeError(`IntervalPlot ${name} must be finite`);
|
|
118
|
+
}
|
|
119
|
+
if (max <= min)
|
|
120
|
+
throw new RangeError("IntervalPlot max must be greater than min");
|
|
121
|
+
if (min > 0 || max < 0)
|
|
122
|
+
throw new RangeError("IntervalPlot scale must contain zero");
|
|
123
|
+
if (intervals.length === 0)
|
|
124
|
+
throw new TypeError("IntervalPlot intervals must not be empty");
|
|
125
|
+
const ids = new Set();
|
|
126
|
+
for (const interval of intervals) {
|
|
127
|
+
if (ids.has(interval.id))
|
|
128
|
+
throw new TypeError(`IntervalPlot id ${interval.id} is duplicated`);
|
|
129
|
+
ids.add(interval.id);
|
|
130
|
+
if (!Number.isFinite(interval.lower) || !Number.isFinite(interval.upper)) {
|
|
131
|
+
throw new TypeError(`IntervalPlot interval ${interval.id} bounds must be finite`);
|
|
132
|
+
}
|
|
133
|
+
if (interval.upper < interval.lower) {
|
|
134
|
+
throw new RangeError(`IntervalPlot interval ${interval.id} upper must not be below lower`);
|
|
135
|
+
}
|
|
136
|
+
if (interval.lower < min || interval.upper > max) {
|
|
137
|
+
throw new RangeError(`IntervalPlot interval ${interval.id} must be within min and max`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Position on a finite scale, clamped to a flat series' midpoint. */
|
|
142
|
+
function normalize(value, min, max) {
|
|
143
|
+
if (max === min)
|
|
144
|
+
return 0.5;
|
|
145
|
+
return (value - min) / (max - min);
|
|
146
|
+
}
|
|
147
|
+
function round(value) {
|
|
148
|
+
return Math.round(value * 100) / 100;
|
|
149
|
+
}
|
|
150
|
+
function classes(...values) {
|
|
151
|
+
return values.filter(Boolean).join(" ");
|
|
152
|
+
}
|