@glyphjs/components 0.5.1 → 0.6.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/index.cjs +84 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +84 -63
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1632,16 +1632,16 @@ function useZoomInteraction({
|
|
|
1632
1632
|
};
|
|
1633
1633
|
}, [interactionMode, svgRef]);
|
|
1634
1634
|
const zoomBehavior = react.useMemo(() => {
|
|
1635
|
-
const
|
|
1636
|
-
if (typeof
|
|
1637
|
-
|
|
1635
|
+
const zoom2 = d32__namespace.zoom().scaleExtent([0.1, 4]);
|
|
1636
|
+
if (typeof zoom2.filter === "function") {
|
|
1637
|
+
zoom2.filter(filterFunction);
|
|
1638
1638
|
}
|
|
1639
|
-
|
|
1639
|
+
zoom2.on("zoom", (event) => {
|
|
1640
1640
|
if (rootRef.current) {
|
|
1641
1641
|
d32__namespace.select(rootRef.current).attr("transform", event.transform.toString());
|
|
1642
1642
|
}
|
|
1643
1643
|
});
|
|
1644
|
-
return
|
|
1644
|
+
return zoom2;
|
|
1645
1645
|
}, [filterFunction, rootRef]);
|
|
1646
1646
|
const handleActivate = react.useCallback(() => {
|
|
1647
1647
|
if (interactionMode === "click-to-activate") {
|
|
@@ -4038,7 +4038,7 @@ function getThemeVar3(container, varName, fallback) {
|
|
|
4038
4038
|
return getComputedStyle(container).getPropertyValue(varName).trim() || fallback;
|
|
4039
4039
|
}
|
|
4040
4040
|
var ARROW_MARKER_ID3 = "glyph-arch-arrowhead";
|
|
4041
|
-
function renderArchitecture(svgElement, layout) {
|
|
4041
|
+
function renderArchitecture(svgElement, layout, rootRef, zoomBehavior) {
|
|
4042
4042
|
const svg = d32__namespace.select(svgElement);
|
|
4043
4043
|
svg.selectAll("*").remove();
|
|
4044
4044
|
const width = Math.max(layout.width, 200);
|
|
@@ -4051,10 +4051,12 @@ function renderArchitecture(svgElement, layout) {
|
|
|
4051
4051
|
const nodeStrokeWidth = getThemeVar3(container, "--glyph-node-stroke-width", "1.5");
|
|
4052
4052
|
const nodeFillOpacity = getThemeVar3(container, "--glyph-node-fill-opacity", "0.85");
|
|
4053
4053
|
const root = svg.append("g").attr("class", "glyph-architecture-root");
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
}
|
|
4057
|
-
|
|
4054
|
+
if (rootRef) {
|
|
4055
|
+
rootRef.current = root.node();
|
|
4056
|
+
}
|
|
4057
|
+
if (zoomBehavior) {
|
|
4058
|
+
svg.call(zoomBehavior);
|
|
4059
|
+
}
|
|
4058
4060
|
const sortedZones = [...layout.zones].sort((a, b) => a.depth - b.depth);
|
|
4059
4061
|
const zoneGroup = root.append("g").attr("class", "glyph-architecture-zones");
|
|
4060
4062
|
for (const zone of sortedZones) {
|
|
@@ -4122,10 +4124,19 @@ function renderArchitecture(svgElement, layout) {
|
|
|
4122
4124
|
}
|
|
4123
4125
|
function Architecture({
|
|
4124
4126
|
data,
|
|
4125
|
-
container
|
|
4127
|
+
container,
|
|
4128
|
+
block
|
|
4126
4129
|
}) {
|
|
4127
4130
|
const svgRef = react.useRef(null);
|
|
4131
|
+
const rootRef = react.useRef(null);
|
|
4132
|
+
const containerRef = react.useRef(null);
|
|
4128
4133
|
const [layout, setLayout] = react.useState(null);
|
|
4134
|
+
const { overlayProps, zoomBehavior, zoomIn, zoomOut, resetZoom } = useZoomInteraction({
|
|
4135
|
+
svgRef,
|
|
4136
|
+
rootRef,
|
|
4137
|
+
interactionMode: data.interactionMode ?? "modifier-key",
|
|
4138
|
+
blockId: block.id
|
|
4139
|
+
});
|
|
4129
4140
|
react.useEffect(() => {
|
|
4130
4141
|
let cancelled = false;
|
|
4131
4142
|
computeArchitectureLayout(data).then((result) => {
|
|
@@ -4137,62 +4148,72 @@ function Architecture({
|
|
|
4137
4148
|
}, [data]);
|
|
4138
4149
|
react.useEffect(() => {
|
|
4139
4150
|
if (!svgRef.current || !layout) return;
|
|
4140
|
-
renderArchitecture(svgRef.current, layout);
|
|
4141
|
-
}, [layout]);
|
|
4151
|
+
renderArchitecture(svgRef.current, layout, rootRef, zoomBehavior);
|
|
4152
|
+
}, [layout, zoomBehavior]);
|
|
4142
4153
|
const nodeCount = countLeafNodes(data.children);
|
|
4143
4154
|
const edgeCount = data.edges.length;
|
|
4144
4155
|
const ariaLabel = data.title ? `${data.title}: architecture diagram with ${nodeCount} nodes and ${edgeCount} connections` : `Architecture diagram with ${nodeCount} nodes and ${edgeCount} connections`;
|
|
4145
4156
|
const flatNodes = flattenNodes(data.children);
|
|
4146
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4158
|
+
"div",
|
|
4159
|
+
{
|
|
4160
|
+
ref: containerRef,
|
|
4161
|
+
className: "glyph-architecture-container",
|
|
4162
|
+
style: { position: "relative" },
|
|
4163
|
+
children: [
|
|
4164
|
+
!layout && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4165
|
+
"div",
|
|
4166
|
+
{
|
|
4167
|
+
style: {
|
|
4168
|
+
padding: "2rem",
|
|
4169
|
+
textAlign: "center",
|
|
4170
|
+
color: "var(--glyph-text-muted, #7a8599)",
|
|
4171
|
+
fontFamily: "Inter, system-ui, sans-serif",
|
|
4172
|
+
fontSize: "13px"
|
|
4173
|
+
},
|
|
4174
|
+
children: "Computing layout..."
|
|
4175
|
+
}
|
|
4176
|
+
),
|
|
4177
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4178
|
+
"svg",
|
|
4179
|
+
{
|
|
4180
|
+
ref: svgRef,
|
|
4181
|
+
role: "img",
|
|
4182
|
+
"aria-label": ariaLabel,
|
|
4183
|
+
width: "100%",
|
|
4184
|
+
height: "100%",
|
|
4185
|
+
style: {
|
|
4186
|
+
minHeight: container.tier === "compact" ? 200 : 300,
|
|
4187
|
+
maxHeight: container.tier === "compact" ? 500 : 700,
|
|
4188
|
+
display: layout ? "block" : "none"
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
),
|
|
4192
|
+
layout && overlayProps && /* @__PURE__ */ jsxRuntime.jsx(InteractionOverlay, { ...overlayProps }),
|
|
4193
|
+
layout && data.showZoomControls !== false && /* @__PURE__ */ jsxRuntime.jsx(ZoomControls, { onZoomIn: zoomIn, onZoomOut: zoomOut, onReset: resetZoom }),
|
|
4194
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: "sr-only", "aria-label": "Architecture data", style: SR_ONLY_STYLE6, children: [
|
|
4195
|
+
/* @__PURE__ */ jsxRuntime.jsx("caption", { children: "Architecture nodes and connections" }),
|
|
4196
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
4197
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", children: "Node" }),
|
|
4198
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", children: "Zone" }),
|
|
4199
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", children: "Connections" })
|
|
4200
|
+
] }) }),
|
|
4201
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: flatNodes.map((node) => {
|
|
4202
|
+
const connections = data.edges.filter((e) => e.from === node.id || e.to === node.id).map((e) => {
|
|
4203
|
+
const target = e.from === node.id ? e.to : e.from;
|
|
4204
|
+
const dir = e.from === node.id ? "->" : "<-";
|
|
4205
|
+
return `${dir} ${target}${e.label ? ` (${e.label})` : ""}`;
|
|
4206
|
+
}).join(", ");
|
|
4207
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
4208
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: node.label }),
|
|
4209
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: node.zone ?? "" }),
|
|
4210
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { children: connections })
|
|
4211
|
+
] }, node.id);
|
|
4212
|
+
}) })
|
|
4213
|
+
] })
|
|
4214
|
+
]
|
|
4215
|
+
}
|
|
4216
|
+
);
|
|
4196
4217
|
}
|
|
4197
4218
|
function flattenNodes(children, zone) {
|
|
4198
4219
|
const result = [];
|