@sentropic/diagram-canvas 0.3.0 → 0.3.1

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.
@@ -39,7 +39,7 @@
39
39
  "weight": 400,
40
40
  "lineHeight": 1.2222222222222223
41
41
  },
42
- "bodyInsetFromBar": 14,
42
+ "bodyInsetFromBar": 10,
43
43
  "ruleHeight": 1,
44
44
  "ruleMargin": 4,
45
45
  "ruleInsetStart": 16,
@@ -105,8 +105,8 @@
105
105
  "headerTextInset": 154,
106
106
  "collapsedWidth": 352,
107
107
  "collapsedHeight": 154,
108
- "collapsedInset": 16,
109
- "collapsedSubtitleMarginInline": 16,
108
+ "collapsedInset": 12,
109
+ "collapsedSubtitleMarginInline": 12,
110
110
  "allocatedLines": {
111
111
  "kicker": 1,
112
112
  "title": 1,
@@ -140,17 +140,17 @@
140
140
  "title": [
141
141
  {
142
142
  "text": "Title",
143
- "x": 206,
143
+ "x": 68,
144
144
  "baseline": 45.203125,
145
145
  "size": 32,
146
146
  "weight": 700,
147
147
  "secondary": false,
148
- "anchor": "middle"
148
+ "anchor": "start"
149
149
  }
150
150
  ],
151
151
  "headerBlockHeight": 52,
152
- "bodyX": 14,
153
- "bodyWidth": 330,
152
+ "bodyX": 10,
153
+ "bodyWidth": 334,
154
154
  "bodyArea": {
155
155
  "top": 66,
156
156
  "bottom": 146
@@ -158,7 +158,7 @@
158
158
  "body": [
159
159
  {
160
160
  "text": "Body",
161
- "x": 179,
161
+ "x": 177,
162
162
  "baseline": 112.40625,
163
163
  "size": 24,
164
164
  "weight": 400,
@@ -198,23 +198,23 @@
198
198
  "kicker": [
199
199
  {
200
200
  "text": "KICKER",
201
- "x": 237,
201
+ "x": 92,
202
202
  "baseline": 32,
203
203
  "size": 22,
204
204
  "weight": 400,
205
205
  "secondary": true,
206
- "anchor": "middle"
206
+ "anchor": "start"
207
207
  }
208
208
  ],
209
209
  "title": [
210
210
  {
211
211
  "text": "Title",
212
- "x": 237,
212
+ "x": 92,
213
213
  "baseline": 70.59375,
214
214
  "size": 32,
215
215
  "weight": 700,
216
216
  "secondary": false,
217
- "anchor": "middle"
217
+ "anchor": "start"
218
218
  }
219
219
  ],
220
220
  "headerBlockHeight": 70.1875,
@@ -251,12 +251,12 @@
251
251
  "footerLines": [
252
252
  {
253
253
  "text": "Footer",
254
- "x": 233,
254
+ "x": 16,
255
255
  "baseline": 179.5625,
256
256
  "size": 24,
257
257
  "weight": 700,
258
258
  "secondary": false,
259
- "anchor": "middle"
259
+ "anchor": "start"
260
260
  }
261
261
  ],
262
262
  "footerBottom": 188.75,
@@ -321,23 +321,23 @@
321
321
  "kicker": [
322
322
  {
323
323
  "text": "KICKER",
324
- "x": 237,
324
+ "x": 92,
325
325
  "baseline": 32,
326
326
  "size": 22,
327
327
  "weight": 400,
328
328
  "secondary": true,
329
- "anchor": "middle"
329
+ "anchor": "start"
330
330
  }
331
331
  ],
332
332
  "title": [
333
333
  {
334
334
  "text": "Zone",
335
- "x": 237,
335
+ "x": 92,
336
336
  "baseline": 70.59375,
337
337
  "size": 32,
338
338
  "weight": 700,
339
339
  "secondary": false,
340
- "anchor": "middle"
340
+ "anchor": "start"
341
341
  }
342
342
  ],
343
343
  "headerBlockHeight": 70.1875,
@@ -365,12 +365,12 @@
365
365
  "footerLines": [
366
366
  {
367
367
  "text": "Footer",
368
- "x": 233,
368
+ "x": 16,
369
369
  "baseline": 179.5625,
370
370
  "size": 24,
371
371
  "weight": 700,
372
372
  "secondary": false,
373
- "anchor": "middle"
373
+ "anchor": "start"
374
374
  }
375
375
  ],
376
376
  "footerBottom": 188.75,
@@ -433,35 +433,35 @@
433
433
  "kicker": [
434
434
  {
435
435
  "text": "KICKER",
436
- "x": 291,
436
+ "x": 68,
437
437
  "baseline": 34,
438
438
  "size": 22,
439
439
  "weight": 400,
440
440
  "secondary": true,
441
- "anchor": "middle"
441
+ "anchor": "start"
442
442
  }
443
443
  ],
444
444
  "title": [
445
445
  {
446
446
  "text": "Zone",
447
- "x": 291,
447
+ "x": 68,
448
448
  "baseline": 72.59375,
449
449
  "size": 32,
450
450
  "weight": 700,
451
451
  "secondary": false,
452
- "anchor": "middle"
452
+ "anchor": "start"
453
453
  }
454
454
  ],
455
455
  "headerBlockHeight": 70.1875,
456
456
  "subtitle": [
457
457
  {
458
458
  "text": "Subtitle",
459
- "x": 175,
459
+ "x": 12,
460
460
  "baseline": 110.1875,
461
461
  "size": 24,
462
462
  "weight": 400,
463
463
  "secondary": false,
464
- "anchor": "middle"
464
+ "anchor": "start"
465
465
  }
466
466
  ],
467
467
  "subtitleWidth": 326,
@@ -476,12 +476,12 @@
476
476
  "footer": [
477
477
  {
478
478
  "text": "Footer",
479
- "x": 300,
479
+ "x": 16,
480
480
  "baseline": 184.875,
481
481
  "size": 24,
482
482
  "weight": 700,
483
483
  "secondary": false,
484
- "anchor": "middle"
484
+ "anchor": "start"
485
485
  }
486
486
  ],
487
487
  "footerRuleY": 157.875,
@@ -513,7 +513,7 @@
513
513
  "bodyFontSize": "var(--st-component-diagramCard-bodyFontSize)",
514
514
  "bodyFontWeight": "var(--st-component-diagramCard-bodyFontWeight)",
515
515
  "bodyLineHeight": "var(--st-component-diagramCard-bodyLineHeight)",
516
- "bodyInsetFromBar": "var(--st-component-diagramCard-bodyInsetFromBar)",
516
+ "bodyInsetFromBar": "10px",
517
517
  "ruleHeight": "var(--st-component-diagramCard-ruleHeight)",
518
518
  "ruleMargin": "var(--st-component-diagramCard-ruleMargin)",
519
519
  "ruleInsetStart": "var(--st-component-diagramCard-ruleInsetStart)",
@@ -878,6 +878,10 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
878
878
  packedRuns.set(run.key, { run, rows, shelves, boxes, positions: seated.positions, alongBase, acrossBase });
879
879
  return { width: seated.width, height: seated.height };
880
880
  };
881
+ const legendKeyCardWidth = (id) => {
882
+ const parent = graph.nodes.get(id)?.parent;
883
+ return parent !== undefined ? cardWidthOf(representativeOf(parent)) : cardWidthOf(representativeOf(id));
884
+ };
881
885
  const sizeBox = (id) => {
882
886
  const kind = kinds.get(id);
883
887
  if (kind === "leaf" || kind === "container-collapsed" || kind === "legend-collapsed") {
@@ -890,7 +894,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
890
894
  return size;
891
895
  }
892
896
  if (kind === "legend-key")
893
- return { width: innerWidthOf(FIXED_CARD_WIDTH), height: LEGEND_KEY_HEIGHT };
897
+ return { width: innerWidthOf(legendKeyCardWidth(id)), height: LEGEND_KEY_HEIGHT };
894
898
  const zoneGeo = anatomyZoneGeometry(occurrenceAnatomy(representativeOf(id)));
895
899
  const hasIcon = presentation.entities[representativeOf(id)]?.icon !== "none";
896
900
  const headerReserve = zoneGeo.headerTextInset - (hasIcon ? 0 : zoneGeo.iconSize + zoneGeo.iconTextGap);
@@ -1058,7 +1062,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
1058
1062
  return;
1059
1063
  }
1060
1064
  if (kind === "legend-key") {
1061
- rects.set(id, { x, y, width: innerWidthOf(FIXED_CARD_WIDTH), height: LEGEND_KEY_HEIGHT });
1065
+ rects.set(id, { x, y, width: innerWidthOf(legendKeyCardWidth(id)), height: LEGEND_KEY_HEIGHT });
1062
1066
  return;
1063
1067
  }
1064
1068
  const size = packedSizes.get(id);
@@ -1129,7 +1133,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
1129
1133
  const text = slotTexts(document, presentation, occurrence, id);
1130
1134
  if (kind === "legend-key") {
1131
1135
  const parent = graph.nodes.get(id)?.parent;
1132
- const inner = parent !== undefined && legendInner.has(parent) ? legendInner.get(parent) : innerWidthOf(FIXED_CARD_WIDTH);
1136
+ const inner = parent !== undefined && legendInner.has(parent) ? legendInner.get(parent) : innerWidthOf(legendKeyCardWidth(id));
1133
1137
  recordSlot(occurrence, "legend-label", measure({
1134
1138
  text: text.title ?? "",
1135
1139
  role: "legend-label",
@@ -1140,7 +1144,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
1140
1144
  continue;
1141
1145
  }
1142
1146
  const expanded = kind === "container-expanded" || kind === "legend-expanded";
1143
- const inner = expanded ? innerWidthOf(outerWidths.get(id) ?? FIXED_CARD_WIDTH) : innerWidthOf(FIXED_CARD_WIDTH);
1147
+ const inner = expanded ? innerWidthOf(outerWidths.get(id) ?? cardWidthOf(occurrence)) : innerWidthOf(cardWidthOf(occurrence));
1144
1148
  const rendered = sceneBoxAt(occurrence, rects.get(id).width, !expanded && kind !== "leaf");
1145
1149
  for (const role of ["body", "detail", "footer"]) {
1146
1150
  if (text[role] === undefined)
@@ -124,6 +124,8 @@ export declare const CARD_GEOMETRY_V2: {
124
124
  readonly headerInset: 12;
125
125
  readonly iconSize: 52;
126
126
  readonly iconTextGap: 4;
127
+ /** Preserves v1's −2 px body-vs-header offset (`10 − 12 = −2`, matching `14 − 16`). */
128
+ readonly bodyInsetFromBar: 10;
127
129
  readonly foldedHeaderTextWidth: 210;
128
130
  /** Title on one line first (addendum 8); v1 keeps two lines. */
129
131
  readonly allocatedLines: {
@@ -162,8 +164,6 @@ export declare const CARD_GEOMETRY_V2: {
162
164
  readonly weight: 400;
163
165
  readonly lineHeight: number;
164
166
  };
165
- /** Accent-bar left edge → first body glyph. */
166
- readonly bodyInsetFromBar: 14;
167
167
  readonly ruleHeight: 1;
168
168
  readonly ruleMargin: 4;
169
169
  readonly ruleInsetStart: 16;
@@ -204,6 +204,16 @@ export interface AnatomyPinned {
204
204
  export interface AlignPinned {
205
205
  readonly align?: "left" | "center";
206
206
  }
207
+ /**
208
+ * Effective header/footer alignment for a card or zone:
209
+ * - Absent `align` is always `"left"` (compact `v2` never centres implicitly).
210
+ * - Explicit `"v1"` anatomy (including `fallback-v1`) keeps the frozen 0.41.5
211
+ * alignment (`"left"`); view-driven centring applies only when a view
212
+ * explicitly asks `align: "center"` on compact `v2`.
213
+ * - Direct unpinned calls (`anatomy === undefined`) preserve 0.41.5's
214
+ * `props.align ?? "left"` behaviour.
215
+ */
216
+ export declare function resolveDiagramAlign(anatomy: DiagramAnatomy | undefined, align: "left" | "center" | undefined): "left" | "center";
207
217
  /**
208
218
  * Edge label typography (DC-2a, tokens `diagramScene.edgeLabelFontSize` /
209
219
  * `diagramScene.edgeLabelLineHeight`): 18 px on a 22 px line box. One line
@@ -559,8 +569,10 @@ export interface CardLayout {
559
569
  * Lay out fixed card slots with measured ellipses and a pinned footer.
560
570
  * Informational diagnostics retain the original text and hidden length.
561
571
  * Missing glyphs use the visible unknown icon (owner A2/A11).
562
- * Compact `v2` cards default to `"center"` alignment and fall back per box
563
- * to frozen `v1` (`460 × 200`) on overflow instead of dropping slots.
572
+ * Compact `v2` cards default to `"left"` alignment (centring only when
573
+ * `align: "center"` is explicitly requested on compact `v2`) and fall back
574
+ * per box to frozen `v1` (`460 × 200`, `"left"` header/footer alignment as in
575
+ * 0.41.5) on overflow instead of dropping slots.
564
576
  */
565
577
  export declare function layoutCard(props: DiagramCardProps, measure: CardLineMeasure): CardLayout;
566
578
  /**
@@ -639,9 +651,10 @@ export declare const ZONE_GEOMETRY: {
639
651
  };
640
652
  /**
641
653
  * Compact zone geometry (`diagram-anatomy/v2`): the collapsed zone IS the
642
- * compact card (`352 × 154`, collapsed subtitle measure `352 − 2 × 32`);
643
- * expanded chrome follows the compact insets (header `12`, icon `52`,
644
- * gap `4`). Unlisted leaves keep v1 values; type scale unchanged.
654
+ * compact card (`352 × 154`, collapsed subtitle measure `352 − 2 × 24 = 304`,
655
+ * preserving v1's ~86 % width ratio); expanded chrome follows the compact
656
+ * insets (header `12`, icon `52`, gap `4`). Unlisted leaves keep v1 values;
657
+ * type scale unchanged.
645
658
  */
646
659
  export declare const ZONE_GEOMETRY_V2: {
647
660
  readonly headerInset: 12;
@@ -655,6 +668,8 @@ export declare const ZONE_GEOMETRY_V2: {
655
668
  readonly headerTextInset: 154;
656
669
  readonly collapsedWidth: 352;
657
670
  readonly collapsedHeight: 154;
671
+ readonly collapsedInset: 12;
672
+ readonly collapsedSubtitleMarginInline: 12;
658
673
  readonly allocatedLines: {
659
674
  readonly kicker: 1;
660
675
  readonly title: 1;
@@ -704,8 +719,6 @@ export declare const ZONE_GEOMETRY_V2: {
704
719
  */
705
720
  readonly toggleTopInset: 8;
706
721
  readonly toggleInset: 8;
707
- readonly collapsedInset: 16;
708
- readonly collapsedSubtitleMarginInline: 16;
709
722
  };
710
723
  /** Select the zone geometry for a pinned anatomy (default `"v1"`). */
711
724
  export declare function anatomyZoneGeometry(anatomy: DiagramAnatomy | undefined): typeof ZONE_GEOMETRY | typeof ZONE_GEOMETRY_V2;
@@ -68,6 +68,8 @@ export const CARD_GEOMETRY_V2 = {
68
68
  headerInset: 12,
69
69
  iconSize: 52,
70
70
  iconTextGap: 4,
71
+ /** Preserves v1's −2 px body-vs-header offset (`10 − 12 = −2`, matching `14 − 16`). */
72
+ bodyInsetFromBar: 10,
71
73
  foldedHeaderTextWidth: 210,
72
74
  /** Title on one line first (addendum 8); v1 keeps two lines. */
73
75
  allocatedLines: { kicker: 1, title: 1, body: 2, footer: 1 },
@@ -76,6 +78,20 @@ export const CARD_GEOMETRY_V2 = {
76
78
  export function anatomyCardGeometry(anatomy) {
77
79
  return anatomy === "v2" ? CARD_GEOMETRY_V2 : CARD_GEOMETRY;
78
80
  }
81
+ /**
82
+ * Effective header/footer alignment for a card or zone:
83
+ * - Absent `align` is always `"left"` (compact `v2` never centres implicitly).
84
+ * - Explicit `"v1"` anatomy (including `fallback-v1`) keeps the frozen 0.41.5
85
+ * alignment (`"left"`); view-driven centring applies only when a view
86
+ * explicitly asks `align: "center"` on compact `v2`.
87
+ * - Direct unpinned calls (`anatomy === undefined`) preserve 0.41.5's
88
+ * `props.align ?? "left"` behaviour.
89
+ */
90
+ export function resolveDiagramAlign(anatomy, align) {
91
+ if (anatomy === "v1")
92
+ return "left";
93
+ return align ?? "left";
94
+ }
79
95
  /**
80
96
  * Edge label typography (DC-2a, tokens `diagramScene.edgeLabelFontSize` /
81
97
  * `diagramScene.edgeLabelLineHeight`): 18 px on a 22 px line box. One line
@@ -784,18 +800,20 @@ function layoutCardAt(props, measure, anatomy, align) {
784
800
  * Lay out fixed card slots with measured ellipses and a pinned footer.
785
801
  * Informational diagnostics retain the original text and hidden length.
786
802
  * Missing glyphs use the visible unknown icon (owner A2/A11).
787
- * Compact `v2` cards default to `"center"` alignment and fall back per box
788
- * to frozen `v1` (`460 × 200`) on overflow instead of dropping slots.
803
+ * Compact `v2` cards default to `"left"` alignment (centring only when
804
+ * `align: "center"` is explicitly requested on compact `v2`) and fall back
805
+ * per box to frozen `v1` (`460 × 200`, `"left"` header/footer alignment as in
806
+ * 0.41.5) on overflow instead of dropping slots.
789
807
  */
790
808
  export function layoutCard(props, measure) {
791
- const align = props.align ?? (props.anatomy === "v2" ? "center" : "left");
809
+ const align = resolveDiagramAlign(props.anatomy, props.align);
792
810
  const primary = layoutCardAt(props, measure, props.anatomy, align);
793
811
  if (props.anatomy !== "v2")
794
812
  return primary;
795
813
  const v2Overflows = primary.diagnostics.filter((diagnostic) => diagnostic.code === "card-overflow");
796
814
  if (v2Overflows.length === 0)
797
815
  return primary;
798
- const fallback = layoutCardAt(props, measure, "v1", align);
816
+ const fallback = layoutCardAt(props, measure, "v1", "left");
799
817
  const stillOverflows = fallback.diagnostics.some((diagnostic) => diagnostic.code === "card-overflow");
800
818
  const diagnostics = stillOverflows
801
819
  ? [...fallback.diagnostics]
@@ -878,9 +896,10 @@ export const ZONE_GEOMETRY = {
878
896
  };
879
897
  /**
880
898
  * Compact zone geometry (`diagram-anatomy/v2`): the collapsed zone IS the
881
- * compact card (`352 × 154`, collapsed subtitle measure `352 − 2 × 32`);
882
- * expanded chrome follows the compact insets (header `12`, icon `52`,
883
- * gap `4`). Unlisted leaves keep v1 values; type scale unchanged.
899
+ * compact card (`352 × 154`, collapsed subtitle measure `352 − 2 × 24 = 304`,
900
+ * preserving v1's ~86 % width ratio); expanded chrome follows the compact
901
+ * insets (header `12`, icon `52`, gap `4`). Unlisted leaves keep v1 values;
902
+ * type scale unchanged.
884
903
  */
885
904
  export const ZONE_GEOMETRY_V2 = {
886
905
  ...ZONE_GEOMETRY,
@@ -895,6 +914,8 @@ export const ZONE_GEOMETRY_V2 = {
895
914
  headerTextInset: 154,
896
915
  collapsedWidth: CARD_GEOMETRY_V2.width,
897
916
  collapsedHeight: CARD_GEOMETRY_V2.height,
917
+ collapsedInset: 12,
918
+ collapsedSubtitleMarginInline: 12,
898
919
  allocatedLines: { kicker: 1, title: 1, subtitle: 2, footer: 1 },
899
920
  };
900
921
  /** Select the zone geometry for a pinned anatomy (default `"v1"`). */
@@ -1040,7 +1061,7 @@ export function layoutZone(props, measure, children = []) {
1040
1061
  ? g.headerInset
1041
1062
  : g.headerTextInset - (g.headerInset + g.iconSize + g.iconTextGap);
1042
1063
  const headerTextWidth = Math.max(0, x + width - headerTextX - rightHeaderReserve);
1043
- const align = props.align ?? (props.anatomy === "v2" ? "center" : "left");
1064
+ const align = resolveDiagramAlign(props.anatomy, props.align);
1044
1065
  const headerAnchor = align === "center" ? "middle" : "start";
1045
1066
  const headerLineX = align === "center" ? headerTextX + headerTextWidth / 2 : headerTextX;
1046
1067
  const fitSlot = (text, role, width, budget, slot = role) => truncateSlot(text, role, width, budget, measure, diagnostic => diagnostics.push({ ...diagnostic, code: "zone-overflow", slot, entityId: props.entityId }));
@@ -250,7 +250,9 @@ export interface SceneModel {
250
250
  */
251
251
  export declare function resolveScene(result: SceneLaidOut, input: Pick<SceneLayoutInput, "document" | "presentation" | "measureLines" | "metrics" | "iconBindings" | "strictIcons" | "view" | "resolveGlyph" | "flows" | "depthParityStart">): SceneModel;
252
252
  /** Default labels for `DiagramSceneFigure`, including the DE-1b containment fallback label. */
253
- export declare const DEFAULT_SCENE_LABELS: DiagramSceneFigureLabels;
253
+ export declare const DEFAULT_SCENE_LABELS: DiagramSceneFigureLabels & {
254
+ readonly contains: string;
255
+ };
254
256
  /** Full presentation text retained alongside the textual relations (A14, DE-1b). */
255
257
  export declare function sceneTextRows(scene: SceneModel, document: SceneDocument, labels?: Partial<Pick<DiagramSceneFigureLabels, "contains">>): readonly string[];
256
258
  export interface SceneCameraInput {
@@ -48,7 +48,15 @@ export function resolveScenePresentation(document, presentation, bindings = {},
48
48
  * everywhere means `"v1"` — existing views do not move.
49
49
  */
50
50
  const viewAnatomy = view?.presentation?.anatomy;
51
- const withViewAnatomy = (entry) => entry.anatomy === undefined && viewAnatomy !== undefined ? { ...entry, anatomy: viewAnatomy } : entry;
51
+ const withViewAnatomy = (entry) => {
52
+ const resolved = entry.anatomy === undefined && viewAnatomy !== undefined ? { ...entry, anatomy: viewAnatomy } : entry;
53
+ // View-level centring applies only when explicitly requested on compact v2 anatomy.
54
+ if (resolved.anatomy !== "v2" && resolved.align === "center") {
55
+ const { align: _ignored, ...rest } = resolved;
56
+ return rest;
57
+ }
58
+ return resolved;
59
+ };
52
60
  const entities = Object.fromEntries(Object.entries(presentation.entities).map(([id, entry]) => {
53
61
  if (entry.form !== "card" && entry.form !== "container" && entry.form !== "legend")
54
62
  return [id, withViewAnatomy(entry)];
@@ -450,10 +458,6 @@ export const DEFAULT_SCENE_LABELS = Object.freeze({
450
458
  collapse: (title) => `Collapse ${title}`,
451
459
  contains: "includes",
452
460
  });
453
- function isContainmentRelation(document, relation) {
454
- const baseType = document.typeDefinitions?.[relation.type]?.baseType ?? relation.type;
455
- return baseType === "contains";
456
- }
457
461
  /** Full presentation text retained alongside the textual relations (A14, DE-1b). */
458
462
  export function sceneTextRows(scene, document, labels) {
459
463
  const containsLabel = labels?.contains ?? DEFAULT_SCENE_LABELS.contains;
@@ -461,7 +465,9 @@ export function sceneTextRows(scene, document, labels) {
461
465
  for (const relation of Object.values(document.relations)) {
462
466
  const names = relation.endpoints.map(end => { const value = document.entities[end.target]?.attributes["name"]; return value?.kind === "text" ? String(value.value) : end.target; });
463
467
  const explicit = edgeLabelOf(document, relation.id);
464
- const fallback = isContainmentRelation(document, relation) ? containsLabel : relation.type;
468
+ // W1-28: only replace the literal "contains" relation type so refined
469
+ // containment subtypes (e.g. "owns" with baseType "contains") keep their name.
470
+ const fallback = relation.type === "contains" ? containsLabel : relation.type;
465
471
  rows.push(names.join(" → ") + " · " + (explicit ?? fallback));
466
472
  }
467
473
  return rows;
@@ -24,7 +24,7 @@ export interface DiagramSceneFigureLabels {
24
24
  expand: (title: string) => string;
25
25
  collapse: (title: string) => string;
26
26
  /** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
27
- contains: string;
27
+ contains?: string;
28
28
  }
29
29
  export interface DiagramSceneCamera {
30
30
  readonly zoom: number;
@@ -115,7 +115,7 @@ export function renderCardSvg(props, measure = defaultCardMeasure) {
115
115
  const { content, layout } = renderCardContent(props, measure);
116
116
  const g = { ...anatomyCardGeometry(layout.anatomyFallback ?? props.anatomy), width: layout.box.width, height: layout.box.height };
117
117
  const overflowSlots = layout.diagnostics
118
- .filter((diagnostic) => diagnostic.code === "card-overflow")
118
+ .filter((diagnostic) => diagnostic.code === "card-overflow" && diagnostic.reason !== "fallback-v1")
119
119
  .map((diagnostic) => diagnostic.slot);
120
120
  const unknownIcon = layout.diagnostics.some((diagnostic) => diagnostic.code === "card-icon-unknown");
121
121
  const firstOverflow = overflowSlots.length === 0 ? undefined : overflowSlots[0];
@@ -58,7 +58,7 @@ export function renderSceneSvg(input, options = {}) {
58
58
  const leader = label.leader === undefined ? '' : `<polyline points="${label.leader.map(p => p.x + ',' + p.y).join(' ')}" fill="none" stroke="var(--st-component-diagramScene-edgeStroke, #64748b)"/>`;
59
59
  return leader + `<g data-scene-label="${escape(label.occurrence)}" transform="translate(${b.x} ${b.y})" font-size="18" fill="var(--st-component-diagramScene-labelText, #172033)"><rect width="${b.width}" height="${b.height}" fill="var(--st-component-diagramScene-labelSurface, #ffffff)" stroke="var(--st-component-diagramScene-labelBorder, #cbd5e1)"/>${text}</g>`;
60
60
  }).join('');
61
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${box.x - 2} ${box.y - 2} ${box.width + 4} ${box.height + 4}" width="${(box.width + 4) * fit.zoom}" height="${(box.height + 4) * fit.zoom}" data-viewport-width="${viewportWidth}" data-display-scale="${fit.zoom}" role="img" aria-label="${escape(options.title ?? input.document.documentId)}" font-family="Inter, system-ui, sans-serif"><title>${escape(options.title ?? input.document.documentId)}</title><style>@font-face{font-family:Inter;src:local('Inter');font-weight:100 900}svg{--st-font-sans:Inter,system-ui,sans-serif;--st-semantic-surface-raised:#fff;--st-semantic-surface-subtle:#f8fafc;--st-component-diagramZone-surface1:#fff;--st-component-diagramZone-surface2:#f8fafc;--st-semantic-text-primary:#172033;--st-semantic-text-secondary:#475569;--st-semantic-border-strong:#64748b;--st-semantic-border-subtle:#cbd5e1;--st-semantic-feedback-info:#2563eb}</style><defs><marker id="scene-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10Z" fill="var(--st-component-diagramScene-edgeStroke, #64748b)"/></marker>${maskDef}</defs>${frames}${connectors}${boxes}${labels}</svg>`;
61
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${box.x - 2} ${box.y - 2} ${box.width + 4} ${box.height + 4}" width="${(box.width + 4) * fit.zoom}" height="${(box.height + 4) * fit.zoom}" data-viewport-width="${viewportWidth}" data-display-scale="${fit.zoom}" role="img" aria-label="${escape(options.title ?? input.document.documentId)}" font-family="Inter, system-ui, sans-serif"><title>${escape(options.title ?? input.document.documentId)}</title><style>@font-face{font-family:Inter;src:local('Inter');font-weight:100 900}svg:root{--st-font-sans:Inter,system-ui,sans-serif;--st-semantic-surface-raised:#fff;--st-semantic-surface-subtle:#f8fafc;--st-component-diagramZone-surface1:#fff;--st-component-diagramZone-surface2:#f8fafc;--st-semantic-text-primary:#172033;--st-semantic-text-secondary:#475569;--st-semantic-border-strong:#64748b;--st-semantic-border-subtle:#cbd5e1;--st-semantic-feedback-info:#2563eb}</style><defs><marker id="scene-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10Z" fill="var(--st-component-diagramScene-edgeStroke, #64748b)"/></marker>${maskDef}</defs>${frames}${connectors}${boxes}${labels}</svg>`;
62
62
  return { svg, result, scene };
63
63
  }
64
64
  //# sourceMappingURL=renderSceneSvg.js.map
@@ -140,7 +140,7 @@ export function renderZoneSvg(props, opts = {}) {
140
140
  const { content, layout, diagnostics } = zoneContent(props, children, measure);
141
141
  const { x, y, width, height } = layout.box;
142
142
  const overflowSlots = diagnostics
143
- .filter((diagnostic) => diagnostic.code === "zone-overflow")
143
+ .filter((diagnostic) => diagnostic.code === "zone-overflow" && diagnostic.reason !== "fallback-v1")
144
144
  .map((diagnostic) => diagnostic.slot);
145
145
  const unknownIcon = diagnostics.some((diagnostic) => diagnostic.code === "zone-icon-unknown");
146
146
  const firstOverflow = overflowSlots.length === 0 ? undefined : overflowSlots[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentropic/diagram-canvas",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Headless diagram scenes, layout, hit testing and pure presentation models/SVG helpers. No DOM or framework.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -58,7 +58,7 @@
58
58
  "main": "./dist/index.js",
59
59
  "sideEffects": false,
60
60
  "dependencies": {
61
- "@sentropic/diagram-core": "0.4.0"
61
+ "@sentropic/diagram-core": "0.4.1"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node ../../scripts/sync-diagram-spacing.mjs && tsc -p tsconfig.json",