@diagrammo/dgmo 0.8.9 → 0.8.10

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.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { EChartsOption } from 'echarts';
2
+ import { Selection } from 'd3-selection';
2
3
  import * as d3Scale from 'd3-scale';
3
4
 
4
5
  type DgmoSeverity = 'error' | 'warning';
@@ -39,6 +40,11 @@ declare function render(content: string, options?: {
39
40
  c4System?: string;
40
41
  c4Container?: string;
41
42
  tagGroup?: string;
43
+ /** Legend state for export — controls which tag group is shown in exported SVG. */
44
+ legendState?: {
45
+ activeGroup?: string;
46
+ hiddenAttributes?: string[];
47
+ };
42
48
  }): Promise<string>;
43
49
 
44
50
  /**
@@ -283,6 +289,134 @@ declare function parseDataRowValues(line: string, options?: {
283
289
  values: number[];
284
290
  } | null;
285
291
 
292
+ interface LegendState {
293
+ activeGroup: string | null;
294
+ hiddenAttributes?: Set<string>;
295
+ }
296
+ interface LegendCallbacks {
297
+ onGroupToggle?: (groupName: string) => void;
298
+ onVisibilityToggle?: (attribute: string) => void;
299
+ onStateChange?: (newState: LegendState) => void;
300
+ /** Called when an entry is hovered. Chart renderers can use this for cross-element highlighting. */
301
+ onEntryHover?: (groupName: string, entryValue: string | null) => void;
302
+ /** Called after each group <g> is rendered — lets chart renderers inject custom elements (swimlane icons, etc.) */
303
+ onGroupRendered?: (groupName: string, groupEl: D3Sel, isActive: boolean) => void;
304
+ }
305
+ interface LegendPosition {
306
+ placement: 'top-center';
307
+ titleRelation: 'below-title' | 'inline-with-title';
308
+ }
309
+ type LegendMode = 'fixed' | 'inline';
310
+ type LegendControlExportBehavior = 'include' | 'strip' | 'static';
311
+ interface LegendControl {
312
+ id: string;
313
+ /** SVG markup for the control icon, or a string label */
314
+ icon: string;
315
+ label?: string;
316
+ exportBehavior: LegendControlExportBehavior;
317
+ onClick?: () => void;
318
+ children?: LegendControlEntry[];
319
+ }
320
+ interface LegendControlEntry {
321
+ id: string;
322
+ label: string;
323
+ isActive?: boolean;
324
+ onClick?: () => void;
325
+ }
326
+ interface LegendConfig {
327
+ groups: LegendGroupData[];
328
+ position: LegendPosition;
329
+ controls?: LegendControl[];
330
+ mode: LegendMode;
331
+ /** Title width in pixels — used for inline-with-title computation */
332
+ titleWidth?: number;
333
+ /** Extra width (px) reserved after the pill inside an active capsule (e.g. for eye icon addon). Entries start after this offset. */
334
+ capsulePillAddonWidth?: number;
335
+ /** When true, groups with no entries are still rendered as collapsed pills. Default: false (empty groups hidden). */
336
+ showEmptyGroups?: boolean;
337
+ }
338
+ interface LegendPalette {
339
+ bg: string;
340
+ surface: string;
341
+ text: string;
342
+ textMuted: string;
343
+ primary?: string;
344
+ }
345
+ interface LegendPillLayout {
346
+ groupName: string;
347
+ x: number;
348
+ y: number;
349
+ width: number;
350
+ height: number;
351
+ isActive: boolean;
352
+ }
353
+ interface LegendEntryLayout {
354
+ value: string;
355
+ color: string;
356
+ x: number;
357
+ y: number;
358
+ dotCx: number;
359
+ dotCy: number;
360
+ textX: number;
361
+ textY: number;
362
+ }
363
+ interface LegendCapsuleLayout {
364
+ groupName: string;
365
+ x: number;
366
+ y: number;
367
+ width: number;
368
+ height: number;
369
+ pill: LegendPillLayout;
370
+ entries: LegendEntryLayout[];
371
+ /** Overflow indicator when entries exceed max rows */
372
+ moreCount?: number;
373
+ /** X offset where addon content (e.g. eye icon) can be placed — after pill, before entries */
374
+ addonX?: number;
375
+ }
376
+ interface LegendControlLayout {
377
+ id: string;
378
+ x: number;
379
+ y: number;
380
+ width: number;
381
+ height: number;
382
+ icon: string;
383
+ label?: string;
384
+ exportBehavior: LegendControlExportBehavior;
385
+ children?: Array<{
386
+ id: string;
387
+ label: string;
388
+ x: number;
389
+ y: number;
390
+ width: number;
391
+ isActive?: boolean;
392
+ }>;
393
+ }
394
+ interface LegendRowLayout {
395
+ y: number;
396
+ items: Array<LegendPillLayout | LegendCapsuleLayout | LegendControlLayout>;
397
+ }
398
+ interface LegendLayout {
399
+ /** Total computed height including all rows */
400
+ height: number;
401
+ /** Total computed width */
402
+ width: number;
403
+ /** Rows of legend elements (pills wrap to new rows on overflow) */
404
+ rows: LegendRowLayout[];
405
+ /** Active capsule layout (if any group is active) */
406
+ activeCapsule?: LegendCapsuleLayout;
407
+ /** Control layouts (right-aligned) */
408
+ controls: LegendControlLayout[];
409
+ /** All pill layouts (collapsed groups) */
410
+ pills: LegendPillLayout[];
411
+ }
412
+ interface LegendHandle {
413
+ setState: (state: LegendState) => void;
414
+ destroy: () => void;
415
+ getHeight: () => number;
416
+ getLayout: () => LegendLayout;
417
+ }
418
+ type D3Sel = Selection<any, unknown, any, unknown>;
419
+
286
420
  interface LegendGroupData {
287
421
  name: string;
288
422
  entries: Array<{
@@ -313,6 +447,9 @@ interface LegendRenderResult {
313
447
  width: number;
314
448
  }
315
449
  declare function renderLegendSvg(groups: LegendGroupData[], options: LegendRenderOptions): LegendRenderResult;
450
+ declare function renderLegendSvgFromConfig(config: LegendConfig, state: LegendState, palette: LegendPalette & {
451
+ isDark: boolean;
452
+ }, containerWidth: number): LegendRenderResult;
316
453
 
317
454
  type ExtendedChartType = 'sankey' | 'chord' | 'function' | 'scatter' | 'heatmap' | 'funnel';
318
455
  interface ExtendedChartDataPoint {
@@ -1568,6 +1705,8 @@ interface BLLayoutEdge {
1568
1705
  yOffset: number;
1569
1706
  parallelCount: number;
1570
1707
  metadata: Record<string, string>;
1708
+ /** True for edges deferred from dagre (group endpoints) — use linear curve */
1709
+ deferred?: boolean;
1571
1710
  }
1572
1711
  interface BLLayoutGroup {
1573
1712
  label: string;
@@ -1694,6 +1833,8 @@ interface SitemapLayoutEdge {
1694
1833
  label?: string;
1695
1834
  color?: string;
1696
1835
  lineNumber: number;
1836
+ /** True for edges deferred from dagre (container endpoints) — use linear curve */
1837
+ deferred?: boolean;
1697
1838
  }
1698
1839
  interface SitemapContainerBounds {
1699
1840
  nodeId: string;
@@ -2277,6 +2418,11 @@ declare function renderFlowchartForExport(content: string, theme: 'light' | 'dar
2277
2418
 
2278
2419
  declare const LEGEND_HEIGHT = 28;
2279
2420
 
2421
+ declare function renderLegendD3(container: D3Sel, config: LegendConfig, state: LegendState, palette: LegendPalette, isDark: boolean, callbacks?: LegendCallbacks, containerWidth?: number): LegendHandle;
2422
+
2423
+ declare function computeLegendLayout(config: LegendConfig, state: LegendState, containerWidth: number): LegendLayout;
2424
+ declare function getLegendReservedHeight(config: LegendConfig, state: LegendState, containerWidth: number): number;
2425
+
2280
2426
  interface SectionMessageGroup {
2281
2427
  section: SequenceSection;
2282
2428
  messageIndices: number[];
@@ -2446,4 +2592,4 @@ declare function parseFirstLine(line: string): {
2446
2592
  */
2447
2593
  declare function injectBranding(svgHtml: string, mutedColor: string): string;
2448
2594
 
2449
- export { ALL_CHART_TYPES, type Activation, type ArcLink, type ArcNodeGroup, type BLCollapseResult, type BLEdge, type BLGroup, type BLLayoutEdge, type BLLayoutGroup, type BLLayoutNode, type BLLayoutResult, type BLNode, type C4ArrowType, type C4DeploymentNode, type C4Element, type C4ElementType, type C4Group, type C4LayoutBoundary, type C4LayoutEdge, type C4LayoutNode, type C4LayoutResult, type C4LegendEntry, type C4LegendGroup, type C4Relationship, type C4Shape, type C4TagEntry, type C4TagGroup, CHART_TYPES, COMPLETION_REGISTRY, type ChartDataPoint, type ChartEra, type ChartType$1 as ChartType, type ClassLayoutEdge, type ClassLayoutNode, type ClassLayoutResult, type ClassMember, type ClassModifier, type ClassNode, type ClassRelationship, type CollapsedOrgResult, type CollapsedSitemapResult, type ComputedInfraEdge, type ComputedInfraModel, type ComputedInfraNode, type ContextRelationship, type D3ExportDimensions, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type DiagramSymbols, type DiagramViewState, type DirectiveSpec, type DirectiveValueSpec, type Duration, type DurationUnit, ENTITY_TYPES, type ERCardinality, type ERColumn, type ERConstraint, type ERLayoutEdge, type ERLayoutNode, type ERLayoutResult, type ERRelationship, type ERTable, type ElseIfBranch, type EncodeDiagramUrlOptions, type EncodeDiagramUrlResult, type ExtendedChartType, type ExtractFn, type GanttDependency, type GanttEra, type GanttGroup, type GroupRow as GanttGroupRow, type GanttHolidays, type GanttInteractiveOptions, type LaneHeaderRow as GanttLaneHeaderRow, type GanttMarker, type GanttNode, type GanttOptions, type GanttParallelBlock, type Row as GanttRow, type GanttTask, type TaskRow as GanttTaskRow, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, INFRA_BEHAVIOR_KEYS, type ImportSource, type InfraAvailabilityPercentiles, type InfraBehaviorKey, type InfraCbState, type InfraComputeParams, type InfraDiagnostic, type InfraEdge, type InfraGroup, type InfraLatencyPercentiles, type InfraLayoutEdge, type InfraLayoutGroup, type InfraLayoutNode, type InfraLayoutResult, type InfraLegendGroup, type InfraNode, type InfraPlaybackState, type InfraProperty, type InfraRole, type InfraTagGroup, type InlineSpan, type KanbanCard, type KanbanColumn, type KanbanTagEntry, type KanbanTagGroup, LEGEND_HEIGHT, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type LegendGroupData, METADATA_KEY_SET, type MemberVisibility, type OrgContainerBounds, type OrgLayoutEdge, type OrgLayoutNode, type OrgLayoutResult, type OrgNode, PIPE_METADATA, type PaletteColors, type PaletteConfig, type ParsedBoxesAndLines, type ParsedC4, type ParsedChart, type ParsedClassDiagram, type ParsedERDiagram, type ParsedExtendedChart, type ParsedGantt, type ParsedGraph, type ParsedInfra, type ParsedKanban, type ParsedOrg, type ParsedQuadrant, type ParsedSequenceDgmo, type ParsedSitemap, type ParsedVisualization, type ParticipantType, type PipeKeySpec, RULE_COUNT, type ReadFileFn, type RelationshipType, type RenderCategory, type RenderStep, type ResolveImportsResult, type ResolvedGroup, type ResolvedSchedule, type ResolvedTask, type ScatterLabelPoint, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, type SitemapContainerBounds, type SitemapDirection, type SitemapEdge, type SitemapLayoutEdge, type SitemapLayoutNode, type SitemapLayoutResult, type SitemapLegendEntry, type SitemapLegendGroup, type SitemapNode, type TagEntry, type TagGroup, type VisualizationType, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildExtendedChartOption, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildSimpleChartOption, buildTagLaneRowList, buildThemeCSS, calculateSchedule, catppuccinPalette, collapseBoxesAndLines, collapseOrgTree, collapseSitemapTree, collectDiagramRoles, collectTasks, colorNames, computeActivations, computeCardArchive, computeCardMove, computeInfra, computeInfraLegendGroups, computeScatterLabelGraphics, computeTimeTicks, contrastText, decodeDiagramUrl, encodeDiagramUrl, extractDiagramSymbols, extractTagDeclarations, formatDateLabel, formatDgmoError, getAvailablePalettes, getExtendedChartLegendGroups, getPalette, getRenderCategory, getSeriesColors, getSimpleChartLegendGroups, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, inferRoles, injectBranding, isArchiveColumn, isExtendedChartType, isSequenceBlock, isSequenceNote, isValidHex, layoutBoxesAndLines, layoutC4Components, layoutC4Containers, layoutC4Context, layoutC4Deployment, layoutClassDiagram, layoutERDiagram, layoutGraph, layoutInfra, layoutOrg, layoutSitemap, looksLikeClassDiagram, looksLikeERDiagram, looksLikeFlowchart, looksLikeSequence, looksLikeSitemap, looksLikeState, makeDgmoError, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseAndLayoutInfra, parseBoxesAndLines, parseC4, parseChart, parseClassDiagram, parseDataRowValues, parseDgmo, parseDgmoChartType, parseERDiagram, parseExtendedChart, parseFirstLine, parseFlowchart, parseGantt, parseInfra, parseInlineMarkdown, parseKanban, parseOrg, parseQuadrant, parseSequenceDgmo, parseSitemap, parseState, parseTimelineDate, parseVisualization, registerExtractor, registerPalette, render, renderArcDiagram, renderBoxesAndLines, renderBoxesAndLinesForExport, renderC4ComponentsForExport, renderC4Containers, renderC4ContainersForExport, renderC4Context, renderC4ContextForExport, renderC4Deployment, renderC4DeploymentForExport, renderClassDiagram, renderClassDiagramForExport, renderERDiagram, renderERDiagramForExport, renderExtendedChartForExport, renderFlowchart, renderFlowchartForExport, renderForExport, renderGantt, renderInfra, renderKanban, renderKanbanForExport, renderLegendSvg, renderOrg, renderOrgForExport, renderQuadrant, renderSequenceDiagram, renderSitemap, renderSitemapForExport, renderSlopeChart, renderState, renderStateForExport, renderTimeline, renderVenn, renderWordCloud, resolveColor, resolveOrgImports, resolveTaskName, rollUpContextRelationships, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette, truncateBareUrl, validateComputed, validateInfra };
2595
+ export { ALL_CHART_TYPES, type Activation, type ArcLink, type ArcNodeGroup, type BLCollapseResult, type BLEdge, type BLGroup, type BLLayoutEdge, type BLLayoutGroup, type BLLayoutNode, type BLLayoutResult, type BLNode, type C4ArrowType, type C4DeploymentNode, type C4Element, type C4ElementType, type C4Group, type C4LayoutBoundary, type C4LayoutEdge, type C4LayoutNode, type C4LayoutResult, type C4LegendEntry, type C4LegendGroup, type C4Relationship, type C4Shape, type C4TagEntry, type C4TagGroup, CHART_TYPES, COMPLETION_REGISTRY, type ChartDataPoint, type ChartEra, type ChartType$1 as ChartType, type ClassLayoutEdge, type ClassLayoutNode, type ClassLayoutResult, type ClassMember, type ClassModifier, type ClassNode, type ClassRelationship, type CollapsedOrgResult, type CollapsedSitemapResult, type ComputedInfraEdge, type ComputedInfraModel, type ComputedInfraNode, type ContextRelationship, type D3ExportDimensions, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type DiagramSymbols, type DiagramViewState, type DirectiveSpec, type DirectiveValueSpec, type Duration, type DurationUnit, ENTITY_TYPES, type ERCardinality, type ERColumn, type ERConstraint, type ERLayoutEdge, type ERLayoutNode, type ERLayoutResult, type ERRelationship, type ERTable, type ElseIfBranch, type EncodeDiagramUrlOptions, type EncodeDiagramUrlResult, type ExtendedChartType, type ExtractFn, type GanttDependency, type GanttEra, type GanttGroup, type GroupRow as GanttGroupRow, type GanttHolidays, type GanttInteractiveOptions, type LaneHeaderRow as GanttLaneHeaderRow, type GanttMarker, type GanttNode, type GanttOptions, type GanttParallelBlock, type Row as GanttRow, type GanttTask, type TaskRow as GanttTaskRow, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, INFRA_BEHAVIOR_KEYS, type ImportSource, type InfraAvailabilityPercentiles, type InfraBehaviorKey, type InfraCbState, type InfraComputeParams, type InfraDiagnostic, type InfraEdge, type InfraGroup, type InfraLatencyPercentiles, type InfraLayoutEdge, type InfraLayoutGroup, type InfraLayoutNode, type InfraLayoutResult, type InfraLegendGroup, type InfraNode, type InfraPlaybackState, type InfraProperty, type InfraRole, type InfraTagGroup, type InlineSpan, type KanbanCard, type KanbanColumn, type KanbanTagEntry, type KanbanTagGroup, LEGEND_HEIGHT, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type LegendCallbacks, type LegendConfig, type LegendControl, type LegendGroupData, type LegendHandle, type LegendLayout, type LegendMode, type LegendPalette, type LegendPosition, type LegendState, METADATA_KEY_SET, type MemberVisibility, type OrgContainerBounds, type OrgLayoutEdge, type OrgLayoutNode, type OrgLayoutResult, type OrgNode, PIPE_METADATA, type PaletteColors, type PaletteConfig, type ParsedBoxesAndLines, type ParsedC4, type ParsedChart, type ParsedClassDiagram, type ParsedERDiagram, type ParsedExtendedChart, type ParsedGantt, type ParsedGraph, type ParsedInfra, type ParsedKanban, type ParsedOrg, type ParsedQuadrant, type ParsedSequenceDgmo, type ParsedSitemap, type ParsedVisualization, type ParticipantType, type PipeKeySpec, RULE_COUNT, type ReadFileFn, type RelationshipType, type RenderCategory, type RenderStep, type ResolveImportsResult, type ResolvedGroup, type ResolvedSchedule, type ResolvedTask, type ScatterLabelPoint, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, type SitemapContainerBounds, type SitemapDirection, type SitemapEdge, type SitemapLayoutEdge, type SitemapLayoutNode, type SitemapLayoutResult, type SitemapLegendEntry, type SitemapLegendGroup, type SitemapNode, type TagEntry, type TagGroup, type VisualizationType, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildExtendedChartOption, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildSimpleChartOption, buildTagLaneRowList, buildThemeCSS, calculateSchedule, catppuccinPalette, collapseBoxesAndLines, collapseOrgTree, collapseSitemapTree, collectDiagramRoles, collectTasks, colorNames, computeActivations, computeCardArchive, computeCardMove, computeInfra, computeInfraLegendGroups, computeLegendLayout, computeScatterLabelGraphics, computeTimeTicks, contrastText, decodeDiagramUrl, encodeDiagramUrl, extractDiagramSymbols, extractTagDeclarations, formatDateLabel, formatDgmoError, getAvailablePalettes, getExtendedChartLegendGroups, getLegendReservedHeight, getPalette, getRenderCategory, getSeriesColors, getSimpleChartLegendGroups, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, inferRoles, injectBranding, isArchiveColumn, isExtendedChartType, isSequenceBlock, isSequenceNote, isValidHex, layoutBoxesAndLines, layoutC4Components, layoutC4Containers, layoutC4Context, layoutC4Deployment, layoutClassDiagram, layoutERDiagram, layoutGraph, layoutInfra, layoutOrg, layoutSitemap, looksLikeClassDiagram, looksLikeERDiagram, looksLikeFlowchart, looksLikeSequence, looksLikeSitemap, looksLikeState, makeDgmoError, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseAndLayoutInfra, parseBoxesAndLines, parseC4, parseChart, parseClassDiagram, parseDataRowValues, parseDgmo, parseDgmoChartType, parseERDiagram, parseExtendedChart, parseFirstLine, parseFlowchart, parseGantt, parseInfra, parseInlineMarkdown, parseKanban, parseOrg, parseQuadrant, parseSequenceDgmo, parseSitemap, parseState, parseTimelineDate, parseVisualization, registerExtractor, registerPalette, render, renderArcDiagram, renderBoxesAndLines, renderBoxesAndLinesForExport, renderC4ComponentsForExport, renderC4Containers, renderC4ContainersForExport, renderC4Context, renderC4ContextForExport, renderC4Deployment, renderC4DeploymentForExport, renderClassDiagram, renderClassDiagramForExport, renderERDiagram, renderERDiagramForExport, renderExtendedChartForExport, renderFlowchart, renderFlowchartForExport, renderForExport, renderGantt, renderInfra, renderKanban, renderKanbanForExport, renderLegendD3, renderLegendSvg, renderLegendSvgFromConfig, renderOrg, renderOrgForExport, renderQuadrant, renderSequenceDiagram, renderSitemap, renderSitemapForExport, renderSlopeChart, renderState, renderStateForExport, renderTimeline, renderVenn, renderWordCloud, resolveColor, resolveOrgImports, resolveTaskName, rollUpContextRelationships, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette, truncateBareUrl, validateComputed, validateInfra };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { EChartsOption } from 'echarts';
2
+ import { Selection } from 'd3-selection';
2
3
  import * as d3Scale from 'd3-scale';
3
4
 
4
5
  type DgmoSeverity = 'error' | 'warning';
@@ -39,6 +40,11 @@ declare function render(content: string, options?: {
39
40
  c4System?: string;
40
41
  c4Container?: string;
41
42
  tagGroup?: string;
43
+ /** Legend state for export — controls which tag group is shown in exported SVG. */
44
+ legendState?: {
45
+ activeGroup?: string;
46
+ hiddenAttributes?: string[];
47
+ };
42
48
  }): Promise<string>;
43
49
 
44
50
  /**
@@ -283,6 +289,134 @@ declare function parseDataRowValues(line: string, options?: {
283
289
  values: number[];
284
290
  } | null;
285
291
 
292
+ interface LegendState {
293
+ activeGroup: string | null;
294
+ hiddenAttributes?: Set<string>;
295
+ }
296
+ interface LegendCallbacks {
297
+ onGroupToggle?: (groupName: string) => void;
298
+ onVisibilityToggle?: (attribute: string) => void;
299
+ onStateChange?: (newState: LegendState) => void;
300
+ /** Called when an entry is hovered. Chart renderers can use this for cross-element highlighting. */
301
+ onEntryHover?: (groupName: string, entryValue: string | null) => void;
302
+ /** Called after each group <g> is rendered — lets chart renderers inject custom elements (swimlane icons, etc.) */
303
+ onGroupRendered?: (groupName: string, groupEl: D3Sel, isActive: boolean) => void;
304
+ }
305
+ interface LegendPosition {
306
+ placement: 'top-center';
307
+ titleRelation: 'below-title' | 'inline-with-title';
308
+ }
309
+ type LegendMode = 'fixed' | 'inline';
310
+ type LegendControlExportBehavior = 'include' | 'strip' | 'static';
311
+ interface LegendControl {
312
+ id: string;
313
+ /** SVG markup for the control icon, or a string label */
314
+ icon: string;
315
+ label?: string;
316
+ exportBehavior: LegendControlExportBehavior;
317
+ onClick?: () => void;
318
+ children?: LegendControlEntry[];
319
+ }
320
+ interface LegendControlEntry {
321
+ id: string;
322
+ label: string;
323
+ isActive?: boolean;
324
+ onClick?: () => void;
325
+ }
326
+ interface LegendConfig {
327
+ groups: LegendGroupData[];
328
+ position: LegendPosition;
329
+ controls?: LegendControl[];
330
+ mode: LegendMode;
331
+ /** Title width in pixels — used for inline-with-title computation */
332
+ titleWidth?: number;
333
+ /** Extra width (px) reserved after the pill inside an active capsule (e.g. for eye icon addon). Entries start after this offset. */
334
+ capsulePillAddonWidth?: number;
335
+ /** When true, groups with no entries are still rendered as collapsed pills. Default: false (empty groups hidden). */
336
+ showEmptyGroups?: boolean;
337
+ }
338
+ interface LegendPalette {
339
+ bg: string;
340
+ surface: string;
341
+ text: string;
342
+ textMuted: string;
343
+ primary?: string;
344
+ }
345
+ interface LegendPillLayout {
346
+ groupName: string;
347
+ x: number;
348
+ y: number;
349
+ width: number;
350
+ height: number;
351
+ isActive: boolean;
352
+ }
353
+ interface LegendEntryLayout {
354
+ value: string;
355
+ color: string;
356
+ x: number;
357
+ y: number;
358
+ dotCx: number;
359
+ dotCy: number;
360
+ textX: number;
361
+ textY: number;
362
+ }
363
+ interface LegendCapsuleLayout {
364
+ groupName: string;
365
+ x: number;
366
+ y: number;
367
+ width: number;
368
+ height: number;
369
+ pill: LegendPillLayout;
370
+ entries: LegendEntryLayout[];
371
+ /** Overflow indicator when entries exceed max rows */
372
+ moreCount?: number;
373
+ /** X offset where addon content (e.g. eye icon) can be placed — after pill, before entries */
374
+ addonX?: number;
375
+ }
376
+ interface LegendControlLayout {
377
+ id: string;
378
+ x: number;
379
+ y: number;
380
+ width: number;
381
+ height: number;
382
+ icon: string;
383
+ label?: string;
384
+ exportBehavior: LegendControlExportBehavior;
385
+ children?: Array<{
386
+ id: string;
387
+ label: string;
388
+ x: number;
389
+ y: number;
390
+ width: number;
391
+ isActive?: boolean;
392
+ }>;
393
+ }
394
+ interface LegendRowLayout {
395
+ y: number;
396
+ items: Array<LegendPillLayout | LegendCapsuleLayout | LegendControlLayout>;
397
+ }
398
+ interface LegendLayout {
399
+ /** Total computed height including all rows */
400
+ height: number;
401
+ /** Total computed width */
402
+ width: number;
403
+ /** Rows of legend elements (pills wrap to new rows on overflow) */
404
+ rows: LegendRowLayout[];
405
+ /** Active capsule layout (if any group is active) */
406
+ activeCapsule?: LegendCapsuleLayout;
407
+ /** Control layouts (right-aligned) */
408
+ controls: LegendControlLayout[];
409
+ /** All pill layouts (collapsed groups) */
410
+ pills: LegendPillLayout[];
411
+ }
412
+ interface LegendHandle {
413
+ setState: (state: LegendState) => void;
414
+ destroy: () => void;
415
+ getHeight: () => number;
416
+ getLayout: () => LegendLayout;
417
+ }
418
+ type D3Sel = Selection<any, unknown, any, unknown>;
419
+
286
420
  interface LegendGroupData {
287
421
  name: string;
288
422
  entries: Array<{
@@ -313,6 +447,9 @@ interface LegendRenderResult {
313
447
  width: number;
314
448
  }
315
449
  declare function renderLegendSvg(groups: LegendGroupData[], options: LegendRenderOptions): LegendRenderResult;
450
+ declare function renderLegendSvgFromConfig(config: LegendConfig, state: LegendState, palette: LegendPalette & {
451
+ isDark: boolean;
452
+ }, containerWidth: number): LegendRenderResult;
316
453
 
317
454
  type ExtendedChartType = 'sankey' | 'chord' | 'function' | 'scatter' | 'heatmap' | 'funnel';
318
455
  interface ExtendedChartDataPoint {
@@ -1568,6 +1705,8 @@ interface BLLayoutEdge {
1568
1705
  yOffset: number;
1569
1706
  parallelCount: number;
1570
1707
  metadata: Record<string, string>;
1708
+ /** True for edges deferred from dagre (group endpoints) — use linear curve */
1709
+ deferred?: boolean;
1571
1710
  }
1572
1711
  interface BLLayoutGroup {
1573
1712
  label: string;
@@ -1694,6 +1833,8 @@ interface SitemapLayoutEdge {
1694
1833
  label?: string;
1695
1834
  color?: string;
1696
1835
  lineNumber: number;
1836
+ /** True for edges deferred from dagre (container endpoints) — use linear curve */
1837
+ deferred?: boolean;
1697
1838
  }
1698
1839
  interface SitemapContainerBounds {
1699
1840
  nodeId: string;
@@ -2277,6 +2418,11 @@ declare function renderFlowchartForExport(content: string, theme: 'light' | 'dar
2277
2418
 
2278
2419
  declare const LEGEND_HEIGHT = 28;
2279
2420
 
2421
+ declare function renderLegendD3(container: D3Sel, config: LegendConfig, state: LegendState, palette: LegendPalette, isDark: boolean, callbacks?: LegendCallbacks, containerWidth?: number): LegendHandle;
2422
+
2423
+ declare function computeLegendLayout(config: LegendConfig, state: LegendState, containerWidth: number): LegendLayout;
2424
+ declare function getLegendReservedHeight(config: LegendConfig, state: LegendState, containerWidth: number): number;
2425
+
2280
2426
  interface SectionMessageGroup {
2281
2427
  section: SequenceSection;
2282
2428
  messageIndices: number[];
@@ -2446,4 +2592,4 @@ declare function parseFirstLine(line: string): {
2446
2592
  */
2447
2593
  declare function injectBranding(svgHtml: string, mutedColor: string): string;
2448
2594
 
2449
- export { ALL_CHART_TYPES, type Activation, type ArcLink, type ArcNodeGroup, type BLCollapseResult, type BLEdge, type BLGroup, type BLLayoutEdge, type BLLayoutGroup, type BLLayoutNode, type BLLayoutResult, type BLNode, type C4ArrowType, type C4DeploymentNode, type C4Element, type C4ElementType, type C4Group, type C4LayoutBoundary, type C4LayoutEdge, type C4LayoutNode, type C4LayoutResult, type C4LegendEntry, type C4LegendGroup, type C4Relationship, type C4Shape, type C4TagEntry, type C4TagGroup, CHART_TYPES, COMPLETION_REGISTRY, type ChartDataPoint, type ChartEra, type ChartType$1 as ChartType, type ClassLayoutEdge, type ClassLayoutNode, type ClassLayoutResult, type ClassMember, type ClassModifier, type ClassNode, type ClassRelationship, type CollapsedOrgResult, type CollapsedSitemapResult, type ComputedInfraEdge, type ComputedInfraModel, type ComputedInfraNode, type ContextRelationship, type D3ExportDimensions, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type DiagramSymbols, type DiagramViewState, type DirectiveSpec, type DirectiveValueSpec, type Duration, type DurationUnit, ENTITY_TYPES, type ERCardinality, type ERColumn, type ERConstraint, type ERLayoutEdge, type ERLayoutNode, type ERLayoutResult, type ERRelationship, type ERTable, type ElseIfBranch, type EncodeDiagramUrlOptions, type EncodeDiagramUrlResult, type ExtendedChartType, type ExtractFn, type GanttDependency, type GanttEra, type GanttGroup, type GroupRow as GanttGroupRow, type GanttHolidays, type GanttInteractiveOptions, type LaneHeaderRow as GanttLaneHeaderRow, type GanttMarker, type GanttNode, type GanttOptions, type GanttParallelBlock, type Row as GanttRow, type GanttTask, type TaskRow as GanttTaskRow, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, INFRA_BEHAVIOR_KEYS, type ImportSource, type InfraAvailabilityPercentiles, type InfraBehaviorKey, type InfraCbState, type InfraComputeParams, type InfraDiagnostic, type InfraEdge, type InfraGroup, type InfraLatencyPercentiles, type InfraLayoutEdge, type InfraLayoutGroup, type InfraLayoutNode, type InfraLayoutResult, type InfraLegendGroup, type InfraNode, type InfraPlaybackState, type InfraProperty, type InfraRole, type InfraTagGroup, type InlineSpan, type KanbanCard, type KanbanColumn, type KanbanTagEntry, type KanbanTagGroup, LEGEND_HEIGHT, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type LegendGroupData, METADATA_KEY_SET, type MemberVisibility, type OrgContainerBounds, type OrgLayoutEdge, type OrgLayoutNode, type OrgLayoutResult, type OrgNode, PIPE_METADATA, type PaletteColors, type PaletteConfig, type ParsedBoxesAndLines, type ParsedC4, type ParsedChart, type ParsedClassDiagram, type ParsedERDiagram, type ParsedExtendedChart, type ParsedGantt, type ParsedGraph, type ParsedInfra, type ParsedKanban, type ParsedOrg, type ParsedQuadrant, type ParsedSequenceDgmo, type ParsedSitemap, type ParsedVisualization, type ParticipantType, type PipeKeySpec, RULE_COUNT, type ReadFileFn, type RelationshipType, type RenderCategory, type RenderStep, type ResolveImportsResult, type ResolvedGroup, type ResolvedSchedule, type ResolvedTask, type ScatterLabelPoint, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, type SitemapContainerBounds, type SitemapDirection, type SitemapEdge, type SitemapLayoutEdge, type SitemapLayoutNode, type SitemapLayoutResult, type SitemapLegendEntry, type SitemapLegendGroup, type SitemapNode, type TagEntry, type TagGroup, type VisualizationType, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildExtendedChartOption, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildSimpleChartOption, buildTagLaneRowList, buildThemeCSS, calculateSchedule, catppuccinPalette, collapseBoxesAndLines, collapseOrgTree, collapseSitemapTree, collectDiagramRoles, collectTasks, colorNames, computeActivations, computeCardArchive, computeCardMove, computeInfra, computeInfraLegendGroups, computeScatterLabelGraphics, computeTimeTicks, contrastText, decodeDiagramUrl, encodeDiagramUrl, extractDiagramSymbols, extractTagDeclarations, formatDateLabel, formatDgmoError, getAvailablePalettes, getExtendedChartLegendGroups, getPalette, getRenderCategory, getSeriesColors, getSimpleChartLegendGroups, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, inferRoles, injectBranding, isArchiveColumn, isExtendedChartType, isSequenceBlock, isSequenceNote, isValidHex, layoutBoxesAndLines, layoutC4Components, layoutC4Containers, layoutC4Context, layoutC4Deployment, layoutClassDiagram, layoutERDiagram, layoutGraph, layoutInfra, layoutOrg, layoutSitemap, looksLikeClassDiagram, looksLikeERDiagram, looksLikeFlowchart, looksLikeSequence, looksLikeSitemap, looksLikeState, makeDgmoError, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseAndLayoutInfra, parseBoxesAndLines, parseC4, parseChart, parseClassDiagram, parseDataRowValues, parseDgmo, parseDgmoChartType, parseERDiagram, parseExtendedChart, parseFirstLine, parseFlowchart, parseGantt, parseInfra, parseInlineMarkdown, parseKanban, parseOrg, parseQuadrant, parseSequenceDgmo, parseSitemap, parseState, parseTimelineDate, parseVisualization, registerExtractor, registerPalette, render, renderArcDiagram, renderBoxesAndLines, renderBoxesAndLinesForExport, renderC4ComponentsForExport, renderC4Containers, renderC4ContainersForExport, renderC4Context, renderC4ContextForExport, renderC4Deployment, renderC4DeploymentForExport, renderClassDiagram, renderClassDiagramForExport, renderERDiagram, renderERDiagramForExport, renderExtendedChartForExport, renderFlowchart, renderFlowchartForExport, renderForExport, renderGantt, renderInfra, renderKanban, renderKanbanForExport, renderLegendSvg, renderOrg, renderOrgForExport, renderQuadrant, renderSequenceDiagram, renderSitemap, renderSitemapForExport, renderSlopeChart, renderState, renderStateForExport, renderTimeline, renderVenn, renderWordCloud, resolveColor, resolveOrgImports, resolveTaskName, rollUpContextRelationships, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette, truncateBareUrl, validateComputed, validateInfra };
2595
+ export { ALL_CHART_TYPES, type Activation, type ArcLink, type ArcNodeGroup, type BLCollapseResult, type BLEdge, type BLGroup, type BLLayoutEdge, type BLLayoutGroup, type BLLayoutNode, type BLLayoutResult, type BLNode, type C4ArrowType, type C4DeploymentNode, type C4Element, type C4ElementType, type C4Group, type C4LayoutBoundary, type C4LayoutEdge, type C4LayoutNode, type C4LayoutResult, type C4LegendEntry, type C4LegendGroup, type C4Relationship, type C4Shape, type C4TagEntry, type C4TagGroup, CHART_TYPES, COMPLETION_REGISTRY, type ChartDataPoint, type ChartEra, type ChartType$1 as ChartType, type ClassLayoutEdge, type ClassLayoutNode, type ClassLayoutResult, type ClassMember, type ClassModifier, type ClassNode, type ClassRelationship, type CollapsedOrgResult, type CollapsedSitemapResult, type ComputedInfraEdge, type ComputedInfraModel, type ComputedInfraNode, type ContextRelationship, type D3ExportDimensions, type DecodedDiagramUrl, type DgmoError, type DgmoSeverity, type DiagramSymbols, type DiagramViewState, type DirectiveSpec, type DirectiveValueSpec, type Duration, type DurationUnit, ENTITY_TYPES, type ERCardinality, type ERColumn, type ERConstraint, type ERLayoutEdge, type ERLayoutNode, type ERLayoutResult, type ERRelationship, type ERTable, type ElseIfBranch, type EncodeDiagramUrlOptions, type EncodeDiagramUrlResult, type ExtendedChartType, type ExtractFn, type GanttDependency, type GanttEra, type GanttGroup, type GroupRow as GanttGroupRow, type GanttHolidays, type GanttInteractiveOptions, type LaneHeaderRow as GanttLaneHeaderRow, type GanttMarker, type GanttNode, type GanttOptions, type GanttParallelBlock, type Row as GanttRow, type GanttTask, type TaskRow as GanttTaskRow, type GraphDirection, type GraphEdge, type GraphGroup, type GraphNode, type GraphShape, INFRA_BEHAVIOR_KEYS, type ImportSource, type InfraAvailabilityPercentiles, type InfraBehaviorKey, type InfraCbState, type InfraComputeParams, type InfraDiagnostic, type InfraEdge, type InfraGroup, type InfraLatencyPercentiles, type InfraLayoutEdge, type InfraLayoutGroup, type InfraLayoutNode, type InfraLayoutResult, type InfraLegendGroup, type InfraNode, type InfraPlaybackState, type InfraProperty, type InfraRole, type InfraTagGroup, type InlineSpan, type KanbanCard, type KanbanColumn, type KanbanTagEntry, type KanbanTagGroup, LEGEND_HEIGHT, type LayoutEdge, type LayoutGroup, type LayoutNode, type LayoutResult, type LegendCallbacks, type LegendConfig, type LegendControl, type LegendGroupData, type LegendHandle, type LegendLayout, type LegendMode, type LegendPalette, type LegendPosition, type LegendState, METADATA_KEY_SET, type MemberVisibility, type OrgContainerBounds, type OrgLayoutEdge, type OrgLayoutNode, type OrgLayoutResult, type OrgNode, PIPE_METADATA, type PaletteColors, type PaletteConfig, type ParsedBoxesAndLines, type ParsedC4, type ParsedChart, type ParsedClassDiagram, type ParsedERDiagram, type ParsedExtendedChart, type ParsedGantt, type ParsedGraph, type ParsedInfra, type ParsedKanban, type ParsedOrg, type ParsedQuadrant, type ParsedSequenceDgmo, type ParsedSitemap, type ParsedVisualization, type ParticipantType, type PipeKeySpec, RULE_COUNT, type ReadFileFn, type RelationshipType, type RenderCategory, type RenderStep, type ResolveImportsResult, type ResolvedGroup, type ResolvedSchedule, type ResolvedTask, type ScatterLabelPoint, type SectionMessageGroup, type SequenceBlock, type SequenceElement, type SequenceGroup, type SequenceMessage, type SequenceNote, type SequenceParticipant, type SequenceRenderOptions, type SequenceSection, type SitemapContainerBounds, type SitemapDirection, type SitemapEdge, type SitemapLayoutEdge, type SitemapLayoutNode, type SitemapLayoutResult, type SitemapLegendEntry, type SitemapLegendGroup, type SitemapNode, type TagEntry, type TagGroup, type VisualizationType, addDurationToDate, applyGroupOrdering, applyPositionOverrides, boldPalette, buildExtendedChartOption, buildMermaidQuadrant, buildMermaidThemeVars, buildNoteMessageMap, buildRenderSequence, buildSimpleChartOption, buildTagLaneRowList, buildThemeCSS, calculateSchedule, catppuccinPalette, collapseBoxesAndLines, collapseOrgTree, collapseSitemapTree, collectDiagramRoles, collectTasks, colorNames, computeActivations, computeCardArchive, computeCardMove, computeInfra, computeInfraLegendGroups, computeLegendLayout, computeScatterLabelGraphics, computeTimeTicks, contrastText, decodeDiagramUrl, encodeDiagramUrl, extractDiagramSymbols, extractTagDeclarations, formatDateLabel, formatDgmoError, getAvailablePalettes, getExtendedChartLegendGroups, getLegendReservedHeight, getPalette, getRenderCategory, getSeriesColors, getSimpleChartLegendGroups, groupMessagesBySection, gruvboxPalette, hexToHSL, hexToHSLString, hslToHex, inferParticipantType, inferRoles, injectBranding, isArchiveColumn, isExtendedChartType, isSequenceBlock, isSequenceNote, isValidHex, layoutBoxesAndLines, layoutC4Components, layoutC4Containers, layoutC4Context, layoutC4Deployment, layoutClassDiagram, layoutERDiagram, layoutGraph, layoutInfra, layoutOrg, layoutSitemap, looksLikeClassDiagram, looksLikeERDiagram, looksLikeFlowchart, looksLikeSequence, looksLikeSitemap, looksLikeState, makeDgmoError, mute, nord, nordPalette, oneDarkPalette, orderArcNodes, parseAndLayoutInfra, parseBoxesAndLines, parseC4, parseChart, parseClassDiagram, parseDataRowValues, parseDgmo, parseDgmoChartType, parseERDiagram, parseExtendedChart, parseFirstLine, parseFlowchart, parseGantt, parseInfra, parseInlineMarkdown, parseKanban, parseOrg, parseQuadrant, parseSequenceDgmo, parseSitemap, parseState, parseTimelineDate, parseVisualization, registerExtractor, registerPalette, render, renderArcDiagram, renderBoxesAndLines, renderBoxesAndLinesForExport, renderC4ComponentsForExport, renderC4Containers, renderC4ContainersForExport, renderC4Context, renderC4ContextForExport, renderC4Deployment, renderC4DeploymentForExport, renderClassDiagram, renderClassDiagramForExport, renderERDiagram, renderERDiagramForExport, renderExtendedChartForExport, renderFlowchart, renderFlowchartForExport, renderForExport, renderGantt, renderInfra, renderKanban, renderKanbanForExport, renderLegendD3, renderLegendSvg, renderLegendSvgFromConfig, renderOrg, renderOrgForExport, renderQuadrant, renderSequenceDiagram, renderSitemap, renderSitemapForExport, renderSlopeChart, renderState, renderStateForExport, renderTimeline, renderVenn, renderWordCloud, resolveColor, resolveOrgImports, resolveTaskName, rollUpContextRelationships, rosePinePalette, seriesColors, shade, solarizedPalette, tint, tokyoNightPalette, truncateBareUrl, validateComputed, validateInfra };