@glyphjs/components 0.5.1 → 0.7.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 +188 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +189 -74
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _glyphjs_types from '@glyphjs/types';
|
|
1
2
|
import { GlyphComponentProps, InlineNode, GlyphComponentDefinition, GraphNode, GraphEdge } from '@glyphjs/types';
|
|
2
3
|
import { ReactElement } from 'react';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -381,6 +382,8 @@ interface ArchitectureData {
|
|
|
381
382
|
children: ArchitectureNode[];
|
|
382
383
|
edges: ArchitectureEdge[];
|
|
383
384
|
layout?: 'top-down' | 'left-right' | 'bottom-up';
|
|
385
|
+
interactionMode?: 'modifier-key' | 'click-to-activate' | 'always';
|
|
386
|
+
showZoomControls?: boolean;
|
|
384
387
|
}
|
|
385
388
|
interface PositionedArchNode {
|
|
386
389
|
id: string;
|
|
@@ -421,7 +424,7 @@ interface ArchitectureLayout {
|
|
|
421
424
|
}
|
|
422
425
|
declare function computeArchitectureLayout(data: ArchitectureData): Promise<ArchitectureLayout>;
|
|
423
426
|
|
|
424
|
-
declare function Architecture({ data, container, }: GlyphComponentProps<ArchitectureData>): ReactElement;
|
|
427
|
+
declare function Architecture({ data, container, block, }: GlyphComponentProps<ArchitectureData>): ReactElement;
|
|
425
428
|
|
|
426
429
|
declare const architectureDefinition: GlyphComponentDefinition<ArchitectureData>;
|
|
427
430
|
|
|
@@ -745,4 +748,6 @@ declare function Annotate({ data, block, onInteraction, }: GlyphComponentProps<A
|
|
|
745
748
|
|
|
746
749
|
declare const annotateDefinition: GlyphComponentDefinition<AnnotateData>;
|
|
747
750
|
|
|
748
|
-
|
|
751
|
+
declare const allComponentDefinitions: readonly [_glyphjs_types.GlyphComponentDefinition<CalloutData>, _glyphjs_types.GlyphComponentDefinition<unknown>, _glyphjs_types.GlyphComponentDefinition<StepsData>, _glyphjs_types.GlyphComponentDefinition<TableData>, _glyphjs_types.GlyphComponentDefinition<TabsData>, _glyphjs_types.GlyphComponentDefinition<TimelineData>, _glyphjs_types.GlyphComponentDefinition<GraphData>, _glyphjs_types.GlyphComponentDefinition<RelationData>, _glyphjs_types.GlyphComponentDefinition<KpiData>, _glyphjs_types.GlyphComponentDefinition<AccordionData>, _glyphjs_types.GlyphComponentDefinition<ComparisonData>, _glyphjs_types.GlyphComponentDefinition<CodeDiffData>, _glyphjs_types.GlyphComponentDefinition<FlowchartData>, _glyphjs_types.GlyphComponentDefinition<FileTreeData>, _glyphjs_types.GlyphComponentDefinition<SequenceData>, _glyphjs_types.GlyphComponentDefinition<ArchitectureData>, _glyphjs_types.GlyphComponentDefinition<MindMapData>, _glyphjs_types.GlyphComponentDefinition<EquationData>, _glyphjs_types.GlyphComponentDefinition<QuizData>, _glyphjs_types.GlyphComponentDefinition<CardData>, _glyphjs_types.GlyphComponentDefinition<InfographicData>, _glyphjs_types.GlyphComponentDefinition<PollData>, _glyphjs_types.GlyphComponentDefinition<RatingData>, _glyphjs_types.GlyphComponentDefinition<RankerData>, _glyphjs_types.GlyphComponentDefinition<SliderData>, _glyphjs_types.GlyphComponentDefinition<MatrixData>, _glyphjs_types.GlyphComponentDefinition<FormData>, _glyphjs_types.GlyphComponentDefinition<KanbanData>, _glyphjs_types.GlyphComponentDefinition<AnnotateData>];
|
|
752
|
+
|
|
753
|
+
export { Accordion, type AccordionData, type AccordionSection, Annotate, type AnnotateData, type AnnotateLabel, type Annotation, Architecture, type ArchitectureData, type ArchitectureLayout, Callout, type CalloutData, Card, type CardAction, type CardData, type CardItem, Chart, CodeDiff, type CodeDiffData, Comparison, type ComparisonData, type ComparisonFeature, type ComparisonOption, type DiffLine, type DiffLineKind, type DividerItem, Equation, type EquationData, type EquationStep, FileTree, type FileTreeData, Flowchart, type FlowchartData, Form, type FormData, type FormField, Graph, type GraphData, Infographic, type InfographicData, type InfographicItem, type InfographicSection, Kanban, type KanbanCard, type KanbanColumn, type KanbanData, Kpi, type KpiData, type KpiMetric, type LayoutResult, Matrix, type MatrixColumn, type MatrixData, type MatrixRow, MindMap, type MindMapData, type PieItem, type PieSlice, Poll, type PollData, type PositionedArchEdge, type PositionedArchNode, type PositionedEdge, type PositionedNode, type PositionedZone, Quiz, type QuizData, type QuizQuestion, Ranker, type RankerData, type RankerItemData, Rating, type RatingData, type RatingItem$1 as RatingItem, type RatingItem as RatingScaleItem, Relation, type RelationData, Sequence, type SequenceData, Slider, type SliderData, type SliderParameter, Steps, type StepsData, Table, type TableData, Tabs, type TabsData, Timeline, type TimelineData, accordionDefinition, allComponentDefinitions, annotateDefinition, architectureDefinition, calloutDefinition, cardDefinition, chartDefinition, codeDiffDefinition, comparisonDefinition, computeArchitectureLayout, computeDagreLayout, computeDiff, computeForceLayout, equationDefinition, fileTreeDefinition, flowchartDefinition, formDefinition, graphDefinition, infographicDefinition, kanbanDefinition, kpiDefinition, matrixDefinition, mindMapDefinition, pollDefinition, quizDefinition, rankerDefinition, ratingDefinition, relationDefinition, sequenceDefinition, sliderDefinition, stepsDefinition, tableDefinition, tabsDefinition, timelineDefinition };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _glyphjs_types from '@glyphjs/types';
|
|
1
2
|
import { GlyphComponentProps, InlineNode, GlyphComponentDefinition, GraphNode, GraphEdge } from '@glyphjs/types';
|
|
2
3
|
import { ReactElement } from 'react';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -381,6 +382,8 @@ interface ArchitectureData {
|
|
|
381
382
|
children: ArchitectureNode[];
|
|
382
383
|
edges: ArchitectureEdge[];
|
|
383
384
|
layout?: 'top-down' | 'left-right' | 'bottom-up';
|
|
385
|
+
interactionMode?: 'modifier-key' | 'click-to-activate' | 'always';
|
|
386
|
+
showZoomControls?: boolean;
|
|
384
387
|
}
|
|
385
388
|
interface PositionedArchNode {
|
|
386
389
|
id: string;
|
|
@@ -421,7 +424,7 @@ interface ArchitectureLayout {
|
|
|
421
424
|
}
|
|
422
425
|
declare function computeArchitectureLayout(data: ArchitectureData): Promise<ArchitectureLayout>;
|
|
423
426
|
|
|
424
|
-
declare function Architecture({ data, container, }: GlyphComponentProps<ArchitectureData>): ReactElement;
|
|
427
|
+
declare function Architecture({ data, container, block, }: GlyphComponentProps<ArchitectureData>): ReactElement;
|
|
425
428
|
|
|
426
429
|
declare const architectureDefinition: GlyphComponentDefinition<ArchitectureData>;
|
|
427
430
|
|
|
@@ -745,4 +748,6 @@ declare function Annotate({ data, block, onInteraction, }: GlyphComponentProps<A
|
|
|
745
748
|
|
|
746
749
|
declare const annotateDefinition: GlyphComponentDefinition<AnnotateData>;
|
|
747
750
|
|
|
748
|
-
|
|
751
|
+
declare const allComponentDefinitions: readonly [_glyphjs_types.GlyphComponentDefinition<CalloutData>, _glyphjs_types.GlyphComponentDefinition<unknown>, _glyphjs_types.GlyphComponentDefinition<StepsData>, _glyphjs_types.GlyphComponentDefinition<TableData>, _glyphjs_types.GlyphComponentDefinition<TabsData>, _glyphjs_types.GlyphComponentDefinition<TimelineData>, _glyphjs_types.GlyphComponentDefinition<GraphData>, _glyphjs_types.GlyphComponentDefinition<RelationData>, _glyphjs_types.GlyphComponentDefinition<KpiData>, _glyphjs_types.GlyphComponentDefinition<AccordionData>, _glyphjs_types.GlyphComponentDefinition<ComparisonData>, _glyphjs_types.GlyphComponentDefinition<CodeDiffData>, _glyphjs_types.GlyphComponentDefinition<FlowchartData>, _glyphjs_types.GlyphComponentDefinition<FileTreeData>, _glyphjs_types.GlyphComponentDefinition<SequenceData>, _glyphjs_types.GlyphComponentDefinition<ArchitectureData>, _glyphjs_types.GlyphComponentDefinition<MindMapData>, _glyphjs_types.GlyphComponentDefinition<EquationData>, _glyphjs_types.GlyphComponentDefinition<QuizData>, _glyphjs_types.GlyphComponentDefinition<CardData>, _glyphjs_types.GlyphComponentDefinition<InfographicData>, _glyphjs_types.GlyphComponentDefinition<PollData>, _glyphjs_types.GlyphComponentDefinition<RatingData>, _glyphjs_types.GlyphComponentDefinition<RankerData>, _glyphjs_types.GlyphComponentDefinition<SliderData>, _glyphjs_types.GlyphComponentDefinition<MatrixData>, _glyphjs_types.GlyphComponentDefinition<FormData>, _glyphjs_types.GlyphComponentDefinition<KanbanData>, _glyphjs_types.GlyphComponentDefinition<AnnotateData>];
|
|
752
|
+
|
|
753
|
+
export { Accordion, type AccordionData, type AccordionSection, Annotate, type AnnotateData, type AnnotateLabel, type Annotation, Architecture, type ArchitectureData, type ArchitectureLayout, Callout, type CalloutData, Card, type CardAction, type CardData, type CardItem, Chart, CodeDiff, type CodeDiffData, Comparison, type ComparisonData, type ComparisonFeature, type ComparisonOption, type DiffLine, type DiffLineKind, type DividerItem, Equation, type EquationData, type EquationStep, FileTree, type FileTreeData, Flowchart, type FlowchartData, Form, type FormData, type FormField, Graph, type GraphData, Infographic, type InfographicData, type InfographicItem, type InfographicSection, Kanban, type KanbanCard, type KanbanColumn, type KanbanData, Kpi, type KpiData, type KpiMetric, type LayoutResult, Matrix, type MatrixColumn, type MatrixData, type MatrixRow, MindMap, type MindMapData, type PieItem, type PieSlice, Poll, type PollData, type PositionedArchEdge, type PositionedArchNode, type PositionedEdge, type PositionedNode, type PositionedZone, Quiz, type QuizData, type QuizQuestion, Ranker, type RankerData, type RankerItemData, Rating, type RatingData, type RatingItem$1 as RatingItem, type RatingItem as RatingScaleItem, Relation, type RelationData, Sequence, type SequenceData, Slider, type SliderData, type SliderParameter, Steps, type StepsData, Table, type TableData, Tabs, type TabsData, Timeline, type TimelineData, accordionDefinition, allComponentDefinitions, annotateDefinition, architectureDefinition, calloutDefinition, cardDefinition, chartDefinition, codeDiffDefinition, comparisonDefinition, computeArchitectureLayout, computeDagreLayout, computeDiff, computeForceLayout, equationDefinition, fileTreeDefinition, flowchartDefinition, formDefinition, graphDefinition, infographicDefinition, kanbanDefinition, kpiDefinition, matrixDefinition, mindMapDefinition, pollDefinition, quizDefinition, rankerDefinition, ratingDefinition, relationDefinition, sequenceDefinition, sliderDefinition, stepsDefinition, tableDefinition, tabsDefinition, timelineDefinition };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accordionSchema,
|
|
1
|
+
import { accordionSchema, calloutSchema, chartSchema, stepsSchema, tableSchema, tabsSchema, timelineSchema, graphSchema, relationSchema, kpiSchema, comparisonSchema, codediffSchema, flowchartSchema, filetreeSchema, sequenceSchema, architectureSchema, mindmapSchema, equationSchema, quizSchema, cardSchema, infographicSchema, pollSchema, ratingSchema, rankerSchema, sliderSchema, matrixSchema, formSchema, kanbanSchema, annotateSchema } from '@glyphjs/schemas';
|
|
2
2
|
import { RichText } from '@glyphjs/runtime';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
@@ -246,6 +246,22 @@ function ChartAccessibleTable({
|
|
|
246
246
|
}
|
|
247
247
|
);
|
|
248
248
|
}
|
|
249
|
+
function inferAxisKeys(series, explicitX, explicitY) {
|
|
250
|
+
if (explicitX && explicitY) return { xKey: explicitX, yKey: explicitY };
|
|
251
|
+
const sample = series[0]?.data[0];
|
|
252
|
+
if (!sample) return { xKey: explicitX ?? "x", yKey: explicitY ?? "y" };
|
|
253
|
+
let inferredX;
|
|
254
|
+
let inferredY;
|
|
255
|
+
for (const [key, value] of Object.entries(sample)) {
|
|
256
|
+
if (!inferredX && typeof value === "string") inferredX = key;
|
|
257
|
+
if (!inferredY && typeof value === "number") inferredY = key;
|
|
258
|
+
if (inferredX && inferredY) break;
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
xKey: explicitX ?? inferredX ?? "x",
|
|
262
|
+
yKey: explicitY ?? inferredY ?? "y"
|
|
263
|
+
};
|
|
264
|
+
}
|
|
249
265
|
function computeScales(width, height, type, series, xKey, yKey, margin) {
|
|
250
266
|
const innerWidth = width - margin.left - margin.right;
|
|
251
267
|
const innerHeight = height - margin.top - margin.bottom;
|
|
@@ -386,9 +402,9 @@ function Chart({
|
|
|
386
402
|
const svgRef = useRef(null);
|
|
387
403
|
const tooltipRef = useRef(null);
|
|
388
404
|
const [width, setWidth] = useState(DEFAULT_WIDTH);
|
|
405
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
389
406
|
const { type, series, xAxis, yAxis, legend } = data;
|
|
390
|
-
const xKey = xAxis?.key
|
|
391
|
-
const yKey = yAxis?.key ?? "y";
|
|
407
|
+
const { xKey, yKey } = inferAxisKeys(series, xAxis?.key, yAxis?.key);
|
|
392
408
|
const height = DEFAULT_HEIGHT;
|
|
393
409
|
const isCompact = containerCtx.tier === "compact";
|
|
394
410
|
const margin = isCompact ? {
|
|
@@ -449,6 +465,7 @@ function Chart({
|
|
|
449
465
|
if (legend) {
|
|
450
466
|
renderLegend(sel, series, margin.left, margin.top, isCompact ? "10px" : void 0);
|
|
451
467
|
}
|
|
468
|
+
setIsLoading(false);
|
|
452
469
|
}, [
|
|
453
470
|
scales,
|
|
454
471
|
type,
|
|
@@ -470,6 +487,7 @@ function Chart({
|
|
|
470
487
|
"div",
|
|
471
488
|
{
|
|
472
489
|
ref: containerRef,
|
|
490
|
+
"data-glyph-loading": isLoading || void 0,
|
|
473
491
|
style: {
|
|
474
492
|
position: "relative",
|
|
475
493
|
width: "100%",
|
|
@@ -1331,6 +1349,13 @@ var timelineDefinition = {
|
|
|
1331
1349
|
// src/utils/measureText.ts
|
|
1332
1350
|
var measurementCache = /* @__PURE__ */ new WeakMap();
|
|
1333
1351
|
function measurePlainText(text, style) {
|
|
1352
|
+
if (typeof document === "undefined") {
|
|
1353
|
+
const avgCharWidth = parseInt(style.fontSize) * 0.6;
|
|
1354
|
+
return {
|
|
1355
|
+
width: text.length * avgCharWidth,
|
|
1356
|
+
height: parseInt(style.fontSize) * 1.2
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1334
1359
|
const canvas = document.createElement("canvas");
|
|
1335
1360
|
const ctx = canvas.getContext("2d");
|
|
1336
1361
|
if (!ctx) {
|
|
@@ -1348,6 +1373,10 @@ function measurePlainText(text, style) {
|
|
|
1348
1373
|
return { width, height };
|
|
1349
1374
|
}
|
|
1350
1375
|
function measureHtmlText(content, style) {
|
|
1376
|
+
if (typeof document === "undefined") {
|
|
1377
|
+
const plainText = flattenInlineNodes(content);
|
|
1378
|
+
return measurePlainText(plainText, style);
|
|
1379
|
+
}
|
|
1351
1380
|
const cached = measurementCache.get(content);
|
|
1352
1381
|
if (cached) {
|
|
1353
1382
|
return cached;
|
|
@@ -1376,6 +1405,28 @@ function measureHtmlText(content, style) {
|
|
|
1376
1405
|
measurementCache.set(content, dimensions);
|
|
1377
1406
|
return dimensions;
|
|
1378
1407
|
}
|
|
1408
|
+
function flattenInlineNodes(nodes) {
|
|
1409
|
+
return nodes.map((node) => {
|
|
1410
|
+
switch (node.type) {
|
|
1411
|
+
case "text":
|
|
1412
|
+
return node.value;
|
|
1413
|
+
case "inlineCode":
|
|
1414
|
+
return node.value;
|
|
1415
|
+
case "strong":
|
|
1416
|
+
case "emphasis":
|
|
1417
|
+
case "delete":
|
|
1418
|
+
return flattenInlineNodes(node.children);
|
|
1419
|
+
case "link":
|
|
1420
|
+
return flattenInlineNodes(node.children);
|
|
1421
|
+
case "image":
|
|
1422
|
+
return node.alt ?? "";
|
|
1423
|
+
case "break":
|
|
1424
|
+
return "\n";
|
|
1425
|
+
default:
|
|
1426
|
+
return "";
|
|
1427
|
+
}
|
|
1428
|
+
}).join("");
|
|
1429
|
+
}
|
|
1379
1430
|
function inlineNodesToHtml(nodes) {
|
|
1380
1431
|
return nodes.map((node) => {
|
|
1381
1432
|
switch (node.type) {
|
|
@@ -1401,6 +1452,9 @@ function inlineNodesToHtml(nodes) {
|
|
|
1401
1452
|
}).join("");
|
|
1402
1453
|
}
|
|
1403
1454
|
function escapeHtml(str) {
|
|
1455
|
+
if (typeof document === "undefined") {
|
|
1456
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1457
|
+
}
|
|
1404
1458
|
const div = document.createElement("div");
|
|
1405
1459
|
div.textContent = str;
|
|
1406
1460
|
return div.innerHTML;
|
|
@@ -1607,16 +1661,16 @@ function useZoomInteraction({
|
|
|
1607
1661
|
};
|
|
1608
1662
|
}, [interactionMode, svgRef]);
|
|
1609
1663
|
const zoomBehavior = useMemo(() => {
|
|
1610
|
-
const
|
|
1611
|
-
if (typeof
|
|
1612
|
-
|
|
1664
|
+
const zoom2 = d32.zoom().scaleExtent([0.1, 4]);
|
|
1665
|
+
if (typeof zoom2.filter === "function") {
|
|
1666
|
+
zoom2.filter(filterFunction);
|
|
1613
1667
|
}
|
|
1614
|
-
|
|
1668
|
+
zoom2.on("zoom", (event) => {
|
|
1615
1669
|
if (rootRef.current) {
|
|
1616
1670
|
d32.select(rootRef.current).attr("transform", event.transform.toString());
|
|
1617
1671
|
}
|
|
1618
1672
|
});
|
|
1619
|
-
return
|
|
1673
|
+
return zoom2;
|
|
1620
1674
|
}, [filterFunction, rootRef]);
|
|
1621
1675
|
const handleActivate = useCallback(() => {
|
|
1622
1676
|
if (interactionMode === "click-to-activate") {
|
|
@@ -1989,6 +2043,7 @@ function Graph({
|
|
|
1989
2043
|
const svgRef = useRef(null);
|
|
1990
2044
|
const rootRef = useRef(null);
|
|
1991
2045
|
const groupIndex = useRef(/* @__PURE__ */ new Map());
|
|
2046
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1992
2047
|
const layoutResult = useMemo(() => {
|
|
1993
2048
|
const direction = resolveLayout(data);
|
|
1994
2049
|
if (direction === "force") {
|
|
@@ -2029,9 +2084,10 @@ function Graph({
|
|
|
2029
2084
|
if (rootElement) {
|
|
2030
2085
|
rootRef.current = rootElement;
|
|
2031
2086
|
}
|
|
2087
|
+
setIsLoading(false);
|
|
2032
2088
|
}, [layoutResult, outgoingRefs, onNavigate, zoomBehavior, handleNodeClick]);
|
|
2033
2089
|
const ariaLabel = `${data.type} graph with ${data.nodes.length} nodes and ${data.edges.length} edges`;
|
|
2034
|
-
return /* @__PURE__ */ jsxs("div", { className: "glyph-graph-container", children: [
|
|
2090
|
+
return /* @__PURE__ */ jsxs("div", { className: "glyph-graph-container", "data-glyph-loading": isLoading || void 0, children: [
|
|
2035
2091
|
/* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
2036
2092
|
/* @__PURE__ */ jsx(
|
|
2037
2093
|
"svg",
|
|
@@ -3774,7 +3830,7 @@ var DIRECTION_MAP = {
|
|
|
3774
3830
|
"bottom-up": "UP"
|
|
3775
3831
|
};
|
|
3776
3832
|
function buildElkNode(node) {
|
|
3777
|
-
if (node.
|
|
3833
|
+
if (node.children?.length) {
|
|
3778
3834
|
return {
|
|
3779
3835
|
id: node.id,
|
|
3780
3836
|
labels: [{ text: node.label }],
|
|
@@ -3818,7 +3874,7 @@ function collectNodes(elkNode, nodeMap, offsetX, offsetY, nodes, zones, depth, z
|
|
|
3818
3874
|
const absX = offsetX + (elkNode.x ?? 0);
|
|
3819
3875
|
const absY = offsetY + (elkNode.y ?? 0);
|
|
3820
3876
|
const original = nodeMap.get(elkNode.id);
|
|
3821
|
-
if (original?.
|
|
3877
|
+
if (original?.children?.length && elkNode.children?.length) {
|
|
3822
3878
|
zones.push({
|
|
3823
3879
|
id: elkNode.id,
|
|
3824
3880
|
label: original.label,
|
|
@@ -3855,7 +3911,7 @@ function flattenNodeMap(children, map) {
|
|
|
3855
3911
|
function buildAncestorMap(children, ancestors, map) {
|
|
3856
3912
|
for (const node of children) {
|
|
3857
3913
|
map.set(node.id, [...ancestors]);
|
|
3858
|
-
if (node.
|
|
3914
|
+
if (node.children?.length) {
|
|
3859
3915
|
buildAncestorMap(node.children, [...ancestors, node.id], map);
|
|
3860
3916
|
}
|
|
3861
3917
|
}
|
|
@@ -4013,7 +4069,7 @@ function getThemeVar3(container, varName, fallback) {
|
|
|
4013
4069
|
return getComputedStyle(container).getPropertyValue(varName).trim() || fallback;
|
|
4014
4070
|
}
|
|
4015
4071
|
var ARROW_MARKER_ID3 = "glyph-arch-arrowhead";
|
|
4016
|
-
function renderArchitecture(svgElement, layout) {
|
|
4072
|
+
function renderArchitecture(svgElement, layout, rootRef, zoomBehavior) {
|
|
4017
4073
|
const svg = d32.select(svgElement);
|
|
4018
4074
|
svg.selectAll("*").remove();
|
|
4019
4075
|
const width = Math.max(layout.width, 200);
|
|
@@ -4026,10 +4082,12 @@ function renderArchitecture(svgElement, layout) {
|
|
|
4026
4082
|
const nodeStrokeWidth = getThemeVar3(container, "--glyph-node-stroke-width", "1.5");
|
|
4027
4083
|
const nodeFillOpacity = getThemeVar3(container, "--glyph-node-fill-opacity", "0.85");
|
|
4028
4084
|
const root = svg.append("g").attr("class", "glyph-architecture-root");
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
}
|
|
4032
|
-
|
|
4085
|
+
if (rootRef) {
|
|
4086
|
+
rootRef.current = root.node();
|
|
4087
|
+
}
|
|
4088
|
+
if (zoomBehavior) {
|
|
4089
|
+
svg.call(zoomBehavior);
|
|
4090
|
+
}
|
|
4033
4091
|
const sortedZones = [...layout.zones].sort((a, b) => a.depth - b.depth);
|
|
4034
4092
|
const zoneGroup = root.append("g").attr("class", "glyph-architecture-zones");
|
|
4035
4093
|
for (const zone of sortedZones) {
|
|
@@ -4097,10 +4155,19 @@ function renderArchitecture(svgElement, layout) {
|
|
|
4097
4155
|
}
|
|
4098
4156
|
function Architecture({
|
|
4099
4157
|
data,
|
|
4100
|
-
container
|
|
4158
|
+
container,
|
|
4159
|
+
block
|
|
4101
4160
|
}) {
|
|
4102
4161
|
const svgRef = useRef(null);
|
|
4162
|
+
const rootRef = useRef(null);
|
|
4163
|
+
const containerRef = useRef(null);
|
|
4103
4164
|
const [layout, setLayout] = useState(null);
|
|
4165
|
+
const { overlayProps, zoomBehavior, zoomIn, zoomOut, resetZoom } = useZoomInteraction({
|
|
4166
|
+
svgRef,
|
|
4167
|
+
rootRef,
|
|
4168
|
+
interactionMode: data.interactionMode ?? "modifier-key",
|
|
4169
|
+
blockId: block.id
|
|
4170
|
+
});
|
|
4104
4171
|
useEffect(() => {
|
|
4105
4172
|
let cancelled = false;
|
|
4106
4173
|
computeArchitectureLayout(data).then((result) => {
|
|
@@ -4112,67 +4179,78 @@ function Architecture({
|
|
|
4112
4179
|
}, [data]);
|
|
4113
4180
|
useEffect(() => {
|
|
4114
4181
|
if (!svgRef.current || !layout) return;
|
|
4115
|
-
renderArchitecture(svgRef.current, layout);
|
|
4116
|
-
}, [layout]);
|
|
4182
|
+
renderArchitecture(svgRef.current, layout, rootRef, zoomBehavior);
|
|
4183
|
+
}, [layout, zoomBehavior]);
|
|
4117
4184
|
const nodeCount = countLeafNodes(data.children);
|
|
4118
4185
|
const edgeCount = data.edges.length;
|
|
4119
4186
|
const ariaLabel = data.title ? `${data.title}: architecture diagram with ${nodeCount} nodes and ${edgeCount} connections` : `Architecture diagram with ${nodeCount} nodes and ${edgeCount} connections`;
|
|
4120
4187
|
const flatNodes = flattenNodes(data.children);
|
|
4121
|
-
return /* @__PURE__ */ jsxs(
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
/* @__PURE__ */ jsx("
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4188
|
+
return /* @__PURE__ */ jsxs(
|
|
4189
|
+
"div",
|
|
4190
|
+
{
|
|
4191
|
+
ref: containerRef,
|
|
4192
|
+
className: "glyph-architecture-container",
|
|
4193
|
+
"data-glyph-loading": !layout || void 0,
|
|
4194
|
+
style: { position: "relative" },
|
|
4195
|
+
children: [
|
|
4196
|
+
!layout && /* @__PURE__ */ jsx(
|
|
4197
|
+
"div",
|
|
4198
|
+
{
|
|
4199
|
+
style: {
|
|
4200
|
+
padding: "2rem",
|
|
4201
|
+
textAlign: "center",
|
|
4202
|
+
color: "var(--glyph-text-muted, #7a8599)",
|
|
4203
|
+
fontFamily: "Inter, system-ui, sans-serif",
|
|
4204
|
+
fontSize: "13px"
|
|
4205
|
+
},
|
|
4206
|
+
children: "Computing layout..."
|
|
4207
|
+
}
|
|
4208
|
+
),
|
|
4209
|
+
/* @__PURE__ */ jsx(
|
|
4210
|
+
"svg",
|
|
4211
|
+
{
|
|
4212
|
+
ref: svgRef,
|
|
4213
|
+
role: "img",
|
|
4214
|
+
"aria-label": ariaLabel,
|
|
4215
|
+
width: "100%",
|
|
4216
|
+
height: "100%",
|
|
4217
|
+
style: {
|
|
4218
|
+
minHeight: container.tier === "compact" ? 200 : 300,
|
|
4219
|
+
maxHeight: container.tier === "compact" ? 500 : 700,
|
|
4220
|
+
display: layout ? "block" : "none"
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
),
|
|
4224
|
+
layout && overlayProps && /* @__PURE__ */ jsx(InteractionOverlay, { ...overlayProps }),
|
|
4225
|
+
layout && data.showZoomControls !== false && /* @__PURE__ */ jsx(ZoomControls, { onZoomIn: zoomIn, onZoomOut: zoomOut, onReset: resetZoom }),
|
|
4226
|
+
/* @__PURE__ */ jsxs("table", { className: "sr-only", "aria-label": "Architecture data", style: SR_ONLY_STYLE6, children: [
|
|
4227
|
+
/* @__PURE__ */ jsx("caption", { children: "Architecture nodes and connections" }),
|
|
4228
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4229
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: "Node" }),
|
|
4230
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: "Zone" }),
|
|
4231
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: "Connections" })
|
|
4232
|
+
] }) }),
|
|
4233
|
+
/* @__PURE__ */ jsx("tbody", { children: flatNodes.map((node) => {
|
|
4234
|
+
const connections = data.edges.filter((e) => e.from === node.id || e.to === node.id).map((e) => {
|
|
4235
|
+
const target = e.from === node.id ? e.to : e.from;
|
|
4236
|
+
const dir = e.from === node.id ? "->" : "<-";
|
|
4237
|
+
return `${dir} ${target}${e.label ? ` (${e.label})` : ""}`;
|
|
4238
|
+
}).join(", ");
|
|
4239
|
+
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
4240
|
+
/* @__PURE__ */ jsx("td", { children: node.label }),
|
|
4241
|
+
/* @__PURE__ */ jsx("td", { children: node.zone ?? "" }),
|
|
4242
|
+
/* @__PURE__ */ jsx("td", { children: connections })
|
|
4243
|
+
] }, node.id);
|
|
4244
|
+
}) })
|
|
4245
|
+
] })
|
|
4246
|
+
]
|
|
4247
|
+
}
|
|
4248
|
+
);
|
|
4171
4249
|
}
|
|
4172
4250
|
function flattenNodes(children, zone) {
|
|
4173
4251
|
const result = [];
|
|
4174
4252
|
for (const child of children) {
|
|
4175
|
-
if (child.
|
|
4253
|
+
if (child.children?.length) {
|
|
4176
4254
|
result.push(...flattenNodes(child.children, child.label));
|
|
4177
4255
|
} else {
|
|
4178
4256
|
result.push({ id: child.id, label: child.label, zone });
|
|
@@ -4183,7 +4261,7 @@ function flattenNodes(children, zone) {
|
|
|
4183
4261
|
function countLeafNodes(children) {
|
|
4184
4262
|
let count = 0;
|
|
4185
4263
|
for (const child of children) {
|
|
4186
|
-
if (child.
|
|
4264
|
+
if (child.children?.length) {
|
|
4187
4265
|
count += countLeafNodes(child.children);
|
|
4188
4266
|
} else {
|
|
4189
4267
|
count++;
|
|
@@ -5504,6 +5582,10 @@ function renderRatingGroup(items, keyPrefix) {
|
|
|
5504
5582
|
);
|
|
5505
5583
|
}) }, keyPrefix);
|
|
5506
5584
|
}
|
|
5585
|
+
function cssEscape(value) {
|
|
5586
|
+
if (typeof CSS !== "undefined" && CSS.escape) return CSS.escape(value);
|
|
5587
|
+
return value.replace(/([^\w-])/g, "\\$1");
|
|
5588
|
+
}
|
|
5507
5589
|
function Infographic({
|
|
5508
5590
|
data,
|
|
5509
5591
|
block,
|
|
@@ -5556,7 +5638,7 @@ function Infographic({
|
|
|
5556
5638
|
borderLeft: "3px solid var(--glyph-infographic-accent, #3b82f6)",
|
|
5557
5639
|
paddingLeft: "var(--glyph-spacing-sm, 0.5rem)"
|
|
5558
5640
|
};
|
|
5559
|
-
const printCss = useGrid ? `@media print { #${
|
|
5641
|
+
const printCss = useGrid ? `@media print { #${cssEscape(baseId)} [data-layout="grid"] { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 0.5rem !important; } #${cssEscape(baseId)} [data-layout="grid"] > div { break-inside: avoid; } }` : "";
|
|
5560
5642
|
let progressColorOffset = 0;
|
|
5561
5643
|
return /* @__PURE__ */ jsxs("div", { id: baseId, role: "region", "aria-label": title ?? "Infographic", style: containerStyle11, children: [
|
|
5562
5644
|
printCss && /* @__PURE__ */ jsx("style", { children: printCss }),
|
|
@@ -7362,6 +7444,39 @@ var annotateDefinition = {
|
|
|
7362
7444
|
render: Annotate
|
|
7363
7445
|
};
|
|
7364
7446
|
|
|
7365
|
-
|
|
7447
|
+
// src/index.ts
|
|
7448
|
+
var allComponentDefinitions = [
|
|
7449
|
+
calloutDefinition,
|
|
7450
|
+
chartDefinition,
|
|
7451
|
+
stepsDefinition,
|
|
7452
|
+
tableDefinition,
|
|
7453
|
+
tabsDefinition,
|
|
7454
|
+
timelineDefinition,
|
|
7455
|
+
graphDefinition,
|
|
7456
|
+
relationDefinition,
|
|
7457
|
+
kpiDefinition,
|
|
7458
|
+
accordionDefinition,
|
|
7459
|
+
comparisonDefinition,
|
|
7460
|
+
codeDiffDefinition,
|
|
7461
|
+
flowchartDefinition,
|
|
7462
|
+
fileTreeDefinition,
|
|
7463
|
+
sequenceDefinition,
|
|
7464
|
+
architectureDefinition,
|
|
7465
|
+
mindMapDefinition,
|
|
7466
|
+
equationDefinition,
|
|
7467
|
+
quizDefinition,
|
|
7468
|
+
cardDefinition,
|
|
7469
|
+
infographicDefinition,
|
|
7470
|
+
pollDefinition,
|
|
7471
|
+
ratingDefinition,
|
|
7472
|
+
rankerDefinition,
|
|
7473
|
+
sliderDefinition,
|
|
7474
|
+
matrixDefinition,
|
|
7475
|
+
formDefinition,
|
|
7476
|
+
kanbanDefinition,
|
|
7477
|
+
annotateDefinition
|
|
7478
|
+
];
|
|
7479
|
+
|
|
7480
|
+
export { Accordion, Annotate, Architecture, Callout, Card, Chart, CodeDiff, Comparison, Equation, FileTree, Flowchart, Form, Graph, Infographic, Kanban, Kpi, Matrix, MindMap, Poll, Quiz, Ranker, Rating, Relation, Sequence, Slider, Steps, Table, Tabs, Timeline, accordionDefinition, allComponentDefinitions, annotateDefinition, architectureDefinition, calloutDefinition, cardDefinition, chartDefinition, codeDiffDefinition, comparisonDefinition, computeArchitectureLayout, computeDagreLayout, computeDiff, computeForceLayout, equationDefinition, fileTreeDefinition, flowchartDefinition, formDefinition, graphDefinition, infographicDefinition, kanbanDefinition, kpiDefinition, matrixDefinition, mindMapDefinition, pollDefinition, quizDefinition, rankerDefinition, ratingDefinition, relationDefinition, sequenceDefinition, sliderDefinition, stepsDefinition, tableDefinition, tabsDefinition, timelineDefinition };
|
|
7366
7481
|
//# sourceMappingURL=index.js.map
|
|
7367
7482
|
//# sourceMappingURL=index.js.map
|