@mcpview/components 0.10.0 → 0.12.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.
Files changed (50) hide show
  1. package/README.md +73 -9
  2. package/esm/preact-components.d.ts +1 -1
  3. package/esm/preact-components.d.ts.map +1 -1
  4. package/esm/preact-context.d.ts +10 -0
  5. package/esm/preact-context.d.ts.map +1 -0
  6. package/esm/preact-context.js +6 -0
  7. package/esm/src/context-basket-labels.d.ts +21 -0
  8. package/esm/src/context-basket-labels.d.ts.map +1 -0
  9. package/esm/src/context-basket-labels.js +40 -0
  10. package/esm/src/context-basket-styles.d.ts +8 -0
  11. package/esm/src/context-basket-styles.d.ts.map +1 -0
  12. package/esm/src/context-basket-styles.js +113 -0
  13. package/esm/src/preact/context-basket.d.ts +61 -0
  14. package/esm/src/preact/context-basket.d.ts.map +1 -0
  15. package/esm/src/preact/context-basket.js +201 -0
  16. package/esm/src/preact/mod.d.ts +1 -1
  17. package/esm/src/preact/mod.d.ts.map +1 -1
  18. package/esm/src/preact/plots.d.ts +15 -4
  19. package/esm/src/preact/plots.d.ts.map +1 -1
  20. package/esm/src/preact/plots.js +39 -25
  21. package/esm/src/preact/use-active-context.d.ts +15 -0
  22. package/esm/src/preact/use-active-context.d.ts.map +1 -0
  23. package/esm/src/preact/use-active-context.js +28 -0
  24. package/esm/src/theme.d.ts.map +1 -1
  25. package/esm/src/theme.js +92 -5
  26. package/package.json +10 -2
  27. package/script/preact-components.d.ts +1 -1
  28. package/script/preact-components.d.ts.map +1 -1
  29. package/script/preact-context.d.ts +10 -0
  30. package/script/preact-context.d.ts.map +1 -0
  31. package/script/preact-context.js +17 -0
  32. package/script/src/context-basket-labels.d.ts +21 -0
  33. package/script/src/context-basket-labels.d.ts.map +1 -0
  34. package/script/src/context-basket-labels.js +44 -0
  35. package/script/src/context-basket-styles.d.ts +8 -0
  36. package/script/src/context-basket-styles.d.ts.map +1 -0
  37. package/script/src/context-basket-styles.js +116 -0
  38. package/script/src/preact/context-basket.d.ts +61 -0
  39. package/script/src/preact/context-basket.d.ts.map +1 -0
  40. package/script/src/preact/context-basket.js +204 -0
  41. package/script/src/preact/mod.d.ts +1 -1
  42. package/script/src/preact/mod.d.ts.map +1 -1
  43. package/script/src/preact/plots.d.ts +15 -4
  44. package/script/src/preact/plots.d.ts.map +1 -1
  45. package/script/src/preact/plots.js +39 -25
  46. package/script/src/preact/use-active-context.d.ts +15 -0
  47. package/script/src/preact/use-active-context.d.ts.map +1 -0
  48. package/script/src/preact/use-active-context.js +31 -0
  49. package/script/src/theme.d.ts.map +1 -1
  50. package/script/src/theme.js +92 -5
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCP_VIEW_CONTEXT_SELECTION_CSS = exports.MCP_VIEW_CONTEXT_BASKET_CSS = void 0;
4
+ /** Optional plain CSS for the controlled context basket; uses the shared theme tokens. */
5
+ exports.MCP_VIEW_CONTEXT_BASKET_CSS = String.raw `
6
+ .mcp-view-context-root {
7
+ position: relative; display: inline-flex; min-width: 0; max-width: 100%;
8
+ align-items: center; gap: .375rem; color: var(--mcp-view-muted);
9
+ font-family: var(--mcp-view-font-body); font-size: var(--mcp-view-size-chip);
10
+ }
11
+ .mcp-view-context-single, .mcp-view-context-trigger {
12
+ display: inline-flex; min-width: 0; align-items: center; gap: .25rem;
13
+ border: 1px solid color-mix(in srgb, var(--mcp-view-accent) 30%, transparent);
14
+ border-radius: var(--mcp-view-radius-control, 5px);
15
+ background: color-mix(in srgb, var(--mcp-view-accent) 8%, transparent);
16
+ }
17
+ .mcp-view-context-single { padding: .125rem .125rem .125rem .5rem; }
18
+ .mcp-view-context-activeLabel, .mcp-view-context-trigger { color: var(--mcp-view-accent-text); }
19
+ .mcp-view-context-activeLabel, .mcp-view-context-chevron { flex-shrink: 0; }
20
+ .mcp-view-context-singleLabel, .mcp-view-context-itemLabel { color: var(--mcp-view-text); }
21
+ .mcp-view-context-singleLabel, .mcp-view-context-itemLabel, .mcp-view-context-itemDetail,
22
+ .mcp-view-context-eviction, .mcp-view-context-pendingLabel {
23
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
24
+ }
25
+ .mcp-view-context-trigger, .mcp-view-context-remove, .mcp-view-context-clearAll,
26
+ .mcp-view-context-retry {
27
+ font: inherit; cursor: pointer;
28
+ }
29
+ .mcp-view-context-trigger { padding: .25rem .5rem; }
30
+ .mcp-view-context-remove {
31
+ display: grid; width: 1.5rem; height: 1.5rem; flex-shrink: 0; place-items: center;
32
+ padding: 0; border: 0; border-radius: var(--mcp-view-radius-sm, 3px);
33
+ background: transparent; color: var(--mcp-view-quiet); font-size: var(--mcp-view-size-body); line-height: 1;
34
+ }
35
+ .mcp-view-context-trigger:hover, .mcp-view-context-remove:hover {
36
+ background: color-mix(in srgb, var(--mcp-view-accent) 12%, transparent);
37
+ }
38
+ .mcp-view-context-remove:hover { color: var(--mcp-view-text); }
39
+ .mcp-view-context-root button:focus-visible {
40
+ outline: 2px solid var(--mcp-view-accent); outline-offset: 1px;
41
+ }
42
+ .mcp-view-context-popover {
43
+ position: absolute; top: 100%; z-index: 30; margin-top: .375rem;
44
+ width: 14rem; max-width: calc(100vw - 24px); padding: .375rem;
45
+ border: 1px solid var(--mcp-view-border); border-radius: var(--mcp-view-radius, 8px);
46
+ background: var(--mcp-view-panel);
47
+ }
48
+ .mcp-view-context-popover[data-align="start"] { left: 0; }
49
+ .mcp-view-context-popover[data-align="end"] { right: 0; }
50
+ .mcp-view-context-list { display: flex; max-height: 16rem; flex-direction: column; overflow-y: auto; }
51
+ .mcp-view-context-item {
52
+ display: flex; min-width: 0; align-items: center; gap: .5rem;
53
+ border-radius: var(--mcp-view-radius-sm, 3px); padding: .25rem .375rem;
54
+ }
55
+ .mcp-view-context-item:hover { background: var(--mcp-view-subtle); }
56
+ .mcp-view-context-itemContent { min-width: 0; flex: 1; }
57
+ .mcp-view-context-itemLabel, .mcp-view-context-itemDetail { display: block; }
58
+ .mcp-view-context-itemDetail, .mcp-view-context-clearAll, .mcp-view-context-eviction {
59
+ font-size: var(--mcp-view-size-micro); color: var(--mcp-view-quiet);
60
+ }
61
+ .mcp-view-context-clearAll {
62
+ width: 100%; margin-top: .25rem; padding: .375rem .375rem 0;
63
+ border: 0; border-top: 1px solid var(--mcp-view-border-soft);
64
+ background: transparent; text-align: left;
65
+ }
66
+ .mcp-view-context-clearAll:hover, .mcp-view-context-error { color: var(--mcp-view-danger); }
67
+ .mcp-view-context-pending, .mcp-view-context-error { display: inline-flex; align-items: center; gap: .25rem; }
68
+ .mcp-view-context-pending { min-width: 0; }
69
+ .mcp-view-context-error { flex-shrink: 0; }
70
+ .mcp-view-context-spinner { flex-shrink: 0; animation: mcp-view-context-spin 1s linear infinite; }
71
+ .mcp-view-context-eviction { max-width: 9rem; }
72
+ .mcp-view-context-root[data-compact] .mcp-view-context-singleLabel,
73
+ .mcp-view-context-root[data-compact] .mcp-view-context-eviction { max-width: 6rem; }
74
+ .mcp-view-context-root[data-compact] .mcp-view-context-activeLabel,
75
+ .mcp-view-context-errorLabel[data-hidden] {
76
+ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
77
+ overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
78
+ }
79
+ .mcp-view-context-retry {
80
+ border: 1px solid currentColor; border-radius: var(--mcp-view-radius-sm, 3px);
81
+ padding: .125rem .375rem; background: transparent; color: inherit;
82
+ }
83
+ .mcp-view-context-root button:disabled { cursor: default; opacity: .55; }
84
+ @keyframes mcp-view-context-spin { to { transform: rotate(360deg); } }
85
+ @media (prefers-reduced-motion: reduce) { .mcp-view-context-spinner { animation: none; } }
86
+ `;
87
+ /**
88
+ * Optional row/card selection treatment. Set data-context-state from
89
+ * useActiveContext().selectionState(item); shared light/dark theme tokens apply.
90
+ */
91
+ exports.MCP_VIEW_CONTEXT_SELECTION_CSS = String.raw `
92
+ .mcp-view-context-selection {
93
+ border: 1px solid var(--mcp-view-border); border-radius: var(--mcp-view-radius-control, 5px);
94
+ background: var(--mcp-view-panel); color: var(--mcp-view-text);
95
+ }
96
+ .mcp-view-context-selection[data-context-state="selected"] {
97
+ border-color: var(--mcp-view-accent);
98
+ background: color-mix(in srgb, var(--mcp-view-accent) 12%, var(--mcp-view-panel));
99
+ box-shadow: inset 3px 0 var(--mcp-view-accent);
100
+ }
101
+ .mcp-view-context-selection[data-context-state="adding"] {
102
+ border-color: var(--mcp-view-accent); border-style: dashed;
103
+ background: color-mix(in srgb, var(--mcp-view-accent) 12%, var(--mcp-view-panel));
104
+ box-shadow: inset 3px 0 var(--mcp-view-accent);
105
+ }
106
+ .mcp-view-context-selection[data-context-state="removing"] {
107
+ border-color: var(--mcp-view-quiet); border-style: dashed;
108
+ background: var(--mcp-view-subtle); color: var(--mcp-view-muted);
109
+ }
110
+ .mcp-view-context-selection:focus-visible {
111
+ outline: 2px solid var(--mcp-view-accent); outline-offset: 2px;
112
+ }
113
+ .mcp-view-context-selection-status {
114
+ margin-inline-start: .5rem; font-size: var(--mcp-view-size-chip); color: var(--mcp-view-muted);
115
+ }
116
+ `;
@@ -0,0 +1,61 @@
1
+ /** @jsxImportSource preact */
2
+ import type { JSX } from "preact";
3
+ /** Minimum presentation identity; the owning controller retains the full payload. */
4
+ export interface ContextBasketSelection {
5
+ readonly scopeKey: string;
6
+ readonly item: {
7
+ readonly id: string;
8
+ readonly label: string;
9
+ readonly view?: string;
10
+ readonly value?: string;
11
+ };
12
+ }
13
+ /** A caller-projected group: identities, membership and summaries remain caller-owned. */
14
+ export interface ContextBasketGroup {
15
+ readonly scopeKey: string;
16
+ readonly id: string;
17
+ readonly label: string;
18
+ readonly summary?: string;
19
+ readonly view?: string;
20
+ readonly value?: string;
21
+ }
22
+ export type ContextBasketEntry<T extends ContextBasketSelection = ContextBasketSelection> = {
23
+ readonly kind: "single";
24
+ readonly selection: T;
25
+ } | {
26
+ readonly kind: "group";
27
+ readonly group: ContextBasketGroup;
28
+ };
29
+ /** Every visible message and accessible name follows the caller's locale. */
30
+ export interface ContextBasketLabels {
31
+ readonly active: string;
32
+ readonly items: string;
33
+ readonly remove: (label: string) => string;
34
+ readonly clearAll: string;
35
+ readonly pending: string;
36
+ readonly error: string;
37
+ readonly retry: string;
38
+ readonly evicted: (label: string) => string;
39
+ }
40
+ export type ContextBasketSlot = "root" | "single" | "activeLabel" | "singleLabel" | "remove" | "trigger" | "chevron" | "popover" | "list" | "item" | "itemContent" | "itemLabel" | "itemDetail" | "clearAll" | "pending" | "spinner" | "error" | "errorLabel" | "eviction" | "pendingLabel" | "retry";
41
+ export type ContextMutation = () => unknown | Promise<unknown>;
42
+ export interface ActiveContextChipProps<T extends ContextBasketSelection = ContextBasketSelection> {
43
+ readonly selections: readonly T[];
44
+ /** Overrides the visible list, e.g. one entry per group instead of its projected members. */
45
+ readonly entries?: readonly ContextBasketEntry<T>[];
46
+ readonly labels: ContextBasketLabels;
47
+ readonly failed?: boolean;
48
+ readonly pending?: boolean;
49
+ readonly evictedLabel?: string | null;
50
+ readonly onRemove?: (selection: T) => unknown | Promise<unknown>;
51
+ readonly onRemoveGroup?: (group: ContextBasketGroup) => unknown | Promise<unknown>;
52
+ readonly onClear: ContextMutation;
53
+ readonly onRetry?: ContextMutation;
54
+ readonly compact?: boolean;
55
+ readonly popoverAlign?: "start" | "end";
56
+ readonly className?: string;
57
+ readonly classes?: Partial<Record<ContextBasketSlot, string>>;
58
+ }
59
+ /** Controlled basket. Acknowledged selections and mutation results remain caller-owned. */
60
+ export declare function ActiveContextChip<T extends ContextBasketSelection>({ selections, entries, labels, failed, pending, evictedLabel, onRemove, onRemoveGroup, onClear, onRetry, compact, popoverAlign, className, classes, }: ActiveContextChipProps<T>): JSX.Element | null;
61
+ //# sourceMappingURL=context-basket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-basket.d.ts","sourceRoot":"","sources":["../../../src/src/preact/context-basket.tsx"],"names":[],"mappings":"AAAA,8BAA8B;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AE,eAAe,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/D;AAsCD,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,sBAAsB,EAChE,EACE,UAAU,EACV,OAAO,EACP,MAAM,EACN,MAAc,EACd,OAAe,EACf,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EACP,OAAO,EACP,OAAe,EACf,YAAoB,EACpB,SAAS,EACT,OAAO,GACR,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAC3B,GAAG,CAAC,OAAO,GAAG,IAAI,CA0QpB"}
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActiveContextChip = ActiveContextChip;
4
+ const jsx_runtime_1 = require("preact/jsx-runtime");
5
+ const hooks_1 = require("preact/hooks");
6
+ const FOCUSABLE_SELECTOR = [
7
+ "a[href]",
8
+ "button:not([disabled])",
9
+ "input:not([disabled])",
10
+ "select:not([disabled])",
11
+ "textarea:not([disabled])",
12
+ '[tabindex]:not([tabindex="-1"])',
13
+ ].join(",");
14
+ function accepted(result) {
15
+ return result === "shared" || result === "cleared";
16
+ }
17
+ function outsideFocusable(wrapper) {
18
+ if (!wrapper)
19
+ return null;
20
+ const elements = Array.from(wrapper.ownerDocument.querySelectorAll(FOCUSABLE_SELECTOR));
21
+ const current = elements.indexOf(wrapper.ownerDocument.activeElement);
22
+ return elements.slice(current + 1).find((element) => !wrapper.contains(element)) ??
23
+ elements.slice(0, Math.max(0, current)).reverse().find((element) => !wrapper.contains(element)) ??
24
+ null;
25
+ }
26
+ function entryKey(entry) {
27
+ return entry.kind === "group"
28
+ ? JSON.stringify(["group", entry.group.scopeKey, entry.group.id])
29
+ : JSON.stringify(["single", entry.selection.scopeKey, entry.selection.item.id]);
30
+ }
31
+ function display(entry) {
32
+ return entry.kind === "group" ? entry.group : entry.selection.item;
33
+ }
34
+ /** Controlled basket. Acknowledged selections and mutation results remain caller-owned. */
35
+ function ActiveContextChip({ selections, entries, labels, failed = false, pending = false, evictedLabel, onRemove, onRemoveGroup, onClear, onRetry, compact = false, popoverAlign = "end", className, classes, }) {
36
+ const slot = (name) => [`mcp-view-context-${name}`, classes?.[name]].filter(Boolean).join(" ");
37
+ const [open, setOpen] = (0, hooks_1.useState)(false);
38
+ const wrapperRef = (0, hooks_1.useRef)(null);
39
+ const triggerRef = (0, hooks_1.useRef)(null);
40
+ const singleRemoveRef = (0, hooks_1.useRef)(null);
41
+ const removeRefs = (0, hooks_1.useRef)(new Map());
42
+ const mountedRef = (0, hooks_1.useRef)(true);
43
+ const operationRef = (0, hooks_1.useRef)(0);
44
+ const popoverId = (0, hooks_1.useId)();
45
+ const visible = entries ??
46
+ selections.map((selection) => ({ kind: "single", selection }));
47
+ const visibleRef = (0, hooks_1.useRef)(visible);
48
+ visibleRef.current = visible;
49
+ const count = visible.length;
50
+ (0, hooks_1.useLayoutEffect)(() => {
51
+ mountedRef.current = true;
52
+ return () => {
53
+ mountedRef.current = false;
54
+ operationRef.current++;
55
+ };
56
+ }, []);
57
+ (0, hooks_1.useEffect)(() => {
58
+ if (count <= 1)
59
+ setOpen(false);
60
+ }, [count]);
61
+ (0, hooks_1.useEffect)(() => {
62
+ if (!open)
63
+ return;
64
+ const doc = wrapperRef.current.ownerDocument;
65
+ function pointer(event) {
66
+ if (!wrapperRef.current?.contains(event.target)) {
67
+ operationRef.current++;
68
+ setOpen(false);
69
+ }
70
+ }
71
+ function key(event) {
72
+ if (event.key !== "Escape")
73
+ return;
74
+ event.preventDefault();
75
+ operationRef.current++;
76
+ setOpen(false);
77
+ triggerRef.current?.focus();
78
+ }
79
+ doc.addEventListener("pointerdown", pointer);
80
+ doc.addEventListener("keydown", key);
81
+ return () => {
82
+ doc.removeEventListener("pointerdown", pointer);
83
+ doc.removeEventListener("keydown", key);
84
+ };
85
+ }, [open]);
86
+ // Run after the controlled render, and never steal focus back from a user who moved away.
87
+ function afterAccepted(operation, origin, callback) {
88
+ queueMicrotask(() => {
89
+ if (!mountedRef.current || operation !== operationRef.current)
90
+ return;
91
+ const current = origin?.ownerDocument.activeElement;
92
+ // A removed button naturally loses browser focus; a deliberate focus change wins.
93
+ if (origin && current !== origin && current !== origin.ownerDocument.body)
94
+ return;
95
+ callback();
96
+ });
97
+ }
98
+ async function remove(entry, index) {
99
+ const operation = ++operationRef.current;
100
+ const origin = wrapperRef.current?.ownerDocument.activeElement ?? null;
101
+ const external = outsideFocusable(wrapperRef.current);
102
+ let result;
103
+ try {
104
+ result = await (entry.kind === "group"
105
+ ? onRemoveGroup?.(entry.group)
106
+ : onRemove
107
+ ? onRemove(entry.selection)
108
+ : count === 1
109
+ ? onClear()
110
+ : undefined);
111
+ }
112
+ catch {
113
+ return;
114
+ }
115
+ if (!accepted(result))
116
+ return;
117
+ afterAccepted(operation, origin, () => {
118
+ const remaining = visibleRef.current;
119
+ if (!remaining.length) {
120
+ if (external?.isConnected)
121
+ external.focus({ preventScroll: true });
122
+ }
123
+ else if (remaining.length === 1) {
124
+ singleRemoveRef.current?.focus({ preventScroll: true });
125
+ }
126
+ else {
127
+ const neighbour = remaining[Math.min(index, remaining.length - 1)];
128
+ (removeRefs.current.get(entryKey(neighbour)) ?? triggerRef.current)?.focus({
129
+ preventScroll: true,
130
+ });
131
+ }
132
+ });
133
+ }
134
+ async function clear() {
135
+ const operation = ++operationRef.current;
136
+ const origin = wrapperRef.current?.ownerDocument.activeElement ?? null;
137
+ const external = outsideFocusable(wrapperRef.current);
138
+ let result;
139
+ try {
140
+ result = await onClear();
141
+ }
142
+ catch {
143
+ return;
144
+ }
145
+ if (!accepted(result))
146
+ return;
147
+ afterAccepted(operation, origin, () => {
148
+ setOpen(false);
149
+ if (external?.isConnected)
150
+ external.focus({ preventScroll: true });
151
+ });
152
+ }
153
+ async function retry() {
154
+ const operation = ++operationRef.current;
155
+ const origin = wrapperRef.current?.ownerDocument.activeElement ?? null;
156
+ const external = outsideFocusable(wrapperRef.current);
157
+ let result;
158
+ try {
159
+ result = await onRetry?.();
160
+ }
161
+ catch {
162
+ return;
163
+ }
164
+ if (!accepted(result))
165
+ return;
166
+ afterAccepted(operation, origin, () => {
167
+ // Retry may clear the basket, remove one item, or retain its confirmed list.
168
+ // Choose from the controlled render after ACK rather than the failed intent.
169
+ const retained = visibleRef.current.length === 1
170
+ ? singleRemoveRef.current
171
+ : triggerRef.current;
172
+ if (retained?.isConnected && !retained.disabled) {
173
+ retained.focus({ preventScroll: true });
174
+ }
175
+ else if (origin?.isConnected) {
176
+ origin.focus({ preventScroll: true });
177
+ }
178
+ else if (external?.isConnected) {
179
+ external.focus({ preventScroll: true });
180
+ }
181
+ });
182
+ }
183
+ function removeButton(entry, index, single = false) {
184
+ const item = display(entry);
185
+ return ((0, jsx_runtime_1.jsx)("button", { type: "button", class: slot("remove"), ref: (element) => {
186
+ if (single)
187
+ singleRemoveRef.current = element;
188
+ if (element)
189
+ removeRefs.current.set(entryKey(entry), element);
190
+ else
191
+ removeRefs.current.delete(entryKey(entry));
192
+ }, disabled: pending || (entry.kind === "group" ? !onRemoveGroup : !onRemove && count > 1), "aria-label": labels.remove(item.label), title: labels.remove(item.label), onClick: () => void remove(entry, index), children: (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: "\u00D7" }) }));
193
+ }
194
+ if (count === 0 && !failed && !pending && !evictedLabel)
195
+ return null;
196
+ return ((0, jsx_runtime_1.jsxs)("span", { ref: wrapperRef, "aria-busy": pending || undefined, class: [slot("root"), className].filter(Boolean).join(" "), "data-compact": compact || undefined, children: [count === 1 && ((0, jsx_runtime_1.jsxs)("span", { class: slot("single"), "aria-live": "polite", "aria-atomic": "true", children: [(0, jsx_runtime_1.jsx)("span", { class: slot("activeLabel"), children: labels.active }), (0, jsx_runtime_1.jsx)("span", { class: slot("singleLabel"), title: display(visible[0]).label, children: display(visible[0]).label }), removeButton(visible[0], 0, true)] })), count > 1 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { ref: triggerRef, type: "button", class: slot("trigger"), "aria-expanded": open, "aria-controls": open ? popoverId : undefined, "aria-haspopup": "dialog", onClick: () => {
197
+ operationRef.current++;
198
+ setOpen((value) => !value);
199
+ }, children: [(0, jsx_runtime_1.jsxs)("span", { "aria-live": "polite", "aria-atomic": "true", children: [labels.active, " \u00B7 ", count] }), (0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: slot("chevron"), children: open ? "▴" : "▾" })] }), open && ((0, jsx_runtime_1.jsxs)("span", { id: popoverId, role: "dialog", "aria-label": labels.items, class: slot("popover"), "data-align": popoverAlign, children: [(0, jsx_runtime_1.jsx)("span", { role: "list", class: slot("list"), children: visible.map((entry, index) => {
200
+ const item = display(entry);
201
+ const summary = entry.kind === "group" ? entry.group.summary : undefined;
202
+ return ((0, jsx_runtime_1.jsxs)("span", { role: "listitem", class: slot("item"), children: [(0, jsx_runtime_1.jsxs)("span", { class: slot("itemContent"), children: [(0, jsx_runtime_1.jsx)("span", { class: slot("itemLabel"), children: item.label }), (0, jsx_runtime_1.jsx)("span", { class: slot("itemDetail"), children: summary ?? [item.view, item.value].filter(Boolean).join(" · ") })] }), removeButton(entry, index)] }, entryKey(entry)));
203
+ }) }), (0, jsx_runtime_1.jsx)("button", { type: "button", class: slot("clearAll"), disabled: pending, onClick: () => void clear(), children: labels.clearAll })] }))] })), pending && ((0, jsx_runtime_1.jsxs)("span", { role: "status", "aria-live": "polite", class: slot("pending"), title: labels.pending, children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: slot("spinner"), children: "\u25CC" }), (0, jsx_runtime_1.jsx)("span", { class: slot("pendingLabel"), children: labels.pending })] })), failed && ((0, jsx_runtime_1.jsxs)("span", { role: "status", class: slot("error"), title: labels.error, children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", children: "!" }), (0, jsx_runtime_1.jsx)("span", { class: slot("errorLabel"), "data-hidden": compact && count > 0 || undefined, children: labels.error }), onRetry && ((0, jsx_runtime_1.jsx)("button", { type: "button", class: slot("retry"), disabled: pending, onClick: () => void retry(), children: labels.retry }))] })), evictedLabel && ((0, jsx_runtime_1.jsx)("span", { role: "status", "aria-live": "polite", class: slot("eviction"), title: labels.evicted(evictedLabel), children: labels.evicted(evictedLabel) }))] }));
204
+ }
@@ -2,5 +2,5 @@
2
2
  export { definePreactComponent, preactSurfaceRenderer, startPreactSurfaceApp, SurfaceAppError, } from "./surface.js";
3
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
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";
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, SeriesChartTone, SeriesPoint, SkeletonProps, Slot3DProps, SparklineProps, StackProps, StaleBannerAction, StaleBannerProps, StateMessageProps, StatusMessageMount, TextInputProps, ToolbarProps, TreeListNode, TreeListProps, TypeBadgeProps, ViewKind, } from "../../preact-components.js";
6
6
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +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"}
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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AAW,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"}
@@ -9,6 +9,8 @@
9
9
  */
10
10
  import type { JSX } from "preact";
11
11
  import type { PresentationTone } from "./components.js";
12
+ /** Plot colors, including the two categorical theme colors. */
13
+ export type SeriesChartTone = PresentationTone | "accent" | "brand";
12
14
  export interface SparklineProps {
13
15
  /** Accessible name of the sampled quantity. */
14
16
  readonly label: string;
@@ -16,11 +18,13 @@ export interface SparklineProps {
16
18
  readonly values: readonly number[];
17
19
  /** Caller-formatted summary, including units. */
18
20
  readonly summaryLabel: string;
19
- readonly tone?: PresentationTone;
21
+ /** Inline mark by default; block also displays the supplied label and summary. */
22
+ readonly variant?: "inline" | "block";
23
+ readonly tone?: SeriesChartTone;
20
24
  readonly className?: string;
21
25
  }
22
26
  /** 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;
27
+ export declare function Sparkline({ label, values, summaryLabel, variant, tone, className, }: SparklineProps): JSX.Element;
24
28
  export interface SeriesPoint {
25
29
  readonly x: number;
26
30
  readonly y: number;
@@ -42,7 +46,7 @@ export interface SeriesChartSeries {
42
46
  readonly mark: SeriesMark;
43
47
  /** At least two finite points, already ordered by the caller. */
44
48
  readonly points: readonly SeriesPoint[];
45
- readonly tone?: PresentationTone;
49
+ readonly tone?: SeriesChartTone;
46
50
  }
47
51
  export interface SeriesChartReadout {
48
52
  /** Must name one declared series. */
@@ -77,6 +81,13 @@ export interface SeriesChartProps {
77
81
  readonly xMax: number;
78
82
  readonly yMin: number;
79
83
  readonly yMax: number;
84
+ /** Show caller-labelled series keys when at least two series are present. */
85
+ readonly legend?: boolean;
86
+ /** Caller-formatted y ticks on the declared shared scale. */
87
+ readonly yTicks?: readonly {
88
+ readonly value: number;
89
+ readonly label: string;
90
+ }[];
80
91
  /** Caller-formatted ticks, left to right. */
81
92
  readonly axisLabels?: readonly string[];
82
93
  /** Caller-computed extrema. The chart never scans the samples for them. */
@@ -92,7 +103,7 @@ export interface SeriesChartProps {
92
103
  readonly className?: string;
93
104
  }
94
105
  /** 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;
106
+ export declare function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, legend, yTicks, summary, cursor, onScrub, className, }: SeriesChartProps): JSX.Element;
96
107
  export interface IntervalPlotInterval {
97
108
  readonly id: string;
98
109
  /** Caller wording for the interval, such as a tolerance class. */
@@ -1 +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,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAa,EACb,SAAS,GACV,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CA6B9B;AAED,MAAM,WAAW,WAAW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,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"}
@@ -8,7 +8,7 @@ const SPARKLINE_VIEWBOX_HEIGHT = 24;
8
8
  const SERIES_CHART_VIEWBOX_HEIGHT = 40;
9
9
  const VIEWBOX_WIDTH = 100;
10
10
  /** Compact shape of one recorded series, readable at chip and row density. */
11
- function Sparkline({ label, values, summaryLabel, tone = "info", className, }) {
11
+ function Sparkline({ label, values, summaryLabel, variant = "inline", tone = "info", className, }) {
12
12
  validateSamples(values, "Sparkline values");
13
13
  const min = Math.min(...values);
14
14
  const max = Math.max(...values);
@@ -20,11 +20,19 @@ function Sparkline({ label, values, summaryLabel, tone = "info", className, }) {
20
20
  return `${round(x)},${round(y)}`;
21
21
  })
22
22
  .join(" ");
23
- return ((0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("polyline", { class: "mcp-view-sparkline-line", points: points, "vector-effect": "non-scaling-stroke" }) }));
23
+ const plot = ((0, jsx_runtime_1.jsx)("svg", { "aria-label": variant === "inline" ? `${label}: ${summaryLabel}` : undefined, "aria-hidden": variant === "block" ? true : undefined, class: classes("mcp-view-sparkline", variant === "inline" ? className : undefined), "data-tone": tone, preserveAspectRatio: "none", role: variant === "inline" ? "img" : undefined, viewBox: `0 0 ${VIEWBOX_WIDTH} ${SPARKLINE_VIEWBOX_HEIGHT}`, children: (0, jsx_runtime_1.jsx)("polyline", { class: "mcp-view-sparkline-line", points: points, "vector-effect": "non-scaling-stroke" }) }));
24
+ if (variant === "inline")
25
+ return plot;
26
+ return ((0, jsx_runtime_1.jsxs)("div", { "aria-label": `${label}: ${summaryLabel}`, class: classes("mcp-view-sparkline-block", className), role: "img", children: [(0, jsx_runtime_1.jsxs)("div", { "aria-hidden": "true", class: "mcp-view-sparkline-heading", children: [(0, jsx_runtime_1.jsx)("span", { children: label }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-sparkline-summary", children: summaryLabel })] }), plot] }));
24
27
  }
25
28
  /** Multi-series plot on one shared finite scale, with a declared cursor readout. */
26
- function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, summary, cursor, onScrub, className, }) {
29
+ function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, legend = true, yTicks, summary, cursor, onScrub, className, }) {
27
30
  validateSeriesChart(series, xMin, xMax, yMin, yMax, cursor);
31
+ for (const tick of yTicks ?? []) {
32
+ if (!Number.isFinite(tick.value) || tick.value < yMin || tick.value > yMax) {
33
+ throw new RangeError("SeriesChart yTicks value must be within yMin and yMax");
34
+ }
35
+ }
28
36
  const baselineY = yMin <= 0 && 0 <= yMax
29
37
  ? SERIES_CHART_VIEWBOX_HEIGHT - normalize(0, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT
30
38
  : undefined;
@@ -32,28 +40,34 @@ function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, summar
32
40
  ? undefined
33
41
  : normalize(cursor.x, xMin, xMax) * VIEWBOX_WIDTH;
34
42
  const seriesLabels = series.map((one) => one.label).join(", ");
35
- return ((0, jsx_runtime_1.jsxs)("figure", { class: classes("mcp-view-series-chart", className), children: [(0, jsx_runtime_1.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) => {
36
- const box = event.currentTarget.getBoundingClientRect();
37
- if (box.width === 0)
38
- return;
39
- const ratio = (event.clientX - box.left) / box.width;
40
- if (ratio < 0 || ratio > 1)
41
- return;
42
- onScrub(xMin + ratio * (xMax - xMin));
43
- }, children: [baselineY !== undefined && ((0, jsx_runtime_1.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 && ((0, jsx_runtime_1.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) => {
44
- const placed = one.points.map((point) => ({
45
- x: normalize(point.x, xMin, xMax) * VIEWBOX_WIDTH,
46
- y: SERIES_CHART_VIEWBOX_HEIGHT -
47
- normalize(point.y, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT,
48
- }));
49
- if (one.mark === "line") {
50
- return ((0, jsx_runtime_1.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));
51
- }
52
- // Each recorded sample stands alone, anchored on the drawn baseline
53
- // when the scale carries zero, otherwise on the floor of the scale.
54
- const foot = baselineY ?? SERIES_CHART_VIEWBOX_HEIGHT;
55
- return ((0, jsx_runtime_1.jsx)("g", { class: "mcp-view-series-chart-bars", "data-tone": one.tone ?? "info", children: placed.map((at, index) => ((0, jsx_runtime_1.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));
56
- })] }), axisLabels && axisLabels.length > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", class: "mcp-view-series-chart-axis", children: axisLabels.map((tick) => (0, jsx_runtime_1.jsx)("span", { children: tick }, tick)) })), cursor && ((0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-series-chart-readout", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-series-chart-readout-position", children: cursor.label }), (0, jsx_runtime_1.jsx)("dl", { class: "mcp-view-series-chart-readout-values", children: cursor.readouts.map((readout) => {
43
+ return ((0, jsx_runtime_1.jsxs)("figure", { class: classes("mcp-view-series-chart", className), children: [legend && series.length >= 2 && (
44
+ // The SVG's aria-label already names every series: the visual legend
45
+ // stays out of the accessibility tree so nothing is read twice.
46
+ (0, jsx_runtime_1.jsx)("ul", { "aria-hidden": "true", class: "mcp-view-series-chart-legend", children: series.map((one) => ((0, jsx_runtime_1.jsxs)("li", { "data-tone": one.tone ?? "info", children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-series-chart-legend-mark", "data-mark": one.mark }), (0, jsx_runtime_1.jsx)("span", { children: one.label })] }, one.id))) })), (0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-series-chart-frame", yTicks?.length ? "mcp-view-series-chart-frame-ticks" : undefined), children: [yTicks && yTicks.length > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", class: "mcp-view-series-chart-y-axis", children: yTicks.map((tick, index) => ((0, jsx_runtime_1.jsx)("span", { style: { top: `${round((1 - normalize(tick.value, yMin, yMax)) * 100)}%` }, children: tick.label }, index))) })), (0, jsx_runtime_1.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) => {
47
+ const box = event.currentTarget.getBoundingClientRect();
48
+ if (box.width === 0)
49
+ return;
50
+ const ratio = (event.clientX - box.left) / box.width;
51
+ if (ratio < 0 || ratio > 1)
52
+ return;
53
+ onScrub(xMin + ratio * (xMax - xMin));
54
+ }, children: [yTicks?.map((tick, index) => {
55
+ const y = round((1 - normalize(tick.value, yMin, yMax)) * SERIES_CHART_VIEWBOX_HEIGHT);
56
+ return ((0, jsx_runtime_1.jsx)("line", { class: "mcp-view-series-chart-grid", "vector-effect": "non-scaling-stroke", x1: 0, x2: VIEWBOX_WIDTH, y1: y, y2: y }, index));
57
+ }), baselineY !== undefined && ((0, jsx_runtime_1.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 && ((0, jsx_runtime_1.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) => {
58
+ const placed = one.points.map((point) => ({
59
+ x: normalize(point.x, xMin, xMax) * VIEWBOX_WIDTH,
60
+ y: SERIES_CHART_VIEWBOX_HEIGHT -
61
+ normalize(point.y, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT,
62
+ }));
63
+ if (one.mark === "line") {
64
+ return ((0, jsx_runtime_1.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));
65
+ }
66
+ // Each recorded sample stands alone, anchored on the drawn baseline
67
+ // when the scale carries zero, otherwise on the floor of the scale.
68
+ const foot = baselineY ?? SERIES_CHART_VIEWBOX_HEIGHT;
69
+ return ((0, jsx_runtime_1.jsx)("g", { class: "mcp-view-series-chart-bars", "data-tone": one.tone ?? "info", children: placed.map((at, index) => ((0, jsx_runtime_1.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));
70
+ })] }), axisLabels && axisLabels.length > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": "true", class: "mcp-view-series-chart-axis", children: axisLabels.map((tick) => (0, jsx_runtime_1.jsx)("span", { children: tick }, tick)) }))] }), cursor && ((0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-series-chart-readout", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-series-chart-readout-position", children: cursor.label }), (0, jsx_runtime_1.jsx)("dl", { class: "mcp-view-series-chart-readout-values", children: cursor.readouts.map((readout) => {
57
71
  const owner = series.find((one) => one.id === readout.seriesId);
58
72
  return ((0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-series-chart-readout-value", children: [(0, jsx_runtime_1.jsx)("dt", { "data-tone": owner?.tone ?? "info", children: owner?.label }), (0, jsx_runtime_1.jsx)("dd", { children: readout.valueLabel })] }, readout.seriesId));
59
73
  }) })] })), summary && summary.length > 0 && ((0, jsx_runtime_1.jsx)("figcaption", { class: "mcp-view-series-chart-summary", children: summary.map((item) => ((0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-series-chart-summary-item", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-series-chart-summary-label", children: item.label }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-series-chart-summary-value", children: item.valueLabel })] }, item.id))) }))] }));
@@ -0,0 +1,15 @@
1
+ import type { ActiveContextActions, ActiveContextController, ActiveContextState } from "@mcpview/view/context";
2
+ export type { ActiveContextReconcileResult } from "@mcpview/view/context";
3
+ /** ACK-confirmed basket, provisional row states and actions for the current root. */
4
+ export interface ActiveContextHook extends ActiveContextState, ActiveContextActions {
5
+ retry: ActiveContextController["retry"];
6
+ dismissFailure: ActiveContextController["dismissFailure"];
7
+ dismissEviction: ActiveContextController["dismissEviction"];
8
+ }
9
+ /**
10
+ * Subscribe to a controller owned outside the render tree. Surface remounts only
11
+ * unsubscribe; they never clear, dispose or recreate the App's context queue.
12
+ * Changing scope invalidates old handlers immediately, then queues the root clear.
13
+ */
14
+ export declare function useActiveContext(controller: ActiveContextController, scopeKey: string): ActiveContextHook;
15
+ //# sourceMappingURL=use-active-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-active-context.d.ts","sourceRoot":"","sources":["../../../src/src/preact/use-active-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAE1E,qFAAqF;AACrF,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB,EAAE,oBAAoB;IACjF,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACxC,cAAc,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAC1D,eAAe,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;CAC7D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,uBAAuB,EACnC,QAAQ,EAAE,MAAM,GACf,iBAAiB,CAqBnB"}