@mcpview/components 0.0.0-stage → 0.11.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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +593 -2
  3. package/esm/_dnt.polyfills.d.ts +12 -0
  4. package/esm/_dnt.polyfills.d.ts.map +1 -0
  5. package/esm/_dnt.polyfills.js +15 -0
  6. package/esm/fonts.d.ts +13 -0
  7. package/esm/fonts.d.ts.map +1 -0
  8. package/esm/fonts.js +12 -0
  9. package/esm/layout.d.ts +14 -0
  10. package/esm/layout.d.ts.map +1 -0
  11. package/esm/layout.js +13 -0
  12. package/esm/mod.d.ts +19 -0
  13. package/esm/mod.d.ts.map +1 -0
  14. package/esm/mod.js +14 -0
  15. package/esm/package.json +3 -0
  16. package/esm/preact-components.d.ts +22 -0
  17. package/esm/preact-components.d.ts.map +1 -0
  18. package/esm/preact-components.js +20 -0
  19. package/esm/preact.d.ts +10 -0
  20. package/esm/preact.d.ts.map +1 -0
  21. package/esm/preact.js +9 -0
  22. package/esm/src/component-primitives.d.ts +41 -0
  23. package/esm/src/component-primitives.d.ts.map +1 -0
  24. package/esm/src/component-primitives.js +121 -0
  25. package/esm/src/components.d.ts +50 -0
  26. package/esm/src/components.d.ts.map +1 -0
  27. package/esm/src/components.js +283 -0
  28. package/esm/src/font-families.d.ts +16 -0
  29. package/esm/src/font-families.d.ts.map +1 -0
  30. package/esm/src/font-families.js +11 -0
  31. package/esm/src/fonts-data.d.ts +2 -0
  32. package/esm/src/fonts-data.d.ts.map +1 -0
  33. package/esm/src/fonts-data.js +42 -0
  34. package/esm/src/fonts.d.ts +12 -0
  35. package/esm/src/fonts.d.ts.map +1 -0
  36. package/esm/src/fonts.js +19 -0
  37. package/esm/src/i18n.d.ts +44 -0
  38. package/esm/src/i18n.d.ts.map +1 -0
  39. package/esm/src/i18n.js +98 -0
  40. package/esm/src/layout/hooks.d.ts +60 -0
  41. package/esm/src/layout/hooks.d.ts.map +1 -0
  42. package/esm/src/layout/hooks.js +121 -0
  43. package/esm/src/layout/mod.d.ts +6 -0
  44. package/esm/src/layout/mod.d.ts.map +1 -0
  45. package/esm/src/layout/mod.js +3 -0
  46. package/esm/src/layout/viewer-layout.d.ts +82 -0
  47. package/esm/src/layout/viewer-layout.d.ts.map +1 -0
  48. package/esm/src/layout/viewer-layout.js +74 -0
  49. package/esm/src/preact/components.d.ts +215 -0
  50. package/esm/src/preact/components.d.ts.map +1 -0
  51. package/esm/src/preact/components.js +176 -0
  52. package/esm/src/preact/focused-view.d.ts +42 -0
  53. package/esm/src/preact/focused-view.d.ts.map +1 -0
  54. package/esm/src/preact/focused-view.js +20 -0
  55. package/esm/src/preact/mod.d.ts +6 -0
  56. package/esm/src/preact/mod.d.ts.map +1 -0
  57. package/esm/src/preact/mod.js +3 -0
  58. package/esm/src/preact/plots.d.ts +130 -0
  59. package/esm/src/preact/plots.d.ts.map +1 -0
  60. package/esm/src/preact/plots.js +166 -0
  61. package/esm/src/preact/semantic-element.d.ts +103 -0
  62. package/esm/src/preact/semantic-element.d.ts.map +1 -0
  63. package/esm/src/preact/semantic-element.js +103 -0
  64. package/esm/src/preact/structural.d.ts +178 -0
  65. package/esm/src/preact/structural.d.ts.map +1 -0
  66. package/esm/src/preact/structural.js +147 -0
  67. package/esm/src/preact/surface.d.ts +37 -0
  68. package/esm/src/preact/surface.d.ts.map +1 -0
  69. package/esm/src/preact/surface.js +47 -0
  70. package/esm/src/surface-app.d.ts +188 -0
  71. package/esm/src/surface-app.d.ts.map +1 -0
  72. package/esm/src/surface-app.js +374 -0
  73. package/esm/src/theme.d.ts +65 -0
  74. package/esm/src/theme.d.ts.map +1 -0
  75. package/esm/src/theme.js +1964 -0
  76. package/esm/surface.d.ts +12 -0
  77. package/esm/surface.d.ts.map +1 -0
  78. package/esm/surface.js +10 -0
  79. package/package.json +68 -4
  80. package/script/_dnt.polyfills.d.ts +12 -0
  81. package/script/_dnt.polyfills.d.ts.map +1 -0
  82. package/script/_dnt.polyfills.js +16 -0
  83. package/script/fonts.d.ts +13 -0
  84. package/script/fonts.d.ts.map +1 -0
  85. package/script/fonts.js +19 -0
  86. package/script/layout.d.ts +14 -0
  87. package/script/layout.d.ts.map +1 -0
  88. package/script/layout.js +29 -0
  89. package/script/mod.d.ts +19 -0
  90. package/script/mod.d.ts.map +1 -0
  91. package/script/mod.js +40 -0
  92. package/script/package.json +3 -0
  93. package/script/preact-components.d.ts +22 -0
  94. package/script/preact-components.d.ts.map +1 -0
  95. package/script/preact-components.js +68 -0
  96. package/script/preact.d.ts +10 -0
  97. package/script/preact.d.ts.map +1 -0
  98. package/script/preact.js +25 -0
  99. package/script/src/component-primitives.d.ts +41 -0
  100. package/script/src/component-primitives.d.ts.map +1 -0
  101. package/script/src/component-primitives.js +127 -0
  102. package/script/src/components.d.ts +50 -0
  103. package/script/src/components.d.ts.map +1 -0
  104. package/script/src/components.js +297 -0
  105. package/script/src/font-families.d.ts +16 -0
  106. package/script/src/font-families.d.ts.map +1 -0
  107. package/script/src/font-families.js +14 -0
  108. package/script/src/fonts-data.d.ts +2 -0
  109. package/script/src/fonts-data.d.ts.map +1 -0
  110. package/script/src/fonts-data.js +45 -0
  111. package/script/src/fonts.d.ts +12 -0
  112. package/script/src/fonts.d.ts.map +1 -0
  113. package/script/src/fonts.js +24 -0
  114. package/script/src/i18n.d.ts +44 -0
  115. package/script/src/i18n.d.ts.map +1 -0
  116. package/script/src/i18n.js +102 -0
  117. package/script/src/layout/hooks.d.ts +60 -0
  118. package/script/src/layout/hooks.d.ts.map +1 -0
  119. package/script/src/layout/hooks.js +126 -0
  120. package/script/src/layout/mod.d.ts +6 -0
  121. package/script/src/layout/mod.d.ts.map +1 -0
  122. package/script/src/layout/mod.js +17 -0
  123. package/script/src/layout/viewer-layout.d.ts +82 -0
  124. package/script/src/layout/viewer-layout.d.ts.map +1 -0
  125. package/script/src/layout/viewer-layout.js +83 -0
  126. package/script/src/preact/components.d.ts +215 -0
  127. package/script/src/preact/components.d.ts.map +1 -0
  128. package/script/src/preact/components.js +199 -0
  129. package/script/src/preact/focused-view.d.ts +42 -0
  130. package/script/src/preact/focused-view.d.ts.map +1 -0
  131. package/script/src/preact/focused-view.js +24 -0
  132. package/script/src/preact/mod.d.ts +6 -0
  133. package/script/src/preact/mod.d.ts.map +1 -0
  134. package/script/src/preact/mod.js +55 -0
  135. package/script/src/preact/plots.d.ts +130 -0
  136. package/script/src/preact/plots.d.ts.map +1 -0
  137. package/script/src/preact/plots.js +171 -0
  138. package/script/src/preact/semantic-element.d.ts +103 -0
  139. package/script/src/preact/semantic-element.d.ts.map +1 -0
  140. package/script/src/preact/semantic-element.js +115 -0
  141. package/script/src/preact/structural.d.ts +178 -0
  142. package/script/src/preact/structural.d.ts.map +1 -0
  143. package/script/src/preact/structural.js +158 -0
  144. package/script/src/preact/surface.d.ts +37 -0
  145. package/script/src/preact/surface.d.ts.map +1 -0
  146. package/script/src/preact/surface.js +53 -0
  147. package/script/src/surface-app.d.ts +188 -0
  148. package/script/src/surface-app.d.ts.map +1 -0
  149. package/script/src/surface-app.js +379 -0
  150. package/script/src/theme.d.ts +65 -0
  151. package/script/src/theme.d.ts.map +1 -0
  152. package/script/src/theme.js +1968 -0
  153. package/script/surface.d.ts +12 -0
  154. package/script/surface.d.ts.map +1 -0
  155. package/script/surface.js +15 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sparkline = Sparkline;
4
+ exports.SeriesChart = SeriesChart;
5
+ exports.IntervalPlot = IntervalPlot;
6
+ const jsx_runtime_1 = require("preact/jsx-runtime");
7
+ const SPARKLINE_VIEWBOX_HEIGHT = 24;
8
+ const SERIES_CHART_VIEWBOX_HEIGHT = 40;
9
+ const VIEWBOX_WIDTH = 100;
10
+ /** Compact shape of one recorded series, readable at chip and row density. */
11
+ function Sparkline({ label, values, summaryLabel, variant = "inline", tone = "info", className, }) {
12
+ validateSamples(values, "Sparkline values");
13
+ const min = Math.min(...values);
14
+ const max = Math.max(...values);
15
+ const points = values
16
+ .map((value, index) => {
17
+ const x = (index / (values.length - 1)) * VIEWBOX_WIDTH;
18
+ const y = SPARKLINE_VIEWBOX_HEIGHT -
19
+ normalize(value, min, max) * SPARKLINE_VIEWBOX_HEIGHT;
20
+ return `${round(x)},${round(y)}`;
21
+ })
22
+ .join(" ");
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] }));
27
+ }
28
+ /** Multi-series plot on one shared finite scale, with a declared cursor readout. */
29
+ function SeriesChart({ label, series, xMin, xMax, yMin, yMax, axisLabels, legend = true, yTicks, summary, cursor, onScrub, className, }) {
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
+ }
36
+ const baselineY = yMin <= 0 && 0 <= yMax
37
+ ? SERIES_CHART_VIEWBOX_HEIGHT - normalize(0, yMin, yMax) * SERIES_CHART_VIEWBOX_HEIGHT
38
+ : undefined;
39
+ const cursorX = cursor === undefined
40
+ ? undefined
41
+ : normalize(cursor.x, xMin, xMax) * VIEWBOX_WIDTH;
42
+ const seriesLabels = series.map((one) => one.label).join(", ");
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) => {
71
+ const owner = series.find((one) => one.id === readout.seriesId);
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));
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))) }))] }));
74
+ }
75
+ /** Caller-declared deviation intervals laid out against a shared zero line. */
76
+ function IntervalPlot({ label, min, max, zeroLabel, intervals, className, }) {
77
+ validateIntervalPlot(min, max, intervals);
78
+ const zeroOffset = `${round(normalize(0, min, max) * 100)}%`;
79
+ return ((0, jsx_runtime_1.jsxs)("div", { "aria-label": label, class: classes("mcp-view-interval-plot", className), role: "group", children: [(0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-interval-plot-scale", children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-interval-plot-zero", style: { left: zeroOffset } }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-interval-plot-zero-label", style: { left: zeroOffset }, children: zeroLabel })] }), intervals.map((interval) => ((0, jsx_runtime_1.jsxs)("div", { class: "mcp-view-interval-plot-row", "data-tone": interval.tone ?? "neutral", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-interval-plot-label", children: interval.label }), (0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-interval-plot-track", children: [(0, jsx_runtime_1.jsx)("span", { "aria-hidden": "true", class: "mcp-view-interval-plot-zero", style: { left: zeroOffset } }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-interval-plot-box", style: {
80
+ left: `${round(normalize(interval.lower, min, max) * 100)}%`,
81
+ width: `${round(((interval.upper - interval.lower) / (max - min)) * 100)}%`,
82
+ } })] }), (0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-interval-plot-bounds", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-interval-plot-lower", children: interval.lowerLabel }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-interval-plot-upper", children: interval.upperLabel })] })] }, interval.id)))] }));
83
+ }
84
+ function validateSamples(values, subject) {
85
+ if (values.length < 2)
86
+ throw new RangeError(`${subject} need at least two samples`);
87
+ for (const value of values) {
88
+ if (!Number.isFinite(value))
89
+ throw new TypeError(`${subject} must all be finite`);
90
+ }
91
+ }
92
+ function validateSeriesChart(series, xMin, xMax, yMin, yMax, cursor) {
93
+ for (const [name, candidate] of [["xMin", xMin], ["xMax", xMax], ["yMin", yMin], [
94
+ "yMax",
95
+ yMax,
96
+ ]]) {
97
+ if (!Number.isFinite(candidate))
98
+ throw new TypeError(`SeriesChart ${name} must be finite`);
99
+ }
100
+ if (xMax <= xMin)
101
+ throw new RangeError("SeriesChart xMax must be greater than xMin");
102
+ if (yMax <= yMin)
103
+ throw new RangeError("SeriesChart yMax must be greater than yMin");
104
+ if (series.length === 0)
105
+ throw new TypeError("SeriesChart series must not be empty");
106
+ const ids = new Set();
107
+ for (const one of series) {
108
+ if (ids.has(one.id))
109
+ throw new TypeError(`SeriesChart series id ${one.id} is duplicated`);
110
+ ids.add(one.id);
111
+ if (one.points.length < 2) {
112
+ throw new RangeError(`SeriesChart series ${one.id} needs at least two points`);
113
+ }
114
+ for (const point of one.points) {
115
+ if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {
116
+ throw new TypeError(`SeriesChart series ${one.id} points must be finite`);
117
+ }
118
+ }
119
+ }
120
+ if (cursor === undefined)
121
+ return;
122
+ if (!Number.isFinite(cursor.x))
123
+ throw new TypeError("SeriesChart cursor x must be finite");
124
+ if (cursor.x < xMin || cursor.x > xMax) {
125
+ throw new RangeError("SeriesChart cursor x must be within xMin and xMax");
126
+ }
127
+ for (const readout of cursor.readouts) {
128
+ if (!ids.has(readout.seriesId)) {
129
+ throw new TypeError(`SeriesChart cursor readout ${readout.seriesId} names no declared series`);
130
+ }
131
+ }
132
+ }
133
+ function validateIntervalPlot(min, max, intervals) {
134
+ for (const [name, candidate] of [["min", min], ["max", max]]) {
135
+ if (!Number.isFinite(candidate))
136
+ throw new TypeError(`IntervalPlot ${name} must be finite`);
137
+ }
138
+ if (max <= min)
139
+ throw new RangeError("IntervalPlot max must be greater than min");
140
+ if (min > 0 || max < 0)
141
+ throw new RangeError("IntervalPlot scale must contain zero");
142
+ if (intervals.length === 0)
143
+ throw new TypeError("IntervalPlot intervals must not be empty");
144
+ const ids = new Set();
145
+ for (const interval of intervals) {
146
+ if (ids.has(interval.id))
147
+ throw new TypeError(`IntervalPlot id ${interval.id} is duplicated`);
148
+ ids.add(interval.id);
149
+ if (!Number.isFinite(interval.lower) || !Number.isFinite(interval.upper)) {
150
+ throw new TypeError(`IntervalPlot interval ${interval.id} bounds must be finite`);
151
+ }
152
+ if (interval.upper < interval.lower) {
153
+ throw new RangeError(`IntervalPlot interval ${interval.id} upper must not be below lower`);
154
+ }
155
+ if (interval.lower < min || interval.upper > max) {
156
+ throw new RangeError(`IntervalPlot interval ${interval.id} must be within min and max`);
157
+ }
158
+ }
159
+ }
160
+ /** Position on a finite scale, clamped to a flat series' midpoint. */
161
+ function normalize(value, min, max) {
162
+ if (max === min)
163
+ return 0.5;
164
+ return (value - min) / (max - min);
165
+ }
166
+ function round(value) {
167
+ return Math.round(value * 100) / 100;
168
+ }
169
+ function classes(...values) {
170
+ return values.filter(Boolean).join(" ");
171
+ }
@@ -0,0 +1,103 @@
1
+ /** @jsxImportSource preact */
2
+ /** Generic, domain-neutral presentation shell for one semantic object. */
3
+ import type { ComposedSemanticRef } from "@mcpview/contracts";
4
+ import type { ComponentChildren, JSX, VNode } from "preact";
5
+ import { type CardProps, type PresentationTone } from "./components.js";
6
+ export type SemanticElementDensity = "chip" | "row" | "card";
7
+ export interface SemanticListProps {
8
+ readonly label: string;
9
+ readonly scrollable?: boolean;
10
+ readonly className?: string;
11
+ readonly children?: ComponentChildren;
12
+ }
13
+ /** Bounded group for row-density semantic objects; it owns no domain ordering. */
14
+ export declare function SemanticList({ label, scrollable, className, children, }: SemanticListProps): JSX.Element;
15
+ export interface CollectionCardProps extends Pick<CardProps, "title" | "eyebrow" | "actions" | "className" | "children">, Pick<SemanticListProps, "label" | "scrollable"> {
16
+ }
17
+ /** Card-hosted SemanticList that keeps a single outer border. */
18
+ export declare function CollectionCard({ label, title, eyebrow, actions, scrollable, className, children, }: CollectionCardProps): JSX.Element;
19
+ export interface ElementIdentProps {
20
+ readonly label: ComponentChildren;
21
+ readonly detail?: ComponentChildren;
22
+ readonly marker?: ComponentChildren;
23
+ readonly className?: string;
24
+ }
25
+ /** Required human-facing identity slot. Its content is already resolved by the caller. */
26
+ export declare function ElementIdent({ label, detail, marker, className, }: ElementIdentProps): JSX.Element;
27
+ export interface ElementReadingProps {
28
+ readonly value: ComponentChildren;
29
+ readonly label?: ComponentChildren;
30
+ readonly unit?: ComponentChildren;
31
+ readonly detail?: ComponentChildren;
32
+ readonly className?: string;
33
+ }
34
+ /** Resolved measurement or documentary reading; no unit is guessed. */
35
+ export declare function ElementReading({ value, label, unit, detail, className, }: ElementReadingProps): JSX.Element;
36
+ export interface ElementLimitProps {
37
+ readonly operator: ComponentChildren;
38
+ readonly value: ComponentChildren;
39
+ readonly label?: ComponentChildren;
40
+ readonly unit?: ComponentChildren;
41
+ readonly detail?: ComponentChildren;
42
+ readonly className?: string;
43
+ }
44
+ /** Caller-declared limit statement; never infers a range, measurement, or verdict. */
45
+ export declare function ElementLimit({ operator, value, label, unit, detail, className, }: ElementLimitProps): JSX.Element;
46
+ export interface ElementVerdictProps {
47
+ readonly value: ComponentChildren;
48
+ readonly label?: ComponentChildren;
49
+ readonly className?: string;
50
+ }
51
+ export interface ElementBodyProps {
52
+ readonly children?: ComponentChildren;
53
+ readonly className?: string;
54
+ }
55
+ /** Optional provider-owned visualization slot, such as a gauge or compact domain plot. */
56
+ export declare function ElementBody({ children, className }: ElementBodyProps): JSX.Element;
57
+ export interface ElementSectionProps {
58
+ /** Visible heading and accessible name of the group; the caller words it. */
59
+ readonly title: string;
60
+ readonly className?: string;
61
+ readonly children?: ComponentChildren;
62
+ }
63
+ /**
64
+ * One titled group inside an ElementBody. A datasheet body is sections, not one
65
+ * list: each fact belongs to exactly one, and the section names what its facts are.
66
+ */
67
+ export declare function ElementSection({ title, className, children, }: ElementSectionProps): JSX.Element;
68
+ /** Caller-authored verdict. Tone remains an explicit SemanticElement concern. */
69
+ export declare function ElementVerdict({ value, label, className, }: ElementVerdictProps): JSX.Element;
70
+ export interface ElementProvenanceProps {
71
+ readonly value: ComponentChildren;
72
+ readonly label?: ComponentChildren;
73
+ readonly className?: string;
74
+ }
75
+ /** Exact caller-provided provenance such as a source, revision, or fingerprint. */
76
+ export declare function ElementProvenance({ value, label, className, }: ElementProvenanceProps): JSX.Element;
77
+ export interface SemanticElementProps {
78
+ /** Structured identity only. This component never resolves or dereferences it. */
79
+ readonly reference: ComposedSemanticRef;
80
+ /** Presentation density. A whole viewer is deliberately not a density. */
81
+ readonly density: SemanticElementDensity;
82
+ /** Explicit visual verdict. Omit when the object has no warranted verdict. */
83
+ readonly tone?: PresentationTone;
84
+ /** Explicit current selection; presentation and accessible state stay kit-owned. */
85
+ readonly selected?: boolean;
86
+ /** Every semantic object must provide a resolved identity slot. */
87
+ readonly ident: VNode<ElementIdentProps>;
88
+ readonly reading?: VNode<ElementReadingProps | ElementLimitProps> | readonly VNode<ElementReadingProps | ElementLimitProps>[];
89
+ readonly body?: VNode<ElementBodyProps> | readonly VNode<ElementBodyProps>[];
90
+ readonly verdict?: VNode<ElementVerdictProps>;
91
+ readonly provenance?: VNode<ElementProvenanceProps>;
92
+ readonly activationLabel?: string;
93
+ readonly onActivate?: (reference: ComposedSemanticRef) => void;
94
+ readonly className?: string;
95
+ }
96
+ /**
97
+ * Render one semantic object without owning domain vocabulary or reference resolution.
98
+ *
99
+ * The same slots survive chip, row, and card composition. When a tone is explicitly
100
+ * supplied, an inline-start verdict border is invariant across all three densities.
101
+ */
102
+ export declare function SemanticElement({ reference, density, tone, selected, ident, reading, body, verdict, provenance, activationLabel, onActivate, className, }: SemanticElementProps): JSX.Element;
103
+ //# sourceMappingURL=semantic-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-element.d.ts","sourceRoot":"","sources":["../../../src/src/preact/semantic-element.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,0EAA0E;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC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QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACpD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,GACV,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CAoDpC"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SemanticList = SemanticList;
4
+ exports.CollectionCard = CollectionCard;
5
+ exports.ElementIdent = ElementIdent;
6
+ exports.ElementReading = ElementReading;
7
+ exports.ElementLimit = ElementLimit;
8
+ exports.ElementBody = ElementBody;
9
+ exports.ElementSection = ElementSection;
10
+ exports.ElementVerdict = ElementVerdict;
11
+ exports.ElementProvenance = ElementProvenance;
12
+ exports.SemanticElement = SemanticElement;
13
+ const jsx_runtime_1 = require("preact/jsx-runtime");
14
+ const components_js_1 = require("./components.js");
15
+ /** Bounded group for row-density semantic objects; it owns no domain ordering. */
16
+ function SemanticList({ label, scrollable = false, className, children, }) {
17
+ return ((0, jsx_runtime_1.jsx)("div", { "aria-label": label, class: classes("mcp-view-semantic-list", className), "data-scrollable": scrollable ? "true" : undefined, role: "group", children: children }));
18
+ }
19
+ /** Card-hosted SemanticList that keeps a single outer border. */
20
+ function CollectionCard({ label, title, eyebrow, actions, scrollable = false, className, children, }) {
21
+ return ((0, jsx_runtime_1.jsx)(components_js_1.Card, { title: title, eyebrow: eyebrow, actions: actions, className: classes("mcp-view-collection-card", className), children: (0, jsx_runtime_1.jsx)(SemanticList, { label: label, scrollable: scrollable, children: children }) }));
22
+ }
23
+ /** Required human-facing identity slot. Its content is already resolved by the caller. */
24
+ function ElementIdent({ label, detail, marker, className, }) {
25
+ return ((0, jsx_runtime_1.jsxs)("header", { class: classes("mcp-view-element-ident", className), "data-element-slot": "ident", children: [isPresent(marker) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-ident-marker", children: marker }), (0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-element-ident-copy", children: [(0, jsx_runtime_1.jsx)("strong", { class: "mcp-view-element-ident-label", children: label }), isPresent(detail) && (0, jsx_runtime_1.jsx)("small", { class: "mcp-view-element-ident-detail", children: detail })] })] }));
26
+ }
27
+ /** Resolved measurement or documentary reading; no unit is guessed. */
28
+ function ElementReading({ value, label, unit, detail, className, }) {
29
+ return ((0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-element-reading", className), "data-element-slot": "reading", children: [isPresent(label) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-reading-label", children: label }), (0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-element-reading-measure", children: [(0, jsx_runtime_1.jsx)("strong", { class: "mcp-view-element-reading-value", children: value }), isPresent(unit) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-reading-unit", children: unit })] }), isPresent(detail) && (0, jsx_runtime_1.jsx)("small", { class: "mcp-view-element-reading-detail", children: detail })] }));
30
+ }
31
+ /** Caller-declared limit statement; never infers a range, measurement, or verdict. */
32
+ function ElementLimit({ operator, value, label, unit, detail, className, }) {
33
+ return ((0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-element-limit", className), "data-element-slot": "reading", children: [isPresent(label) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-limit-label", children: label }), (0, jsx_runtime_1.jsxs)("span", { class: "mcp-view-element-limit-statement", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-limit-operator", children: operator }), (0, jsx_runtime_1.jsx)("strong", { class: "mcp-view-element-limit-value", children: value }), isPresent(unit) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-limit-unit", children: unit })] }), isPresent(detail) && (0, jsx_runtime_1.jsx)("small", { class: "mcp-view-element-limit-detail", children: detail })] }));
34
+ }
35
+ /** Optional provider-owned visualization slot, such as a gauge or compact domain plot. */
36
+ function ElementBody({ children, className }) {
37
+ return ((0, jsx_runtime_1.jsx)("div", { class: classes("mcp-view-element-body", className), "data-element-slot": "body", children: children }));
38
+ }
39
+ /**
40
+ * One titled group inside an ElementBody. A datasheet body is sections, not one
41
+ * list: each fact belongs to exactly one, and the section names what its facts are.
42
+ */
43
+ function ElementSection({ title, className, children, }) {
44
+ return ((0, jsx_runtime_1.jsxs)("div", { "aria-label": title, class: classes("mcp-view-element-section", className), "data-element-slot": "section", role: "group", children: [(0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-section-title", children: title }), children] }));
45
+ }
46
+ /** Caller-authored verdict. Tone remains an explicit SemanticElement concern. */
47
+ function ElementVerdict({ value, label, className, }) {
48
+ return ((0, jsx_runtime_1.jsxs)("div", { class: classes("mcp-view-element-verdict", className), "data-element-slot": "verdict", children: [isPresent(label) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-verdict-label", children: label }), (0, jsx_runtime_1.jsx)("strong", { class: "mcp-view-element-verdict-value", children: value })] }));
49
+ }
50
+ /** Exact caller-provided provenance such as a source, revision, or fingerprint. */
51
+ function ElementProvenance({ value, label, className, }) {
52
+ return ((0, jsx_runtime_1.jsxs)("footer", { class: classes("mcp-view-element-provenance", className), "data-element-slot": "provenance", children: [isPresent(label) && (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-provenance-label", children: label }), (0, jsx_runtime_1.jsx)("span", { class: "mcp-view-element-provenance-value", children: value })] }));
53
+ }
54
+ /**
55
+ * Render one semantic object without owning domain vocabulary or reference resolution.
56
+ *
57
+ * The same slots survive chip, row, and card composition. When a tone is explicitly
58
+ * supplied, an inline-start verdict border is invariant across all three densities.
59
+ */
60
+ function SemanticElement({ reference, density, tone, selected, ident, reading, body, verdict, provenance, activationLabel, onActivate, className, }) {
61
+ if (!ident)
62
+ throw new TypeError("SemanticElement requires an ElementIdent slot");
63
+ const interactive = onActivate !== undefined;
64
+ const activate = () => onActivate?.(reference);
65
+ return ((0, jsx_runtime_1.jsxs)("div", { "aria-current": !interactive && selected ? "true" : undefined, "aria-label": interactive ? activationLabel : undefined, "aria-pressed": interactive && selected !== undefined ? selected : undefined, class: classes("mcp-view-semantic-element", selected ? "mcp-view-selected" : undefined, className), "data-density": density, "data-interactive": interactive ? "true" : undefined, "data-selected": selected === undefined ? undefined : String(selected), "data-semantic-domain": reference.domain, "data-semantic-id": reference.id, "data-semantic-kind": reference.kind, "data-basis-fingerprint": reference.basisFingerprint, "data-tone": tone, role: interactive ? "button" : undefined, style: tone ? { borderInlineStart: verdictBorder(tone) } : undefined, tabIndex: interactive ? 0 : undefined, onClick: interactive
66
+ ? (event) => {
67
+ if (eventStartedInInteractiveChild(event.currentTarget, event.target))
68
+ return;
69
+ activate();
70
+ }
71
+ : undefined, onKeyDown: interactive
72
+ ? (event) => {
73
+ if (event.target !== event.currentTarget)
74
+ return;
75
+ if (event.key !== "Enter" && event.key !== " ")
76
+ return;
77
+ event.preventDefault();
78
+ activate();
79
+ }
80
+ : undefined, children: [ident, isPresent(reading) && ((0, jsx_runtime_1.jsx)("div", { class: "mcp-view-element-readings", "data-element-slot": "readings", children: reading })), body, verdict, provenance] }));
81
+ }
82
+ const INTERACTIVE_CHILD_SELECTOR = [
83
+ "a[href]",
84
+ "button",
85
+ "input",
86
+ "select",
87
+ "textarea",
88
+ "[role='button']",
89
+ "[role='link']",
90
+ ].join(",");
91
+ function eventStartedInInteractiveChild(element, target) {
92
+ const candidate = target;
93
+ if (!candidate || typeof candidate.closest !== "function")
94
+ return false;
95
+ const interactive = candidate.closest(INTERACTIVE_CHILD_SELECTOR);
96
+ return interactive !== null && interactive !== element && element.contains(interactive);
97
+ }
98
+ function verdictBorder(tone) {
99
+ const color = {
100
+ neutral: "var(--mcp-view-muted, currentColor)",
101
+ info: "var(--mcp-view-accent, currentColor)",
102
+ success: "var(--mcp-view-success, currentColor)",
103
+ warning: "var(--mcp-view-warning, currentColor)",
104
+ danger: "var(--mcp-view-danger, currentColor)",
105
+ }[tone];
106
+ return `var(--mcp-view-semantic-verdict-border-width, 3px) solid ${color}`;
107
+ }
108
+ function isPresent(value) {
109
+ if (value === undefined || value === null || value === false)
110
+ return false;
111
+ return !(Array.isArray(value) && value.length === 0);
112
+ }
113
+ function classes(...values) {
114
+ return values.filter(Boolean).join(" ");
115
+ }
@@ -0,0 +1,178 @@
1
+ /** @jsxImportSource preact */
2
+ /** Pure presentation structures shared by composable MCP Apps. */
3
+ import type { ComponentChildren, JSX } from "preact";
4
+ import type { PresentationTone } from "./components.js";
5
+ export interface PathBarItem {
6
+ readonly id: string;
7
+ readonly label: ComponentChildren;
8
+ /** Recorded state of that kept level, revealed only by the collapsed disclosure. */
9
+ readonly detail?: ComponentChildren;
10
+ }
11
+ /** Trailing items kept inline before the leading ones collapse. */
12
+ export declare const PATH_BAR_DEFAULT_MAX_VISIBLE = 3;
13
+ export interface PathBarProps {
14
+ /** Accessible name for the navigation landmark. */
15
+ readonly label: string;
16
+ /** Ordered path, including the current item. */
17
+ readonly items: readonly PathBarItem[];
18
+ /** Controlled identity of the current item. */
19
+ readonly currentId: string;
20
+ /** Local navigation callback. The component owns no routing state. */
21
+ readonly onSelect: (id: string) => void;
22
+ /** Inline capacity before the leading items collapse. Defaults to three. */
23
+ readonly maxVisible?: number;
24
+ /** Accessible name of the collapsed disclosure. Omit to never collapse. */
25
+ readonly collapsedLabel?: string;
26
+ /** Accessible name of the leading step-out control. Omit to render none. */
27
+ readonly backLabel?: string;
28
+ readonly className?: string;
29
+ }
30
+ /**
31
+ * Controlled breadcrumb-like navigation without host or MCP side effects.
32
+ *
33
+ * A one-item path renders nothing: the first level has nothing to leave.
34
+ */
35
+ export declare function PathBar({ label, items, currentId, onSelect, maxVisible, collapsedLabel, backLabel, className, }: PathBarProps): JSX.Element | null;
36
+ /** Where one available drill-down leads. */
37
+ export type DrillHintDirection = "in-view" | "to-model";
38
+ interface DrillHintBaseProps {
39
+ readonly label: ComponentChildren;
40
+ readonly direction: DrillHintDirection;
41
+ readonly className?: string;
42
+ }
43
+ interface StaticDrillHintProps extends DrillHintBaseProps {
44
+ readonly onActivate?: undefined;
45
+ readonly actionLabel?: never;
46
+ }
47
+ interface InteractiveDrillHintProps extends DrillHintBaseProps {
48
+ readonly onActivate: () => void;
49
+ /** Accessible action name, supplied together with the callback. */
50
+ readonly actionLabel: string;
51
+ }
52
+ export type DrillHintProps = StaticDrillHintProps | InteractiveDrillHintProps;
53
+ /**
54
+ * Affordance for one available drill-down.
55
+ *
56
+ * Without a callback the hint degrades to plain text and shows no glyph, so a
57
+ * host that cannot follow it never advertises a step that does not exist.
58
+ */
59
+ export declare function DrillHint(props: DrillHintProps): JSX.Element;
60
+ /** Shape of one recorded level, so a path never hides what it opens onto. */
61
+ export type ViewKind = "list" | "chart" | "record";
62
+ export interface TypeBadgeProps {
63
+ readonly kind: ViewKind;
64
+ /** Caller-provided wording. The kit never translates or invents a label. */
65
+ readonly label: ComponentChildren;
66
+ readonly className?: string;
67
+ }
68
+ /** Names what one level is, next to the path that reached it. */
69
+ export declare function TypeBadge({ kind, label, className }: TypeBadgeProps): JSX.Element;
70
+ export interface StaleBannerAction {
71
+ readonly label: string;
72
+ readonly onActivate: () => void;
73
+ }
74
+ export interface StaleBannerProps {
75
+ /** Caller-formatted sentence, including the instant those values were recorded. */
76
+ readonly message: ComponentChildren;
77
+ readonly tone?: PresentationTone;
78
+ readonly action?: StaleBannerAction;
79
+ readonly className?: string;
80
+ }
81
+ /**
82
+ * Marks the surrounding values as recorded earlier without hiding them.
83
+ *
84
+ * The banner refetches nothing and never replaces a dated value with a gap.
85
+ */
86
+ export declare function StaleBanner({ message, tone, action, className, }: StaleBannerProps): JSX.Element;
87
+ export interface Slot3DProps {
88
+ /** Accessible name of the reserved area. */
89
+ readonly label: string;
90
+ /** Caller-provided wording for the reserved state. */
91
+ readonly statusLabel: ComponentChildren;
92
+ /** A provider-owned renderer. Without one the slot stays visibly reserved. */
93
+ readonly children?: ComponentChildren;
94
+ readonly className?: string;
95
+ }
96
+ /** Reserved area for a provider-owned 3D pose. The kit renders no geometry. */
97
+ export declare function Slot3D({ label, statusLabel, children, className }: Slot3DProps): JSX.Element;
98
+ export interface TreeListNode {
99
+ readonly id: string;
100
+ readonly label: ComponentChildren;
101
+ /** Caller-provided type wording, such as a package, part, or attribute. */
102
+ readonly typeLabel?: ComponentChildren;
103
+ readonly detail?: ComponentChildren;
104
+ /** Caller-computed coverage wording. The kit counts nothing. */
105
+ readonly coverageLabel?: ComponentChildren;
106
+ readonly tone?: PresentationTone;
107
+ readonly children?: readonly TreeListNode[];
108
+ }
109
+ export interface TreeListProps {
110
+ /** Accessible name for the tree. */
111
+ readonly label: string;
112
+ readonly nodes: readonly TreeListNode[];
113
+ /** Controlled expansion. The component keeps no local disclosure state. */
114
+ readonly expandedIds: readonly string[];
115
+ readonly onToggle: (id: string) => void;
116
+ /** Accessible name shared by every disclosure control. */
117
+ readonly toggleLabel: string;
118
+ readonly selectedId?: string;
119
+ /** Omit to render a read-only tree with no selection affordance. */
120
+ readonly onSelect?: (id: string) => void;
121
+ readonly className?: string;
122
+ }
123
+ /** Controlled hierarchy with caller-owned type wording and coverage. */
124
+ export declare function TreeList({ label, nodes, expandedIds, onToggle, toggleLabel, selectedId, onSelect, className, }: TreeListProps): JSX.Element;
125
+ export interface LimitGaugeLimit {
126
+ /** Position of the caller-provided limit on the same finite scale. */
127
+ readonly value: number;
128
+ /** Visible description of that recorded limit. */
129
+ readonly label: string;
130
+ }
131
+ export interface LimitGaugeProps {
132
+ readonly label: string;
133
+ readonly min: number;
134
+ readonly max: number;
135
+ readonly value: number;
136
+ /** Caller-formatted reading, including its unit when applicable. */
137
+ readonly valueLabel: string;
138
+ /** Caller-provided state text; the gauge never derives a verdict. */
139
+ readonly statusLabel: string;
140
+ readonly tone: PresentationTone;
141
+ readonly limit?: LimitGaugeLimit;
142
+ readonly className?: string;
143
+ }
144
+ /** Finite meter with an optional caller-supplied limit marker and explicit status text. */
145
+ export declare function LimitGauge({ label, min, max, value, valueLabel, statusLabel, tone, limit, className, }: LimitGaugeProps): JSX.Element;
146
+ export interface ArtifactFingerprint {
147
+ readonly algorithm: string;
148
+ readonly digest: string;
149
+ }
150
+ export interface ArtifactVerification {
151
+ /** Literal verification state supplied by the caller. */
152
+ readonly label: ComponentChildren;
153
+ readonly tone: PresentationTone;
154
+ }
155
+ interface ArtifactRowBaseProps {
156
+ readonly label: ComponentChildren;
157
+ readonly kind?: ComponentChildren;
158
+ readonly uri: string;
159
+ readonly fingerprint?: ArtifactFingerprint;
160
+ /** Caller-formatted byte size or other bounded size description. */
161
+ readonly sizeLabel?: ComponentChildren;
162
+ readonly verification?: ArtifactVerification;
163
+ readonly className?: string;
164
+ }
165
+ interface StaticArtifactRowProps extends ArtifactRowBaseProps {
166
+ readonly onActivate?: undefined;
167
+ readonly actionLabel?: never;
168
+ }
169
+ interface InteractiveArtifactRowProps extends ArtifactRowBaseProps {
170
+ readonly onActivate: () => void;
171
+ /** Accessible action name, supplied together with the callback. */
172
+ readonly actionLabel: string;
173
+ }
174
+ export type ArtifactRowProps = StaticArtifactRowProps | InteractiveArtifactRowProps;
175
+ /** Immutable-artifact presentation; verification is displayed, never inferred or performed. */
176
+ export declare function ArtifactRow(props: ArtifactRowProps): JSX.Element;
177
+ export {};
178
+ //# sourceMappingURL=structural.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structural.d.ts","sourceRoot":"","sources":["../../../src/src/preact/structural.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,kEAAkE;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC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