@momoi-labs/kiso-react 0.25.0 → 0.27.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/dist/alert-dialog.d.ts +1 -1
- package/dist/alert-dialog.js +3 -2
- package/dist/app-shell.d.ts +1 -1
- package/dist/app-shell.js +3 -2
- package/dist/card.d.ts +1 -1
- package/dist/card.js +4 -3
- package/dist/chart-data.d.ts +2 -0
- package/dist/chart-data.js +1 -0
- package/dist/code-block.js +2 -1
- package/dist/command-palette.js +2 -1
- package/dist/diagram-routes.d.ts +8 -2
- package/dist/diagram-routes.js +669 -398
- package/dist/diagram.d.ts +21 -11
- package/dist/diagram.js +39 -16
- package/dist/dialog.js +2 -1
- package/dist/drawer.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/log-view.js +8 -7
- package/dist/panel-shadow.d.ts +1 -0
- package/dist/panel-shadow.js +6 -0
- package/dist/status-badge.d.ts +16 -2
- package/dist/status-badge.js +9 -2
- package/dist/styles.css +4 -4
- package/dist/table.js +3 -2
- package/package.json +2 -2
package/dist/diagram.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type LucideIcon } from "lucide-react";
|
|
3
|
-
import { type
|
|
4
|
-
|
|
3
|
+
import { type DiagramSeries } from "./chart-data.js";
|
|
4
|
+
import { type DiagramArrow, type DiagramCrossings, type DiagramEdgeLine, type DiagramEdgeRoute, type DiagramEdgeShape, type DiagramEdgeSide, type DiagramEdgeTone, type DiagramLabels } from "./diagram-routes.js";
|
|
5
|
+
export type { DiagramArrow, DiagramCrossings, DiagramEdgeLine, DiagramEdgeRoute, DiagramEdgeShape, DiagramEdgeSide, DiagramEdgeTone, DiagramLabels, DiagramSeries };
|
|
5
6
|
export type DiagramKind = "route" | "service" | "repository" | "image" | "database";
|
|
6
7
|
export type DiagramBackground = "solid" | "dots" | "grid" | "crosses" | "construction" | "guides" | "fibers";
|
|
7
8
|
export type DiagramStatus = "stopped" | "failed";
|
|
@@ -10,7 +11,9 @@ export type DiagramBorderStyle = "solid" | "none" | "rail" | "dash" | "bevel" |
|
|
|
10
11
|
export type DiagramCornerStyle = "square" | "rounded" | "asym" | "pixel";
|
|
11
12
|
export type DiagramCornerSize = "off" | "small" | "medium" | "large";
|
|
12
13
|
export type DiagramCornerMarks = "none" | "ticks" | "brackets" | "arcs" | "diagonal" | "dots";
|
|
14
|
+
export type DiagramShadowStyle = "auto" | "none" | "hard" | "soft";
|
|
13
15
|
export type DiagramFrameProps = {
|
|
16
|
+
shadowStyle?: DiagramShadowStyle;
|
|
14
17
|
borderStyle?: DiagramBorderStyle;
|
|
15
18
|
cornerStyle?: DiagramCornerStyle;
|
|
16
19
|
cornerSize?: DiagramCornerSize;
|
|
@@ -44,7 +47,7 @@ export type DiagramProps = Omit<React.ComponentProps<"div">, "children"> & Diagr
|
|
|
44
47
|
strength?: "quiet" | "visible";
|
|
45
48
|
children: React.ReactNode;
|
|
46
49
|
};
|
|
47
|
-
declare function Diagram({ label, direction, columns, crossings, labels, edges: shape, arrow, footer, background, strength, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }: DiagramProps): React.JSX.Element;
|
|
50
|
+
declare function Diagram({ label, direction, columns, crossings, labels, edges: shape, arrow, footer, background, strength, borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, children, ...props }: DiagramProps): React.JSX.Element;
|
|
48
51
|
declare function DiagramColumn({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
49
52
|
export type DiagramRowProps = React.ComponentProps<"div"> & {
|
|
50
53
|
/** Where the row's nodes sit across the drawing. Center by default. */
|
|
@@ -71,7 +74,7 @@ export type DiagramGroupProps = Omit<React.ComponentProps<"div">, "title"> & {
|
|
|
71
74
|
};
|
|
72
75
|
declare function DiagramGroup({ label, title, footer, line, tone, collapsible, defaultOpen, className, style, children, ...props }: DiagramGroupProps): React.JSX.Element;
|
|
73
76
|
export type DiagramNodeGroupProps = React.ComponentProps<"div"> & DiagramFrameProps;
|
|
74
|
-
declare function DiagramNodeGroup({ borderStyle, cornerStyle, cornerSize, cornerMarks, className, ...props }: DiagramNodeGroupProps): React.JSX.Element;
|
|
77
|
+
declare function DiagramNodeGroup({ borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, ...props }: DiagramNodeGroupProps): React.JSX.Element;
|
|
75
78
|
export type DiagramNodeProps = Omit<React.ComponentProps<"div">, "title" | "children"> & DiagramFrameProps & {
|
|
76
79
|
/** Edges refer to the node by this id. Unique within the Diagram. */
|
|
77
80
|
id: string;
|
|
@@ -90,7 +93,7 @@ export type DiagramNodeProps = Omit<React.ComponentProps<"div">, "title" | "chil
|
|
|
90
93
|
Elements, such as facts or a fold, render as they are. */
|
|
91
94
|
children?: React.ReactNode;
|
|
92
95
|
};
|
|
93
|
-
declare function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }: DiagramNodeProps): React.JSX.Element;
|
|
96
|
+
declare function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, children, ...props }: DiagramNodeProps): React.JSX.Element;
|
|
94
97
|
export type DiagramFactProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
95
98
|
icon?: LucideIcon;
|
|
96
99
|
label: string;
|
|
@@ -142,9 +145,14 @@ export type DiagramEdgeProps = {
|
|
|
142
145
|
to: string;
|
|
143
146
|
/** Mono text on the run into the target, such as a port or a variable. */
|
|
144
147
|
label?: string;
|
|
145
|
-
/**
|
|
146
|
-
|
|
148
|
+
/** Forces the path the edge would otherwise pick, relative to the flow:
|
|
149
|
+
`side`, `down` or `drop`. `fromSide` and `toSide` win over it. */
|
|
147
150
|
route?: DiagramEdgeRoute;
|
|
151
|
+
/** The side of the source the edge leaves by. Without it, the Diagram
|
|
152
|
+
picks the side with the shortest clear path. */
|
|
153
|
+
fromSide?: DiagramEdgeSide;
|
|
154
|
+
/** The side of the target the edge comes into. */
|
|
155
|
+
toSide?: DiagramEdgeSide;
|
|
148
156
|
/** Overrides the Diagram's `edges` for this edge. */
|
|
149
157
|
shape?: DiagramEdgeShape;
|
|
150
158
|
/** Overrides the Diagram's `arrow` for this edge. */
|
|
@@ -156,16 +164,18 @@ export type DiagramEdgeProps = {
|
|
|
156
164
|
flow?: never;
|
|
157
165
|
}
|
|
158
166
|
/** A kind of link, such as replication or backups: the chart colour of the
|
|
159
|
-
slot and a dash of its own
|
|
167
|
+
slot and a dash of its own, or `"neutral"`, grey with its own dash.
|
|
168
|
+
`flow` moves the dash toward the target. */
|
|
160
169
|
| {
|
|
161
|
-
series:
|
|
170
|
+
series: DiagramSeries;
|
|
162
171
|
flow?: boolean;
|
|
163
172
|
line?: never;
|
|
164
173
|
tone?: never;
|
|
165
174
|
});
|
|
166
|
-
declare function DiagramEdge({ from, to, label, route, line, tone, series, flow, shape, arrow }: DiagramEdgeProps): null;
|
|
175
|
+
declare function DiagramEdge({ from, to, label, route, fromSide, toSide, line, tone, series: named, flow, shape, arrow }: DiagramEdgeProps): null;
|
|
167
176
|
export type DiagramEdgeKeyProps = Omit<React.ComponentProps<"span">, "children"> & {
|
|
168
|
-
|
|
177
|
+
/** A chart slot, or `"neutral"`. */
|
|
178
|
+
series: DiagramSeries;
|
|
169
179
|
/** What the series means, such as "WAL to storage". */
|
|
170
180
|
children: React.ReactNode;
|
|
171
181
|
};
|
package/dist/diagram.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PanelShadow } from "./panel-shadow.js";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { clsx as cn } from "clsx";
|
|
4
5
|
import { ChevronDown, ChevronUp, Container, Database, GitBranch, Route, Server } from "lucide-react";
|
|
5
6
|
import { Badge } from "./badge.js";
|
|
6
7
|
import { Card } from "./card.js";
|
|
7
|
-
import {
|
|
8
|
+
import { seriesColor } from "./chart-data.js";
|
|
8
9
|
import { StatusBadge } from "./status-badge.js";
|
|
9
10
|
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
10
11
|
import { draw, route, } from "./diagram-routes.js";
|
|
11
12
|
/* The number of dash patterns in ui.css. Series past it reuse a dash with a
|
|
12
13
|
new colour, so the pair stays unique. */
|
|
13
14
|
const DASHES = 5;
|
|
14
|
-
|
|
15
|
+
/* The router keys series by number, so the neutral series travels through
|
|
16
|
+
it as this slot. No chart slot is below 1. */
|
|
17
|
+
const NEUTRAL = -1;
|
|
18
|
+
const slotOf = (series) => series === "neutral" ? NEUTRAL : series;
|
|
19
|
+
const seriesOf = (slot) => slot === NEUTRAL ? "neutral" : slot;
|
|
20
|
+
/* The neutral series has a dash of its own, outside the five. */
|
|
21
|
+
const dashOf = (series) => series === "neutral" ? "neutral" : ((Math.max(1, Math.round(series)) - 1) % DASHES) + 1;
|
|
22
|
+
const colorOf = (slot) => seriesColor(seriesOf(slot));
|
|
15
23
|
const DiagramContext = React.createContext(null);
|
|
16
24
|
function useRegistry(part) {
|
|
17
25
|
const registry = React.useContext(DiagramContext);
|
|
@@ -42,7 +50,7 @@ const statuses = {
|
|
|
42
50
|
stopped: { label: "Stopped", tone: "neutral" },
|
|
43
51
|
failed: { label: "Failed", tone: "danger" },
|
|
44
52
|
};
|
|
45
|
-
function Diagram({ label, direction = "right", columns, crossings = "none", labels = "auto", edges: shape, arrow, footer, background, strength, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }) {
|
|
53
|
+
function Diagram({ label, direction = "right", columns, crossings = "none", labels = "auto", edges: shape, arrow, footer, background, strength, borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, children, ...props }) {
|
|
46
54
|
const frame = React.useRef(null);
|
|
47
55
|
const scroll = React.useRef(null);
|
|
48
56
|
const lanes = React.useRef(null);
|
|
@@ -171,7 +179,21 @@ function Diagram({ label, direction = "right", columns, crossings = "none", labe
|
|
|
171
179
|
const rect = place(element.getBoundingClientRect());
|
|
172
180
|
return rect.width && rect.height ? [{ ...rect, id: `frame:${index}`, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }] : [];
|
|
173
181
|
});
|
|
174
|
-
|
|
182
|
+
// A group's title on its top border and what its footer holds: no run
|
|
183
|
+
// or label crosses them.
|
|
184
|
+
const titles = groups.flatMap((element, index) => [
|
|
185
|
+
...element.querySelectorAll(":scope > .diagram-group-title, :scope > .diagram-group-foot > *"),
|
|
186
|
+
].flatMap((item, part) => {
|
|
187
|
+
const rect = place(item.getBoundingClientRect());
|
|
188
|
+
return rect.width && rect.height ? [{ ...rect, id: `title:${index}:${part}`, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }] : [];
|
|
189
|
+
}));
|
|
190
|
+
// A label keeps off a group's whole footer, so it never reads as part of it.
|
|
191
|
+
const feet = groups.flatMap((element, index) => {
|
|
192
|
+
const foot = element.querySelector(":scope > .diagram-group-foot");
|
|
193
|
+
const rect = foot ? place(foot.getBoundingClientRect()) : null;
|
|
194
|
+
return rect?.width && rect.height ? [{ ...rect, id: `foot:${index}`, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 }] : [];
|
|
195
|
+
});
|
|
196
|
+
const routes = route(measured, all, direction, walls, titles);
|
|
175
197
|
// An edge that comes into a group from the side needs room between
|
|
176
198
|
// the border and the node, so the line runs straight after crossing
|
|
177
199
|
// the border. Only the sides where edges come in get it.
|
|
@@ -228,7 +250,7 @@ function Diagram({ label, direction = "right", columns, crossings = "none", labe
|
|
|
228
250
|
probe.remove();
|
|
229
251
|
}
|
|
230
252
|
const measure = (text) => sizes.get(text) ?? { width: text.length * 7, height: 12 };
|
|
231
|
-
setDrawn(draw(routes, frames, crossings, labels, measure, { shape, arrow, boxes: new Map(all.map((item) => [item.id, item])) }));
|
|
253
|
+
setDrawn(draw(routes, frames, crossings, labels, measure, { shape, arrow, boxes: new Map(all.map((item) => [item.id, item])), blocks: [...titles, ...feet] }));
|
|
232
254
|
};
|
|
233
255
|
const measure = () => layout(0);
|
|
234
256
|
measure();
|
|
@@ -247,17 +269,17 @@ function Diagram({ label, direction = "right", columns, crossings = "none", labe
|
|
|
247
269
|
fonts?.removeEventListener("loadingdone", refont);
|
|
248
270
|
};
|
|
249
271
|
}, [direction, crossings, labels, shape, arrow, registered, nodes, version]);
|
|
250
|
-
return (_jsx(DiagramContext.Provider, { value: context, children: _jsxs("div", { ...props, "data-slot": "diagram", className: cn("card diagram", className), "data-direction": direction, "data-background-style": background, "data-background-strength": strength, children: [_jsx("div", { ref: scroll, "data-slot": "diagram-scroll", className: "diagram-scroll", role: "group", "aria-label": label, tabIndex: 0, children: _jsxs("div", { ref: frame, "data-slot": "diagram-canvas", className: "diagram-canvas", children: [_jsx("div", { ref: lanes, "data-slot": "diagram-lanes", className: "diagram-lanes", "data-direction": direction, style: direction === "grid" && columns ? { "--diagram-columns": columns } : undefined, "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks, "data-edge-labels": registered.some((edge) => edge.label) || undefined, children: children }), _jsxs("svg", { ref: svg, className: "diagram-edges", "aria-hidden": "true", children: [_jsxs("defs", { children: [["neutral", "success", "danger"].map((tone) => (_jsx("marker", { id: `${marker}-${tone}`, className: "diagram-arrow", "data-tone": tone, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M 0 0 L 10 5 L 0 10 z" }) }, tone))), [...new Set(registered.flatMap((edge) => edge.series ? [edge.series] : []))].map((series) => (_jsx("marker", { id: `${marker}-s${series}`, className: "diagram-arrow", style: { color:
|
|
272
|
+
return (_jsx(DiagramContext.Provider, { value: context, children: _jsxs("div", { ...props, "data-slot": "diagram", className: cn("card diagram", className), "data-direction": direction, "data-background-style": background, "data-background-strength": strength, children: [_jsx(PanelShadow, {}), _jsx("div", { ref: scroll, "data-slot": "diagram-scroll", className: "diagram-scroll", role: "group", "aria-label": label, tabIndex: 0, children: _jsxs("div", { ref: frame, "data-slot": "diagram-canvas", className: "diagram-canvas", children: [_jsx("div", { ref: lanes, "data-slot": "diagram-lanes", className: "diagram-lanes", "data-direction": direction, style: direction === "grid" && columns ? { "--diagram-columns": columns } : undefined, "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks, "data-shadow-style": shadowStyle, "data-edge-labels": registered.some((edge) => edge.label) || undefined, children: children }), _jsxs("svg", { ref: svg, className: "diagram-edges", "aria-hidden": "true", children: [_jsxs("defs", { children: [["neutral", "success", "danger"].map((tone) => (_jsx("marker", { id: `${marker}-${tone}`, className: "diagram-arrow", "data-tone": tone, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M 0 0 L 10 5 L 0 10 z" }) }, tone))), [...new Set(registered.flatMap((edge) => edge.series ? [edge.series] : []))].map((series) => (_jsx("marker", { id: `${marker}-s${series}`, className: "diagram-arrow", style: { color: colorOf(series) }, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "6", markerHeight: "6", orient: "auto-start-reverse", children: _jsx("path", { d: "M 0 0 L 10 5 L 0 10 z" }) }, series))), [...new Set(drawn.paths.flatMap((path) => path.arrow && path.head !== "triangle" && path.head !== "none"
|
|
251
273
|
? [`${path.head}|${path.series ? `s${path.series}` : path.tone ?? "neutral"}`] : []))].map((id) => {
|
|
252
274
|
const [head, paint] = id.split("|");
|
|
253
275
|
const series = paint.startsWith("s") ? Number(paint.slice(1)) : undefined;
|
|
254
276
|
const size = series ? "6" : "7";
|
|
255
|
-
return (_jsx("marker", { id: `${marker}-${head}-${paint}`, className: "diagram-arrow", "data-arrow": head, "data-tone": series ? undefined : paint, style: series ? { color:
|
|
277
|
+
return (_jsx("marker", { id: `${marker}-${head}-${paint}`, className: "diagram-arrow", "data-arrow": head, "data-tone": series ? undefined : paint, style: series ? { color: colorOf(series) } : undefined, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: size, markerHeight: size, orient: "auto-start-reverse", children: heads[head] }, id));
|
|
256
278
|
})] }), drawn.plates.map((plate) => (_jsx("rect", { className: "diagram-edge-plate", x: plate.x, y: plate.y, width: plate.width, height: plate.height }, plate.key))), drawn.paths.map((path) => {
|
|
257
279
|
const series = path.series;
|
|
258
280
|
const paint = series ? `s${series}` : path.tone ?? "neutral";
|
|
259
|
-
return (_jsxs(React.Fragment, { children: [path.knock && _jsx("path", { className: "diagram-edge-knock", d: path.knock }), _jsx("path", { d: path.d, "data-shape": path.shape && path.shape !== "orthogonal" ? path.shape : undefined, "data-line": series ? undefined : path.line, "data-tone": series ? undefined : path.tone, "data-series": series, "data-dash": series ? dashOf(series) : undefined, "data-flow": (series && path.flow) || undefined, style: series ? { color:
|
|
260
|
-
}), drawn.dots.map((dot) => (_jsx("circle", { className: "diagram-junction", cx: dot.x, cy: dot.y, r: "3", "data-tone": dot.series ? undefined : dot.tone, style: dot.series ? { color:
|
|
281
|
+
return (_jsxs(React.Fragment, { children: [path.knock && _jsx("path", { className: "diagram-edge-knock", d: path.knock }), _jsx("path", { d: path.d, "data-shape": path.shape && path.shape !== "orthogonal" ? path.shape : undefined, "data-line": series ? undefined : path.line, "data-tone": series ? undefined : path.tone, "data-series": series ? seriesOf(series) : undefined, "data-dash": series ? dashOf(seriesOf(series)) : undefined, "data-flow": (series && path.flow) || undefined, style: series ? { color: colorOf(series) } : undefined, markerEnd: !path.arrow || path.head === "none" ? undefined : `url(#${marker}-${path.head === "triangle" ? "" : `${path.head}-`}${paint})` })] }, path.key));
|
|
282
|
+
}), drawn.dots.map((dot) => (_jsx("circle", { className: "diagram-junction", cx: dot.x, cy: dot.y, r: "3", "data-tone": dot.series ? undefined : dot.tone, style: dot.series ? { color: colorOf(dot.series) } : undefined }, dot.key))), drawn.labels.map((item) => (_jsxs(React.Fragment, { children: [item.plate && _jsx("rect", { className: "diagram-edge-plate", x: item.plate.x, y: item.plate.y, width: item.plate.width, height: item.plate.height }), _jsx("text", { x: item.x, y: item.y, className: "diagram-edge-label", "data-anchor": item.anchor, "data-orient": item.rotate ? "vertical" : item.middle ? "inline" : undefined, transform: item.rotate ? `rotate(-90 ${item.x} ${item.y})` : undefined, children: item.lines.length > 1
|
|
261
283
|
? _jsxs(_Fragment, { children: [_jsx("tspan", { x: item.x, dy: "-1.2em", children: item.lines[0] }), _jsx("tspan", { x: item.x, dy: "1.2em", children: item.lines[1] })] })
|
|
262
284
|
: item.lines[0] })] }, item.key)))] })] }) }), footer != null && (_jsx("div", { "data-slot": "diagram-footer", className: "diagram-footer", children: _jsx("div", { className: "diagram-footer-items", children: footer }) }))] }) }));
|
|
263
285
|
}
|
|
@@ -309,10 +331,10 @@ function DiagramGroup({ label, title, footer, line, tone, collapsible = false, d
|
|
|
309
331
|
container that receives requests with the other containers under it.
|
|
310
332
|
Edges still reach each node on its own. The group carries the frame, so
|
|
311
333
|
its frame props replace the nodes' own. */
|
|
312
|
-
function DiagramNodeGroup({ borderStyle, cornerStyle, cornerSize, cornerMarks, className, ...props }) {
|
|
313
|
-
return (_jsx(Card, { ...props, "data-slot": "diagram-node-group", className: cn("diagram-node-group", className), "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks }));
|
|
334
|
+
function DiagramNodeGroup({ borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, ...props }) {
|
|
335
|
+
return (_jsx(Card, { ...props, "data-slot": "diagram-node-group", className: cn("diagram-node-group", className), "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks, "data-shadow-style": shadowStyle }));
|
|
314
336
|
}
|
|
315
|
-
function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle, cornerStyle, cornerSize, cornerMarks, className, children, ...props }) {
|
|
337
|
+
function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle, cornerStyle, cornerSize, cornerMarks, shadowStyle, className, children, ...props }) {
|
|
316
338
|
const { register } = useRegistry("DiagramNode");
|
|
317
339
|
const ref = React.useCallback((element) => register(id, element), [id, register]);
|
|
318
340
|
const spec = kind ? kinds[kind] : undefined;
|
|
@@ -322,7 +344,7 @@ function DiagramNode({ id, title, kind, icon, label, accent, status, borderStyle
|
|
|
322
344
|
const items = React.Children.toArray(children);
|
|
323
345
|
const text = items.filter((item) => typeof item === "string" || typeof item === "number");
|
|
324
346
|
const parts = items.filter((item) => typeof item !== "string" && typeof item !== "number");
|
|
325
|
-
return (_jsxs(Card, { ...props, ref: ref, "data-slot": "diagram-node", className: cn("diagram-node", className), "data-kind": kind, "data-tone": spec?.tone ?? "neutral", "data-accent": accent || undefined, "data-status": status, "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks, children: [caption && (_jsxs("span", { className: "diagram-node-kind", children: [glyph, _jsx("span", { className: "t-caps", children: caption })] })), title != null && (_jsxs("span", { className: "diagram-node-title", "data-lead": (!caption && !!glyph) || undefined, children: [!caption && glyph, title] })), text.length > 0 && _jsx("span", { className: "diagram-node-text mono", children: text }), status && (_jsx(StatusBadge, { tone: statuses[status].tone, className: "diagram-node-status", children: statuses[status].label })), parts] }));
|
|
347
|
+
return (_jsxs(Card, { ...props, ref: ref, "data-slot": "diagram-node", className: cn("diagram-node", className), "data-kind": kind, "data-tone": spec?.tone ?? "neutral", "data-accent": accent || undefined, "data-status": status, "data-border-style": borderStyle, "data-corner-style": cornerStyle, "data-corner-size": cornerSize, "data-corner-marks": cornerMarks, "data-shadow-style": shadowStyle, children: [caption && (_jsxs("span", { className: "diagram-node-kind", children: [glyph, _jsx("span", { className: "t-caps", children: caption })] })), title != null && (_jsxs("span", { className: "diagram-node-title", "data-lead": (!caption && !!glyph) || undefined, children: [!caption && glyph, title] })), text.length > 0 && _jsx("span", { className: "diagram-node-text mono", children: text }), status && (_jsx(StatusBadge, { tone: statuses[status].tone, className: "diagram-node-status", children: statuses[status].label })), parts] }));
|
|
326
348
|
}
|
|
327
349
|
/* One fact about a node as a line: its icon and name, the value on the
|
|
328
350
|
right. Long values wrap under the name before they widen the node. */
|
|
@@ -362,16 +384,17 @@ function DiagramLine({ end, onClick, className, children, ...props }) {
|
|
|
362
384
|
}
|
|
363
385
|
/* An edge renders nothing itself: it registers with the Diagram, which draws
|
|
364
386
|
it once the nodes are measured. */
|
|
365
|
-
function DiagramEdge({ from, to, label, route, line, tone, series, flow, shape, arrow }) {
|
|
387
|
+
function DiagramEdge({ from, to, label, route, fromSide, toSide, line, tone, series: named, flow, shape, arrow }) {
|
|
366
388
|
const { addEdge } = useRegistry("DiagramEdge");
|
|
389
|
+
const series = named == null ? undefined : slotOf(named);
|
|
367
390
|
// Ids never contain a newline, so the join is a stable dependency.
|
|
368
391
|
const sources = (Array.isArray(from) ? from : [from]).join("\n");
|
|
369
|
-
React.useEffect(() => addEdge({ key: `${sources}->${to}${series ? `#${series}` : ""}`, from: sources.split("\n"), to, label, route, line, tone, series, flow, shape, head: arrow }), [addEdge, sources, to, label, route, line, tone, series, flow, shape, arrow]);
|
|
392
|
+
React.useEffect(() => addEdge({ key: `${sources}->${to}${series ? `#${series}` : ""}`, from: sources.split("\n"), to, label, route, fromSide, toSide, line, tone, series, flow, shape, head: arrow }), [addEdge, sources, to, label, route, fromSide, toSide, line, tone, series, flow, shape, arrow]);
|
|
370
393
|
return null;
|
|
371
394
|
}
|
|
372
395
|
/* A sample of a series edge, its colour and dash, with what it means. The
|
|
373
396
|
product lays these out as the drawing's key; the sample never moves. */
|
|
374
397
|
function DiagramEdgeKey({ series, className, children, ...props }) {
|
|
375
|
-
return (_jsxs("span", { ...props, "data-slot": "diagram-edge-key", className: cn("diagram-edge-key", className), children: [_jsx("svg", { viewBox: "0 0 28 6", "aria-hidden": "true", focusable: "false", style: { color:
|
|
398
|
+
return (_jsxs("span", { ...props, "data-slot": "diagram-edge-key", className: cn("diagram-edge-key", className), children: [_jsx("svg", { viewBox: "0 0 28 6", "aria-hidden": "true", focusable: "false", style: { color: seriesColor(series) }, children: _jsx("path", { d: "M 2 3 H 26", "data-series": series, "data-dash": dashOf(series) }) }), children] }));
|
|
376
399
|
}
|
|
377
400
|
export { Diagram, DiagramColumn, DiagramRow, DiagramGroup, DiagramEdgeKey, DiagramNodeGroup, DiagramNode, DiagramFact, DiagramFold, DiagramFilter, DiagramSection, DiagramLine, DiagramEdge };
|
package/dist/dialog.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
|
|
2
2
|
"use client";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { PanelShadow } from "./panel-shadow.js";
|
|
4
5
|
import { clsx as cn } from "clsx";
|
|
5
6
|
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
6
7
|
function Dialog({ ...props }) {
|
|
@@ -19,7 +20,7 @@ function DialogOverlay({ className, ...props }) {
|
|
|
19
20
|
return (_jsx(DialogPrimitive.Overlay, { "data-slot": "dialog-overlay", className: cn("kiso-react-overlay", className), ...props }));
|
|
20
21
|
}
|
|
21
22
|
function DialogContent({ className, children, ...props }) {
|
|
22
|
-
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}),
|
|
23
|
+
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "aria-modal": "true", "data-slot": "dialog-content", className: cn("kiso-react-dialog marked", className), ...props, children: [_jsx(PanelShadow, {}), children] })] }));
|
|
23
24
|
}
|
|
24
25
|
function DialogHeader({ className, ...props }) {
|
|
25
26
|
return (_jsx("div", { "data-slot": "dialog-header", className: cn("dialog-header", className), ...props }));
|
package/dist/drawer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PanelShadow } from "./panel-shadow.js";
|
|
3
4
|
import { clsx as cn } from "clsx";
|
|
4
5
|
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
5
6
|
import { DialogBody, DialogClose, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogDescription, } from "./dialog.js";
|
|
@@ -12,6 +13,6 @@ function DrawerTrigger({ ...props }) {
|
|
|
12
13
|
return _jsx(DialogPrimitive.Trigger, { "data-slot": "drawer-trigger", ...props });
|
|
13
14
|
}
|
|
14
15
|
function DrawerContent({ className, placement = "bottom", children, ...props }) {
|
|
15
|
-
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}),
|
|
16
|
+
return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, { "aria-modal": "true", "data-slot": "drawer-content", "data-placement": placement, className: cn("kiso-react-drawer marked", className), ...props, children: [_jsx(PanelShadow, {}), children] })] }));
|
|
16
17
|
}
|
|
17
18
|
export { Drawer, DrawerTrigger, DrawerContent, DialogClose as DrawerClose, DialogHeader as DrawerHeader, DialogBody as DrawerBody, DialogFooter as DrawerFooter, DialogTitle as DrawerTitle, DialogDescription as DrawerDescription, };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./brand-mark.js";
|
|
|
7
7
|
export * from "./breadcrumb.js";
|
|
8
8
|
export * from "./button.js";
|
|
9
9
|
export * from "./card.js";
|
|
10
|
+
export * from "./panel-shadow.js";
|
|
10
11
|
export * from "./checkbox.js";
|
|
11
12
|
export * from "./chip-input.js";
|
|
12
13
|
export * from "./code-block.js";
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./brand-mark.js";
|
|
|
8
8
|
export * from "./breadcrumb.js";
|
|
9
9
|
export * from "./button.js";
|
|
10
10
|
export * from "./card.js";
|
|
11
|
+
export * from "./panel-shadow.js";
|
|
11
12
|
export * from "./checkbox.js";
|
|
12
13
|
export * from "./chip-input.js";
|
|
13
14
|
export * from "./code-block.js";
|
package/dist/log-view.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
|
|
2
2
|
"use client";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { PanelShadow } from "./panel-shadow.js";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { cva } from "class-variance-authority";
|
|
6
7
|
import { clsx as cn } from "clsx";
|
|
@@ -47,12 +48,12 @@ function LogView({ className, children, follow, onFollowChange, ref, ...props })
|
|
|
47
48
|
el.scrollTop = el.scrollHeight;
|
|
48
49
|
pinned.current = el.scrollHeight;
|
|
49
50
|
}, [children, following]);
|
|
50
|
-
return (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
return (_jsxs("div", { "data-slot": "log-view", "data-follow": following, className: cn("logview", className), ...props, children: [_jsx(PanelShadow, {}), _jsx("div", { ref: scroller, "data-slot": "log-view-scroll", className: "log-scroll", onScroll: (event) => {
|
|
52
|
+
const bottom = isAtBottom(event.currentTarget);
|
|
53
|
+
setAtBottom(bottom);
|
|
54
|
+
if (bottom !== following)
|
|
55
|
+
onFollowChange?.(bottom);
|
|
56
|
+
}, children: children })] }));
|
|
56
57
|
}
|
|
57
58
|
function LogViewLine({ className, ...props }) {
|
|
58
59
|
return (_jsx("div", { "data-slot": "log-view-line", className: cn("", className), ...props }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PanelShadow(): import("react").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* Non-box contours need a separate paint layer. Filtering this empty layer
|
|
3
|
+
leaves panel content, controls and translucent fills unchanged. */
|
|
4
|
+
export function PanelShadow() {
|
|
5
|
+
return _jsx("span", { className: "panel-shadow", "aria-hidden": "true", children: _jsx("span", { children: _jsx("span", {}) }) });
|
|
6
|
+
}
|
package/dist/status-badge.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
3
|
import { Badge } from "./badge.js";
|
|
4
|
+
import { type DiagramSeries } from "./chart-data.js";
|
|
3
5
|
import type { StatusBadgeSpec, StatusTone } from "./generated/status-badge.js";
|
|
4
6
|
export type { StatusTone };
|
|
5
|
-
export type StatusBadgeProps = Omit<React.ComponentProps<typeof Badge>, "variant" | "asChild"> & Omit<StatusBadgeSpec, "label"
|
|
6
|
-
|
|
7
|
+
export type StatusBadgeProps = Omit<React.ComponentProps<typeof Badge>, "variant" | "asChild"> & Omit<StatusBadgeSpec, "label" | "tone"> & ({
|
|
8
|
+
tone: StatusTone;
|
|
9
|
+
series?: never;
|
|
10
|
+
icon?: never;
|
|
11
|
+
}
|
|
12
|
+
/** A state that belongs to a Diagram edge, such as "Streaming" on the
|
|
13
|
+
node a replication edge feeds: the edge's series colour in place of
|
|
14
|
+
a tone. `icon` replaces the dot and takes its pulse. */
|
|
15
|
+
| {
|
|
16
|
+
series: DiagramSeries;
|
|
17
|
+
icon?: LucideIcon;
|
|
18
|
+
tone?: never;
|
|
19
|
+
});
|
|
20
|
+
export declare function StatusBadge({ tone, series, icon: Icon, pulse, className, style, children, ...props }: StatusBadgeProps): React.JSX.Element;
|
package/dist/status-badge.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as cn } from "clsx";
|
|
2
3
|
import { Badge } from "./badge.js";
|
|
4
|
+
import { seriesColor } from "./chart-data.js";
|
|
3
5
|
import { Dot } from "./dot.js";
|
|
4
6
|
/* The dot pulses while work is going, a run or a build; a thing that is
|
|
5
7
|
merely up holds still. */
|
|
6
|
-
export function StatusBadge({ tone, pulse = false, children, ...props }) {
|
|
7
|
-
|
|
8
|
+
export function StatusBadge({ tone, series, icon: Icon, pulse = false, className, style, children, ...props }) {
|
|
9
|
+
if (series == null) {
|
|
10
|
+
return _jsxs(Badge, { ...props, className: className, style: style, variant: tone, children: [_jsx(Dot, { pulse: pulse }), children] });
|
|
11
|
+
}
|
|
12
|
+
return _jsxs(Badge, { ...props, "data-variant": "series", "data-series": series, className: cn("badge-series", className), style: { "--badge-series": seriesColor(series), ...style }, children: [Icon
|
|
13
|
+
? _jsx("span", { className: cn("badge-series-icon", pulse && "dot-pulse"), "aria-hidden": "true", children: _jsx(Icon, { className: "icon", strokeWidth: 1.75, "aria-hidden": "true", focusable: "false" }) })
|
|
14
|
+
: _jsx(Dot, { pulse: pulse }), children] });
|
|
8
15
|
}
|
package/dist/styles.css
CHANGED
|
@@ -178,9 +178,9 @@
|
|
|
178
178
|
width: min(32rem, calc(100vw - 2 * var(--spacing-lg)));
|
|
179
179
|
--frame-fill: var(--color-elevated-surface);
|
|
180
180
|
background-color: color-mix(in srgb, var(--frame-fill) calc((1 - var(--appearance-expressive, 0)) * (1 - var(--pixel-enabled, 0)) * 100%), transparent);
|
|
181
|
-
border: 1px var(--appearance-panel-border, solid) var(--appearance-border-color, var(--corner-border-color, var(--color-border)));
|
|
181
|
+
border: 1px var(--appearance-panel-border, solid) var(--appearance-border-color, var(--corner-border-color, var(--appearance-cast-border, var(--color-border))));
|
|
182
182
|
border-radius: var(--appearance-corners, var(--radius-surface));
|
|
183
|
-
box-shadow: var(--appearance-frame-shadow, var(--corner-frame-shadow, var(--shadow-md)));
|
|
183
|
+
box-shadow: var(--panel-shadow-legacy, var(--appearance-frame-shadow, var(--corner-frame-shadow, var(--shadow-md), var(--appearance-cast-shadow, 0 0 transparent)))) var(--panel-shadow-projection, var(--panel-shadow-paint));
|
|
184
184
|
}
|
|
185
185
|
.dialog-scroll {
|
|
186
186
|
max-height: calc(100dvh - 2 * var(--spacing-xl));
|
|
@@ -476,8 +476,8 @@
|
|
|
476
476
|
flex-direction: column;
|
|
477
477
|
--frame-fill: var(--color-elevated-surface);
|
|
478
478
|
background-color: color-mix(in srgb, var(--frame-fill) calc((1 - var(--appearance-expressive, 0)) * (1 - var(--pixel-enabled, 0)) * 100%), transparent);
|
|
479
|
-
border: 1px var(--appearance-panel-border, solid) var(--appearance-border-color, var(--corner-border-color, var(--color-border)));
|
|
480
|
-
box-shadow: var(--appearance-frame-shadow, var(--corner-frame-shadow, var(--shadow-md)));
|
|
479
|
+
border: 1px var(--appearance-panel-border, solid) var(--appearance-border-color, var(--corner-border-color, var(--appearance-cast-border, var(--color-border))));
|
|
480
|
+
box-shadow: var(--panel-shadow-legacy, var(--appearance-frame-shadow, var(--corner-frame-shadow, var(--shadow-md), var(--appearance-cast-shadow, 0 0 transparent)))) var(--panel-shadow-projection, var(--panel-shadow-paint));
|
|
481
481
|
}
|
|
482
482
|
.kiso-react-drawer[data-placement="side"] {
|
|
483
483
|
inset-block: 0;
|
package/dist/table.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Adapted from shadcn/ui new-york-v4. See ../SHADCN-LICENSE.
|
|
2
2
|
"use client";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { PanelShadow } from "./panel-shadow.js";
|
|
4
5
|
import { clsx as cn } from "clsx";
|
|
5
6
|
function TableFrame({ className, frame = "default", children, ...props }) {
|
|
6
|
-
return
|
|
7
|
+
return _jsxs("div", { "data-slot": "table-frame", "data-frame": frame, className: cn("table-wrap", className), ...props, children: [_jsx(PanelShadow, {}), _jsx("div", { className: "table-surface", children: children })] });
|
|
7
8
|
}
|
|
8
9
|
function Table({ className, density, header, ...props }) {
|
|
9
10
|
return (_jsx("div", { "data-slot": "table-container", className: "table-scroll", children: _jsx("table", { "data-slot": "table", "data-density": density, "data-header": header, className: cn("table", className), ...props }) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Kiso React components built with shadcn/ui and Radix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@momoi-labs/kiso": "^1.
|
|
35
|
+
"@momoi-labs/kiso": "^1.5.1",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|