@momoi-labs/kiso-react 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/app-shell.js +3 -2
- package/dist/chart-legend.js +1 -1
- package/dist/chart-style.d.ts +19 -0
- package/dist/chart-style.js +68 -0
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +21 -9
- package/dist/chip-input.js +3 -8
- package/dist/command-palette.js +2 -1
- package/dist/detail-select.d.ts +24 -0
- package/dist/detail-select.js +56 -0
- package/dist/diagram.d.ts +104 -0
- package/dist/diagram.js +208 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/pane-grid.d.ts +28 -0
- package/dist/pane-grid.js +488 -0
- package/dist/password-input.d.ts +15 -0
- package/dist/password-input.js +31 -0
- package/dist/search.js +2 -1
- package/dist/select.js +2 -1
- package/dist/sparkline.d.ts +3 -1
- package/dist/sparkline.js +16 -2
- package/dist/steps.js +2 -1
- package/dist/styles.css +51 -0
- package/dist/theme-selector.js +5 -4
- package/dist/time-range-control.js +2 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -83,6 +83,9 @@ Data and structure
|
|
|
83
83
|
arrangement. Pass `layout="topbar"` for a single-surface frame with brand and
|
|
84
84
|
primary action in the top bar and no sidebar rail.
|
|
85
85
|
- Split, Pane, and Splitter, a list-detail layout with a resizable divider.
|
|
86
|
+
- PaneGrid and GridPane, summary panes on twelve columns that the reader
|
|
87
|
+
resizes at the end edge and moves by the title. `onLayoutChange` reports
|
|
88
|
+
the rows and sizes for the product to persist.
|
|
86
89
|
- LogView, LogViewLine, LogViewTime, and LogViewLevel.
|
|
87
90
|
- StepList, a run's steps with a state each, and StepBar, the same run as
|
|
88
91
|
one segment per step for a summary, a table cell, or a toast.
|
package/dist/app-shell.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { clsx as cn } from "clsx";
|
|
6
|
+
import { PanelLeftClose, PanelLeftOpen, PanelRight } from "lucide-react";
|
|
6
7
|
import { Button } from "./button.js";
|
|
7
8
|
import { Header } from "./header.js";
|
|
8
9
|
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
@@ -20,7 +21,7 @@ function AppShellPanel({ className, ...props }) {
|
|
|
20
21
|
return _jsx("aside", { "data-slot": "app-shell-panel", className: cn("app-shell-panel", className), ...props });
|
|
21
22
|
}
|
|
22
23
|
function AppShellPanelToggle({ className, placement = "header", children, "aria-label": label, ...props }) {
|
|
23
|
-
return _jsx(Button, { variant: "ghost", size: "sm", "data-slot": "app-shell-panel-toggle", "data-placement": placement, className: cn("app-shell-panel-toggle", className), "aria-label": label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), title: label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), ...props, children: children ??
|
|
24
|
+
return _jsx(Button, { variant: "ghost", size: "sm", "data-slot": "app-shell-panel-toggle", "data-placement": placement, className: cn("app-shell-panel-toggle", className), "aria-label": label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), title: label ?? (props["aria-expanded"] ? "Close panel" : "Open panel"), ...props, children: children ?? _jsx(PanelRight, { className: "icon", "aria-hidden": "true" }) });
|
|
24
25
|
}
|
|
25
26
|
function ApplicationShellNavigation({ navigation, navigationLabel, collapsible = false, }) {
|
|
26
27
|
return (_jsx(Navigation, { "aria-label": navigationLabel, children: navigation.map((group, groupIndex) => (_jsx(NavigationGroup, { label: group.label, children: group.destinations.length > 0 ? (_jsx(NavigationList, { children: group.destinations.map((destination, destinationIndex) => (_jsx(NavigationItem, { children: _jsx(NavigationLink, { href: destination.href, active: destination.active, className: collapsible && destination.leading ? "sidebar-link-with-icon" : undefined, title: collapsible && typeof destination.label === "string" ? destination.label : undefined, onClick: (event) => {
|
|
@@ -56,7 +57,7 @@ function ApplicationShellSidebar({ brand, primaryAction, navigation, navigationL
|
|
|
56
57
|
setInternalCollapsed(next);
|
|
57
58
|
onCollapsedChange?.(next);
|
|
58
59
|
}
|
|
59
|
-
const toggle = collapsible ? (_jsx(Button, { ref: toggleRef, variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": !isCollapsed, "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", title: isCollapsed ? "Expand sidebar" : "Collapse sidebar", onClick: toggleSidebar, children:
|
|
60
|
+
const toggle = collapsible ? (_jsx(Button, { ref: toggleRef, variant: "ghost", size: "sm", className: "sidebar-toggle btn-icon", "aria-controls": sidebarId, "aria-expanded": !isCollapsed, "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", title: isCollapsed ? "Expand sidebar" : "Collapse sidebar", onClick: toggleSidebar, children: isCollapsed ? _jsx(PanelLeftOpen, { className: "icon", "aria-hidden": "true" }) : _jsx(PanelLeftClose, { className: "icon", "aria-hidden": "true" }) })) : null;
|
|
60
61
|
return (_jsxs(AppShell, { ...shellProps, children: [_jsxs(Sidebar, { ref: sidebarRef, id: sidebarId, collapsed: isCollapsed, children: [_jsx(SidebarHeader, { className: collapsible && togglePlacement === "sidebar" ? "sidebar-header-collapsible" : undefined, children: collapsible ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "sidebar-expanded-content", children: [brand, primaryAction] }), togglePlacement === "sidebar" && toggle] }) : _jsxs(_Fragment, { children: [brand, primaryAction] }) }), _jsx(SidebarBody, { children: _jsx(ApplicationShellNavigation, { navigation: navigation, navigationLabel: navigationLabel, collapsible: collapsible }) }), footer && _jsx(SidebarFooter, { className: collapsible ? "sidebar-expanded-content" : undefined, children: footer })] }), _jsxs(AppShellMain, { children: [(header || (collapsible && togglePlacement === "header")) && _jsxs(Header, { variant: headerVariant, children: [togglePlacement === "header" && toggle, header] }), children] }), panel] }));
|
|
61
62
|
}
|
|
62
63
|
export { AppShell, AppShellMain, AppShellPanel, AppShellPanelToggle, ApplicationShell };
|
package/dist/chart-legend.js
CHANGED
|
@@ -4,7 +4,7 @@ import { clsx as cn } from "clsx";
|
|
|
4
4
|
import { chartColor, chartSlot, formatChartTime, formatChartValue, measured, seriesSummary, validateChart } from "./chart-data.js";
|
|
5
5
|
export function ChartSeriesLabel({ series, index }) {
|
|
6
6
|
const slot = chartSlot(series, index);
|
|
7
|
-
return _jsxs("span", { className: "chart-series-label", children: [_jsx("svg", { "aria-hidden": "true", width: "28", height: "12", viewBox: "0 0 28 12", children: _jsx("path", { d: "M0 6H28", stroke: chartColor(slot), strokeWidth: "2" }) }), _jsxs("span", { children: [slot, ". ", series.label] })] });
|
|
7
|
+
return _jsxs("span", { className: "chart-series-label", children: [_jsx("svg", { className: "chart-series-swatch", "aria-hidden": "true", width: "28", height: "12", viewBox: "0 0 28 12", children: _jsx("path", { d: "M0 6H28", stroke: chartColor(slot), strokeWidth: "2" }) }), _jsxs("span", { children: [slot, ". ", series.label] })] });
|
|
8
8
|
}
|
|
9
9
|
export function ChartLegend({ data, series, label, formatValue = formatChartValue, variant = "table", activeTimestamp, formatTime = formatChartTime, highlightSeries, onHighlightSeriesChange, className, ...props }) {
|
|
10
10
|
validateChart(data, series);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Line } from "recharts";
|
|
3
|
+
export type ChartStyle = "solid" | "pixel" | "halftone" | "rounded";
|
|
4
|
+
export declare function useChartStyle(ref: React.RefObject<HTMLElement | null>, override?: ChartStyle, mounted?: boolean): ChartStyle;
|
|
5
|
+
type CurveFactory = Exclude<NonNullable<React.ComponentProps<typeof Line>["type"]>, string>;
|
|
6
|
+
export declare const pixelCurve: CurveFactory;
|
|
7
|
+
export declare function ChartPattern({ id, color }: {
|
|
8
|
+
id: string;
|
|
9
|
+
color: string;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
export declare function ChartDot({ cx, cy, r, fill, opacity, chartStyle }: {
|
|
12
|
+
cx?: number;
|
|
13
|
+
cy?: number;
|
|
14
|
+
r?: number;
|
|
15
|
+
fill?: string;
|
|
16
|
+
opacity?: number;
|
|
17
|
+
chartStyle: ChartStyle;
|
|
18
|
+
}): React.JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
const chartStyles = ["solid", "pixel", "halftone", "rounded"];
|
|
5
|
+
// Geometry must update with a scoped appearance attribute, not just CSS paint.
|
|
6
|
+
export function useChartStyle(ref, override, mounted = true) {
|
|
7
|
+
const [inherited, setInherited] = React.useState("solid");
|
|
8
|
+
React.useLayoutEffect(() => {
|
|
9
|
+
if (override)
|
|
10
|
+
return;
|
|
11
|
+
const element = ref.current;
|
|
12
|
+
if (!element)
|
|
13
|
+
return;
|
|
14
|
+
const read = () => {
|
|
15
|
+
const style = getComputedStyle(element).getPropertyValue("--chart-style").trim();
|
|
16
|
+
setInherited(chartStyles.includes(style) ? style : "solid");
|
|
17
|
+
};
|
|
18
|
+
read();
|
|
19
|
+
const observer = new MutationObserver(read);
|
|
20
|
+
observer.observe(element.ownerDocument.documentElement, { attributes: true, subtree: true, attributeFilter: ["data-chart-style"] });
|
|
21
|
+
return () => observer.disconnect();
|
|
22
|
+
}, [ref, override, mounted]);
|
|
23
|
+
return override ?? inherited;
|
|
24
|
+
}
|
|
25
|
+
export const pixelCurve = context => {
|
|
26
|
+
let areaLine = NaN, count = 0, previousX = 0, previousY = 0;
|
|
27
|
+
return {
|
|
28
|
+
areaStart() { areaLine = 0; },
|
|
29
|
+
areaEnd() { areaLine = NaN; },
|
|
30
|
+
lineStart() { count = 0; },
|
|
31
|
+
lineEnd() {
|
|
32
|
+
if (areaLine || (areaLine !== 0 && count === 1))
|
|
33
|
+
context.closePath();
|
|
34
|
+
areaLine = 1 - areaLine;
|
|
35
|
+
},
|
|
36
|
+
point(x, y) {
|
|
37
|
+
if (count === 0) {
|
|
38
|
+
count = 1;
|
|
39
|
+
if (areaLine)
|
|
40
|
+
context.lineTo(x, y);
|
|
41
|
+
else
|
|
42
|
+
context.moveTo(x, y);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
count = 2;
|
|
46
|
+
const steps = Math.max(1, Math.ceil(Math.max(Math.abs(x - previousX), Math.abs(y - previousY)) / 4));
|
|
47
|
+
for (let step = 1; step <= steps; step++) {
|
|
48
|
+
const nextX = previousX + (x - previousX) * step / steps;
|
|
49
|
+
const nextY = previousY + (y - previousY) * step / steps;
|
|
50
|
+
context.lineTo(nextX, previousY + (y - previousY) * (step - 1) / steps);
|
|
51
|
+
context.lineTo(nextX, nextY);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
previousX = x;
|
|
55
|
+
previousY = y;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export function ChartPattern({ id, color }) {
|
|
60
|
+
return _jsx("pattern", { id: id, width: 4, height: 4, patternUnits: "userSpaceOnUse", children: _jsx("circle", { cx: 1, cy: 1, r: 0.8, fill: color }) });
|
|
61
|
+
}
|
|
62
|
+
export function ChartDot({ cx, cy, r = 4, fill, opacity, chartStyle }) {
|
|
63
|
+
if (cx === undefined || cy === undefined)
|
|
64
|
+
return null;
|
|
65
|
+
return chartStyle === "pixel"
|
|
66
|
+
? _jsx("rect", { x: cx - r, y: cy - r, width: 2 * r, height: 2 * r, fill: fill, opacity: opacity })
|
|
67
|
+
: _jsx("circle", { cx: cx, cy: cy, r: r, fill: fill, opacity: opacity });
|
|
68
|
+
}
|
package/dist/chart.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { type ChartStyle } from "./chart-style.js";
|
|
2
3
|
import { type ChartSample, type ChartSeries } from "./chart-data.js";
|
|
3
4
|
export type { ChartSample, ChartSeries } from "./chart-data.js";
|
|
4
5
|
export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
@@ -18,5 +19,6 @@ export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
|
18
19
|
formatValue?: (value: number) => string;
|
|
19
20
|
min?: number;
|
|
20
21
|
max?: number;
|
|
22
|
+
chartStyle?: ChartStyle;
|
|
21
23
|
};
|
|
22
|
-
export declare function Chart({ data, series, label, variant, layout, legend, highlightSeries, onHighlightSeriesChange, height, syncId, formatTime, formatValue, min, max, className, ...props }: ChartProps): React.JSX.Element;
|
|
24
|
+
export declare function Chart({ data, series, label, variant, layout, legend, highlightSeries, onHighlightSeriesChange, height, syncId, formatTime, formatValue, min, max, chartStyle, ref, className, ...props }: ChartProps): React.JSX.Element;
|
package/dist/chart.js
CHANGED
|
@@ -4,9 +4,12 @@ import * as React from "react";
|
|
|
4
4
|
import { clsx as cn } from "clsx";
|
|
5
5
|
import { Area, CartesianGrid, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
6
6
|
import { ChartLegend, ChartSeriesLabel } from "./chart-legend.js";
|
|
7
|
+
import { ChartDot, ChartPattern, pixelCurve, useChartStyle } from "./chart-style.js";
|
|
7
8
|
import { chartColor, chartSlot, formatChartTime, formatChartValue, measured, validateChart } from "./chart-data.js";
|
|
8
|
-
export function Chart({ data, series, label, variant = "line", layout = "standard", legend = "table", highlightSeries, onHighlightSeriesChange, height = layout === "compact" ? 165 : layout === "split" ? 90 : 200, syncId, formatTime = formatChartTime, formatValue = formatChartValue, min, max, className, ...props }) {
|
|
9
|
+
export function Chart({ data, series, label, variant = "line", layout = "standard", legend = "table", highlightSeries, onHighlightSeriesChange, height = layout === "compact" ? 165 : layout === "split" ? 90 : 200, syncId, formatTime = formatChartTime, formatValue = formatChartValue, min, max, chartStyle, ref, className, ...props }) {
|
|
9
10
|
const id = React.useId();
|
|
11
|
+
const frame = React.useRef(null);
|
|
12
|
+
const treatment = useChartStyle(frame, chartStyle);
|
|
10
13
|
const [localHighlight, setLocalHighlight] = React.useState(null);
|
|
11
14
|
const [activeTimestamp, setActiveTimestamp] = React.useState(null);
|
|
12
15
|
const requestedHighlight = highlightSeries === undefined ? localHighlight : highlightSeries;
|
|
@@ -44,26 +47,35 @@ export function Chart({ data, series, label, variant = "line", layout = "standar
|
|
|
44
47
|
else
|
|
45
48
|
splitMin -= Math.max(1, Math.abs(splitMin) * 0.1);
|
|
46
49
|
}
|
|
47
|
-
const renderPlot = (indices, lane) => _jsx("div", { className: "chart-plot", style: { height }, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: plot, syncId: syncId ?? (layout === "split" ? id : undefined), syncMethod: "value", accessibilityLayer: true, "aria-label": lane ? `${label}: ${lane.label}` : label, "aria-describedby": `${id}-help`, margin: { top: 8, right: 12, bottom: 0, left: 0 }, children: [_jsx(CartesianGrid, { vertical: false, stroke: "var(--color-border)", strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["dataMin", "dataMax"], scale: "time", axisLine: false, tickLine: false, tickFormatter: formatTime, minTickGap: 48, tick: { fill: "var(--color-muted-foreground)" } }), _jsx(YAxis, { domain: layout === "split" ? [splitMin, splitMax]
|
|
50
|
+
const renderPlot = (indices, lane) => _jsx("div", { className: "chart-plot", style: { height }, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: plot, syncId: syncId ?? (layout === "split" ? id : undefined), syncMethod: "value", accessibilityLayer: true, "aria-label": lane ? `${label}: ${lane.label}` : label, "aria-describedby": `${id}-help`, margin: { top: 8, right: 12, bottom: 0, left: 0 }, children: [_jsx("defs", { children: indices.map(index => _jsx(ChartPattern, { id: `${id}-halftone-${index}`, color: chartColor(chartSlot(series[index], index)) }, series[index].key)) }), _jsx(CartesianGrid, { vertical: false, stroke: "var(--color-border)", strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["dataMin", "dataMax"], scale: "time", axisLine: false, tickLine: false, tickFormatter: formatTime, minTickGap: 48, tick: { fill: "var(--color-muted-foreground)" } }), _jsx(YAxis, { domain: layout === "split" ? [splitMin, splitMax]
|
|
48
51
|
: [min ?? (variant === "stacked-area" ? 0 : "auto"), max ?? "auto"], tickCount: 3, axisLine: false, tickLine: false, tickFormatter: formatValue, tick: { fill: "var(--color-muted-foreground)" }, width: 56 }), _jsx(Tooltip, { filterNull: false, isAnimationActive: false, cursor: { stroke: "var(--color-border-strong)", strokeDasharray: "3 3" }, content: ({ active, label: timestamp }) => _jsx(ChartReadout, { active: active, timestamp: Number(timestamp), data: data, series: series, formatTime: formatTime, displayValue: displayValue, sidebar: legend === "sidebar", onInspect: legend === "sidebar" && (!lane || indices[0] === 0) ? setActiveTimestamp : undefined }) }), indices.map(index => {
|
|
49
52
|
const item = series[index];
|
|
50
53
|
const slot = chartSlot(item, index);
|
|
51
54
|
const dimmed = highlighted !== null && item.key !== highlighted;
|
|
52
55
|
const common = { dataKey: `values.${index}`, name: item.label, stroke: chartColor(slot),
|
|
53
|
-
strokeWidth: item.key === highlighted ? 2.
|
|
56
|
+
strokeWidth: item.key === highlighted ? (treatment === "pixel" || treatment === "rounded" ? 2.7 : 2.2) : treatment === "pixel" || treatment === "rounded" ? 2 : 1.5,
|
|
57
|
+
strokeOpacity: dimmed ? 0.3 : 1, strokeLinecap: treatment === "rounded" ? "round" : "butt",
|
|
58
|
+
strokeLinejoin: treatment === "rounded" ? "round" : "miter",
|
|
54
59
|
connectNulls: false, isAnimationActive: false,
|
|
55
60
|
dot: (dotProps) => {
|
|
56
61
|
const at = dotProps.index ?? -1;
|
|
57
62
|
const isolated = measured(plot[at]?.values[index])
|
|
58
63
|
&& !measured(plot[at - 1]?.values[index]) && !measured(plot[at + 1]?.values[index]);
|
|
59
|
-
return _jsx(
|
|
60
|
-
}, activeDot: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
return _jsx(ChartDot, { cx: dotProps.cx, cy: dotProps.cy, r: isolated ? 3 : 0, chartStyle: treatment, fill: chartColor(slot), opacity: dimmed ? 0.3 : 1 }, at);
|
|
65
|
+
}, activeDot: (dotProps) => _jsx(ChartDot, { ...dotProps, chartStyle: treatment, fill: chartColor(slot), opacity: dimmed ? 0.3 : 1 }) };
|
|
66
|
+
const curve = treatment === "pixel" ? pixelCurve : treatment === "rounded" && variant === "line" ? "monotone" : "linear";
|
|
67
|
+
return variant === "stacked-area" || treatment === "halftone"
|
|
68
|
+
? _jsx(Area, { ...common, type: curve, stackId: variant === "stacked-area" ? "total" : undefined, fill: treatment === "halftone" ? `url(#${id}-halftone-${index})` : chartColor(slot), fillOpacity: dimmed ? 0.06 : 0.2 }, item.key)
|
|
69
|
+
: _jsx(Line, { ...common, type: curve }, item.key);
|
|
64
70
|
})] }) }) });
|
|
65
71
|
const legendContent = _jsx(ChartLegend, { data: data, series: series, label: `${label}: summary`, variant: legend, formatValue: formatValue, formatTime: formatTime, activeTimestamp: legend === "sidebar" && hasData ? activeTimestamp : null, highlightSeries: highlighted, onHighlightSeriesChange: highlight });
|
|
66
|
-
return _jsxs("figure", { ...props,
|
|
72
|
+
return _jsxs("figure", { ...props, ref: element => {
|
|
73
|
+
frame.current = element;
|
|
74
|
+
if (typeof ref === "function")
|
|
75
|
+
return ref(element);
|
|
76
|
+
if (ref)
|
|
77
|
+
ref.current = element;
|
|
78
|
+
}, "data-slot": "chart", "data-layout": layout, "data-legend": legend, "data-chart-treatment": treatment, className: cn("framed-chart", className), "aria-labelledby": `${id}-title`, children: [_jsx("figcaption", { id: `${id}-title`, className: "t-h3", children: label }), _jsx("p", { id: `${id}-help`, className: "chart-help", children: "Focus the chart and use Left and Right to inspect samples. Select a series in the legend to highlight it. Exact values are available below." }), _jsxs("div", { className: "chart-body", children: [_jsx("div", { className: "chart-plots", children: hasData ? layout === "split" ? series.map((item, index) => _jsxs("div", { className: "chart-lane", children: [_jsxs("div", { className: "chart-lane-heading", children: [_jsx(ChartSeriesLabel, { series: item, index: index }), _jsx("span", { children: displayValue(data.at(-1)?.values[item.key]) })] }), renderPlot([index], item)] }, item.key)) : renderPlot(series.map((_, index) => index))
|
|
67
79
|
: _jsx("div", { className: "chart-empty hatch", style: { minHeight: height }, children: "No collected samples in this window." }) }), legend === "sidebar" && legendContent] }), legend !== "sidebar" && legendContent, _jsxs("details", { className: "disclosure chart-values", children: [_jsx("summary", { children: "View exact values" }), _jsx("div", { className: "chart-table-scroll", children: _jsxs("table", { className: "chart-table", children: [_jsxs("caption", { children: [label, ": collected samples, timestamps in UTC"] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Timestamp" }), series.map(item => _jsx("th", { scope: "col", children: item.label }, item.key))] }) }), _jsx("tbody", { children: data.map(sample => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: formatChartTime(sample.timestamp) }), series.map(item => _jsx("td", { children: measured(sample.values[item.key]) ? String(sample.values[item.key]) : "Not collected" }, item.key))] }, sample.timestamp)) })] }) })] })] });
|
|
68
80
|
}
|
|
69
81
|
// Observe Recharts' synchronized tooltip state after render. This keeps the
|
package/dist/chip-input.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { clsx as cn } from "clsx";
|
|
5
|
+
import { Check, X } from "lucide-react";
|
|
5
6
|
// One field holding several structured values. The component owns the box, the
|
|
6
7
|
// chips, and the combobox keys; the product owns what a chip means, which
|
|
7
8
|
// suggestions match, and which options a chip accepts.
|
|
@@ -188,7 +189,7 @@ function EditableSegment({ slot, className, value, placeholder, display, onCommi
|
|
|
188
189
|
event.preventDefault();
|
|
189
190
|
restoreSegmentFocus(editorRef.current);
|
|
190
191
|
commit(draft);
|
|
191
|
-
}, children: _jsx(
|
|
192
|
+
}, children: _jsx(Check, { className: "icon", "aria-hidden": "true" }) })] }));
|
|
192
193
|
}
|
|
193
194
|
return (_jsx("button", { type: "button", "data-slot": slot, "data-empty": value ? undefined : "true", className: cn(className), "aria-label": editLabel, onClick: () => setDraft(value), ...props, children: value ? (display ?? value) : placeholder }));
|
|
194
195
|
}
|
|
@@ -224,12 +225,6 @@ function ChipRemove({ className, onClick, ...props }) {
|
|
|
224
225
|
root?.querySelector('[data-slot="chip-input-field"]')?.focus();
|
|
225
226
|
}
|
|
226
227
|
});
|
|
227
|
-
}, children: _jsx(
|
|
228
|
-
}
|
|
229
|
-
function CheckIcon() {
|
|
230
|
-
return (_jsx("svg", { className: "icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "m3.5 8.5 3 3 6-7" }) }));
|
|
231
|
-
}
|
|
232
|
-
function CloseIcon() {
|
|
233
|
-
return (_jsx("svg", { className: "icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: _jsx("path", { d: "m4 4 8 8M12 4l-8 8" }) }));
|
|
228
|
+
}, children: _jsx(X, { className: "icon", "aria-hidden": "true" }) }));
|
|
234
229
|
}
|
|
235
230
|
export { Chip, ChipInput, ChipInputBox, ChipInputEmpty, ChipInputField, ChipInputList, ChipInputOption, ChipName, ChipOption, ChipOptionAdd, ChipRemove, ChipScope, ChipValue, };
|
package/dist/command-palette.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { clsx as cn } from "clsx";
|
|
5
|
+
import { Search } from "lucide-react";
|
|
5
6
|
import { Dialog as DialogPrimitive, VisuallyHidden } from "radix-ui";
|
|
6
7
|
import { DialogOverlay, DialogPortal } from "./dialog.js";
|
|
7
8
|
// The palette owns its overlay, focus, and in-palette keys. Matching is the
|
|
@@ -60,7 +61,7 @@ function CommandPaletteInput({ className, onKeyDown, onCompositionStart, onCompo
|
|
|
60
61
|
}
|
|
61
62
|
onKeyDown?.(event);
|
|
62
63
|
}
|
|
63
|
-
return (_jsxs("div", { className: "palette-input", "data-slot": "command-palette-input", children: [
|
|
64
|
+
return (_jsxs("div", { className: "palette-input", "data-slot": "command-palette-input", children: [_jsx(Search, { className: "icon muted", "aria-hidden": "true" }), _jsx("input", { role: "combobox", "aria-expanded": "true", "aria-controls": listId, "aria-activedescendant": activeId || undefined, "aria-autocomplete": "list", autoComplete: "off", autoFocus: true, onKeyDown: move, onCompositionStart: (event) => {
|
|
64
65
|
composing.current = true;
|
|
65
66
|
onCompositionStart?.(event);
|
|
66
67
|
}, onCompositionEnd: (event) => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type DetailSelectOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
illustration: React.ReactNode;
|
|
7
|
+
description: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type DetailSelectProps = {
|
|
11
|
+
label: string;
|
|
12
|
+
options: readonly DetailSelectOption[];
|
|
13
|
+
value?: string;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
controlSize?: "sm" | "md" | "lg" | "xl";
|
|
19
|
+
id?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
"aria-describedby"?: string;
|
|
22
|
+
"aria-invalid"?: React.AriaAttributes["aria-invalid"];
|
|
23
|
+
};
|
|
24
|
+
export declare function DetailSelect({ label, options, value, defaultValue, onValueChange, placeholder, disabled, controlSize, id, className, "aria-describedby": describedBy, "aria-invalid": invalid }: DetailSelectProps): React.JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { clsx as cn } from "clsx";
|
|
5
|
+
import { Check } from "lucide-react";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
7
|
+
export function DetailSelect({ label, options, value, defaultValue, onValueChange, placeholder = "Choose an option", disabled, controlSize, id, className, "aria-describedby": describedBy, "aria-invalid": invalid }) {
|
|
8
|
+
const generatedId = React.useId();
|
|
9
|
+
const triggerId = id ?? generatedId;
|
|
10
|
+
const [localValue, setLocalValue] = React.useState(defaultValue);
|
|
11
|
+
const [open, setOpen] = React.useState(false);
|
|
12
|
+
const selected = value === undefined ? localValue : value;
|
|
13
|
+
const current = options.find(option => option.value === selected);
|
|
14
|
+
const buttons = React.useRef([]);
|
|
15
|
+
const choose = (option, close = true) => {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
setLocalValue(option.value);
|
|
18
|
+
if (option.value !== selected)
|
|
19
|
+
onValueChange?.(option.value);
|
|
20
|
+
if (close)
|
|
21
|
+
setOpen(false);
|
|
22
|
+
};
|
|
23
|
+
return _jsxs("div", { "data-slot": "detail-select", className: cn("detail-select", className), children: [_jsx("label", { id: `${triggerId}-label`, htmlFor: triggerId, className: "t-label", children: label }), _jsxs(Popover, { open: open && !disabled, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { id: triggerId, type: "button", disabled: disabled, "data-control-size": controlSize, className: "select detail-select-trigger", "aria-labelledby": `${triggerId}-label ${triggerId}-value`, "aria-describedby": describedBy, "aria-invalid": invalid, onKeyDown: event => {
|
|
24
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp")
|
|
25
|
+
return;
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
setOpen(true);
|
|
28
|
+
}, children: [current?.icon && _jsx("span", { className: "detail-select-icon", "aria-hidden": "true", children: current.icon }), _jsx("span", { id: `${triggerId}-value`, children: current?.label ?? placeholder })] }) }), _jsx(PopoverContent, { className: "detail-select-content", "aria-label": `${label}: options`, collisionPadding: 16, onOpenAutoFocus: event => {
|
|
29
|
+
const index = options.findIndex(option => option.value === selected && !option.disabled);
|
|
30
|
+
const target = buttons.current[index] ?? buttons.current.find(button => button && !button.disabled);
|
|
31
|
+
if (target) {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
target.focus();
|
|
34
|
+
}
|
|
35
|
+
}, children: options.length ? options.map((option, index) => _jsxs("section", { className: "detail-select-option", "data-selected": option.value === selected || undefined, "data-disabled": option.disabled || undefined, onClick: event => {
|
|
36
|
+
if (option.disabled || event.defaultPrevented || !(event.target instanceof Element))
|
|
37
|
+
return;
|
|
38
|
+
const interactive = event.target.closest("a, button, input, select, textarea, summary, label, [contenteditable], [role=button], [role=link], [role=checkbox], [role=radio], [role=switch], [role=slider], [role=combobox]");
|
|
39
|
+
if (!interactive || !event.currentTarget.contains(interactive))
|
|
40
|
+
choose(option);
|
|
41
|
+
}, "aria-labelledby": `${triggerId}-option-${index}`, children: [_jsx("div", { className: "detail-select-illustration", children: option.illustration }), _jsxs("div", { className: "detail-select-body", children: [_jsx("h3", { className: "detail-select-heading", children: _jsxs("button", { id: `${triggerId}-option-${index}`, type: "button", className: "detail-select-choice", ref: element => { buttons.current[index] = element; }, disabled: option.disabled, "aria-pressed": option.value === selected, "aria-describedby": `${triggerId}-description-${index}`, onClick: () => choose(option), onKeyDown: event => {
|
|
42
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
|
|
43
|
+
return;
|
|
44
|
+
const enabled = options.map((option, index) => ({ option, button: buttons.current[index] }))
|
|
45
|
+
.filter(item => item.button && !item.option.disabled);
|
|
46
|
+
const position = enabled.findIndex(item => item.button === event.currentTarget);
|
|
47
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? enabled.length - 1
|
|
48
|
+
: (position + (event.key === "ArrowDown" ? 1 : -1) + enabled.length) % enabled.length;
|
|
49
|
+
const target = enabled[next];
|
|
50
|
+
if (target) {
|
|
51
|
+
target.button?.focus();
|
|
52
|
+
choose(target.option, false);
|
|
53
|
+
}
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
}, children: [_jsx("span", { children: option.label }), option.value === selected && _jsx(Check, { className: "icon icon-sm", "aria-hidden": "true" })] }) }), _jsx("div", { id: `${triggerId}-description-${index}`, className: "detail-select-description", children: option.description })] })] }, option.value)) : _jsx("p", { className: "detail-select-empty", children: "No available options." }) })] })] });
|
|
56
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
export type DiagramKind = "route" | "service" | "repository" | "image" | "database";
|
|
4
|
+
export type DiagramBackground = "solid" | "dots" | "grid" | "crosses" | "construction" | "guides" | "fibers";
|
|
5
|
+
export type DiagramStatus = "stopped" | "failed";
|
|
6
|
+
export type DiagramEdgeLine = "solid" | "dashed" | "dotted";
|
|
7
|
+
export type DiagramEdgeTone = "neutral" | "success" | "danger";
|
|
8
|
+
export type DiagramBorderStyle = "solid" | "none" | "rail" | "dash" | "bevel" | "double" | "base" | "offset" | "manga" | "brush";
|
|
9
|
+
export type DiagramCornerStyle = "square" | "rounded" | "asym" | "pixel";
|
|
10
|
+
export type DiagramCornerSize = "off" | "small" | "medium" | "large";
|
|
11
|
+
export type DiagramCornerMarks = "none" | "ticks" | "brackets" | "arcs" | "diagonal" | "dots";
|
|
12
|
+
export type DiagramFrameProps = {
|
|
13
|
+
borderStyle?: DiagramBorderStyle;
|
|
14
|
+
cornerStyle?: DiagramCornerStyle;
|
|
15
|
+
cornerSize?: DiagramCornerSize;
|
|
16
|
+
cornerMarks?: DiagramCornerMarks;
|
|
17
|
+
};
|
|
18
|
+
export type DiagramProps = Omit<React.ComponentProps<"div">, "children"> & DiagramFrameProps & {
|
|
19
|
+
/** Names the drawing for assistive technology. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Unset follows the page's canvas; a page with no canvas gets dots. */
|
|
22
|
+
background?: DiagramBackground;
|
|
23
|
+
strength?: "quiet" | "visible";
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
};
|
|
26
|
+
declare function Diagram({ label, background, strength, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }: DiagramProps): React.JSX.Element;
|
|
27
|
+
declare function DiagramColumn({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
28
|
+
export type DiagramNodeGroupProps = React.ComponentProps<"div"> & DiagramFrameProps;
|
|
29
|
+
declare function DiagramNodeGroup({ borderStyle, cornerStyle, cornerSize, cornerMarks, className, ...props }: DiagramNodeGroupProps): React.JSX.Element;
|
|
30
|
+
export type DiagramNodeProps = Omit<React.ComponentProps<"div">, "title" | "children"> & DiagramFrameProps & {
|
|
31
|
+
/** Edges refer to the node by this id. Unique within the Diagram. */
|
|
32
|
+
id: string;
|
|
33
|
+
/** The name in weight. It never wraps. A node that only holds parts, such
|
|
34
|
+
as a DiagramFold, leaves it out. */
|
|
35
|
+
title?: React.ReactNode;
|
|
36
|
+
/** Default icon, label and tone. `icon` and `label` override it. */
|
|
37
|
+
kind?: DiagramKind;
|
|
38
|
+
icon?: LucideIcon;
|
|
39
|
+
/** The caption above the title. Without one, the icon leads the title. */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** Marks the node the screen is about. */
|
|
42
|
+
accent?: boolean;
|
|
43
|
+
status?: DiagramStatus;
|
|
44
|
+
/** Text renders under the title in mono, with its line breaks kept.
|
|
45
|
+
Elements, such as facts or a fold, render as they are. */
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
};
|
|
48
|
+
declare function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }: DiagramNodeProps): React.JSX.Element;
|
|
49
|
+
export type DiagramFactProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
50
|
+
icon?: LucideIcon;
|
|
51
|
+
label: string;
|
|
52
|
+
/** The value, right-aligned in mono. */
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
/** Said, muted, when there is no value. */
|
|
55
|
+
empty?: string;
|
|
56
|
+
};
|
|
57
|
+
declare function DiagramFact({ icon: Icon, label, empty, className, children, ...props }: DiagramFactProps): React.JSX.Element;
|
|
58
|
+
export type DiagramFoldProps = Omit<React.ComponentProps<"div">, "title"> & {
|
|
59
|
+
title: React.ReactNode;
|
|
60
|
+
/** The number of things the fold holds, shown next to the title. */
|
|
61
|
+
count?: number;
|
|
62
|
+
/** Open by default. */
|
|
63
|
+
defaultOpen?: boolean;
|
|
64
|
+
};
|
|
65
|
+
declare function DiagramFold({ title, count, defaultOpen, className, children, ...props }: DiagramFoldProps): React.JSX.Element;
|
|
66
|
+
export type DiagramFilterOption = {
|
|
67
|
+
value: string;
|
|
68
|
+
label: string;
|
|
69
|
+
count: number;
|
|
70
|
+
};
|
|
71
|
+
export type DiagramFilterProps = Omit<React.ComponentProps<"div">, "onChange"> & {
|
|
72
|
+
options: DiagramFilterOption[];
|
|
73
|
+
/** The option shown alone, or null for all of them. */
|
|
74
|
+
value: string | null;
|
|
75
|
+
onValueChange: (value: string | null) => void;
|
|
76
|
+
};
|
|
77
|
+
declare function DiagramFilter({ options, value, onValueChange, className, ...props }: DiagramFilterProps): React.JSX.Element;
|
|
78
|
+
export type DiagramSectionProps = Omit<React.ComponentProps<"div">, "title"> & {
|
|
79
|
+
/** Without a title the lines sit flat, with no tree. */
|
|
80
|
+
title?: React.ReactNode;
|
|
81
|
+
icon?: LucideIcon;
|
|
82
|
+
count?: number;
|
|
83
|
+
/** A control at the end of the heading, such as an add button. */
|
|
84
|
+
action?: React.ReactNode;
|
|
85
|
+
};
|
|
86
|
+
declare function DiagramSection({ title, icon: Icon, count, action, className, children, ...props }: DiagramSectionProps): React.JSX.Element;
|
|
87
|
+
export type DiagramLineProps = Omit<React.ComponentProps<"div">, "onClick"> & {
|
|
88
|
+
/** Right-aligned detail, such as a target or a state. */
|
|
89
|
+
end?: React.ReactNode;
|
|
90
|
+
/** Makes the line a button. */
|
|
91
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
92
|
+
};
|
|
93
|
+
declare function DiagramLine({ end, onClick, className, children, ...props }: DiagramLineProps): React.JSX.Element;
|
|
94
|
+
export type DiagramEdgeProps = {
|
|
95
|
+
/** One source id, or several that merge into the target. */
|
|
96
|
+
from: string | string[];
|
|
97
|
+
to: string;
|
|
98
|
+
/** Mono text on the run into the target, such as a port or a variable. */
|
|
99
|
+
label?: string;
|
|
100
|
+
line?: DiagramEdgeLine;
|
|
101
|
+
tone?: DiagramEdgeTone;
|
|
102
|
+
};
|
|
103
|
+
declare function DiagramEdge({ from, to, label, line, tone }: DiagramEdgeProps): null;
|
|
104
|
+
export { Diagram, DiagramColumn, DiagramNodeGroup, DiagramNode, DiagramFact, DiagramFold, DiagramFilter, DiagramSection, DiagramLine, DiagramEdge };
|