@sentropic/design-system-svelte 0.43.2 → 0.44.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.
@@ -7,6 +7,7 @@
7
7
  clampZoom,
8
8
  createLayoutCache,
9
9
  FIT_ASPECT,
10
+ isR7ConnectorPresentation,
10
11
  zoomReadout,
11
12
  type LayoutHints,
12
13
  type LayoutMetrics,
@@ -36,13 +37,24 @@
36
37
  } from "./diagramCardModel.js";
37
38
  import {
38
39
  collapsedOccurrencesOf,
40
+ connectorDashArray, connectorDashPaint,
41
+ connectorMarkerIds,
42
+ connectorMarkerRef,
43
+ connectorPath,
44
+ DEFAULT_EDGE_CORNER_RADIUS,
45
+ DEFAULT_EDGE_LABEL_SIZE,
39
46
  DEFAULT_SCENE_LABELS,
47
+ parseCssLengthPx,
48
+ resolveEdgeLabelSizeToken,
49
+ extraConnectorMarkers,
40
50
  sceneContentSize,
41
51
  type DiagramSceneSize,
42
52
  type SceneLayoutCache,
43
53
  DEFAULT_SCENE_TARGET_WIDTH,
44
54
  displayedRects,
45
55
  layoutScene,
56
+ linkLegendBoxStyle,
57
+ linkLegendSwatchGeometry,
46
58
  parseDurationMs,
47
59
  parseEasing,
48
60
  parseScale,
@@ -50,6 +62,7 @@
50
62
  resolveScene,
51
63
  resolveZoom,
52
64
  sameRects,
65
+ scaleEdgeLabelMeasurer,
53
66
  sceneConnectorMask,
54
67
  sceneFit,
55
68
  sceneNodesOnPlane,
@@ -58,6 +71,7 @@
58
71
  WHEEL_ZOOM_RATE,
59
72
  ZOOM_STEP_RATIO,
60
73
  type Easing,
74
+ type LinkLegendAnchor,
61
75
  type SceneDocument,
62
76
  type SceneModel,
63
77
  type SceneNodeModel,
@@ -124,6 +138,8 @@
124
138
  collapse: (title: string) => string;
125
139
  /** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
126
140
  contains?: string;
141
+ /** Heading for the automatic link-style legend strip (DE-2). */
142
+ legend?: string;
127
143
  }
128
144
 
129
145
  export interface DiagramSceneCamera {
@@ -171,11 +187,17 @@
171
187
  /** Accessible name of the figure. Defaults to `title`. */
172
188
  label?: string;
173
189
  compact?: boolean;
190
+ /** Opt-in fit-to-window host framing (`max-height: calc(100vh - 24px)`, `max-width: 100%`, centred; DE-2 ask 9). Default `false` preserves `Z-3 / AC-23`. */
191
+ fitToWindow?: boolean;
174
192
  labels?: Partial<DiagramSceneFigureLabels>;
175
193
  iconBindings?: import("@sentropic/diagram-canvas/diagramSceneModel").SceneIconBindings;
176
194
  strictIcons?: boolean;
177
195
  /** Selectable start parity for alternating zone depth surfaces (`0` default, `1` flipped). */
178
196
  depthParityStart?: 0 | 1;
197
+ /** Automatic link-style legend anchor (`"right"` default; `"none"` suppresses). */
198
+ legend?: LinkLegendAnchor;
199
+ /** Optional custom labels for automatic link-style legend entries, keyed by `linkStyleKey(...)`. */
200
+ legendLabels?: Readonly<Record<string, string>>;
179
201
  resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
180
202
  onFoldChange?: (
181
203
  collapsed: readonly SceneOccurrenceRef[],
@@ -215,11 +237,14 @@
215
237
  title,
216
238
  label,
217
239
  compact = false,
240
+ fitToWindow = false,
218
241
  labels,
219
242
  resolveGlyph = getDiagramGlyph,
220
243
  iconBindings,
221
244
  strictIcons = true,
222
245
  depthParityStart,
246
+ legend,
247
+ legendLabels,
223
248
  onFoldChange,
224
249
  onSelect,
225
250
  onLayout,
@@ -252,6 +277,7 @@
252
277
  const collapsedNow = $derived(collapsed ?? foldState);
253
278
  const arrowInstance = $props.id();
254
279
  const arrowId = "diagram-arrow-" + arrowInstance;
280
+ const markerIds = connectorMarkerIds(arrowId);
255
281
  const maskId = "diagram-connector-mask-" + arrowInstance;
256
282
  let browserMeasure = $state.raw<CardLineMeasure>();
257
283
  let frameWidth = $state<number>();
@@ -259,17 +285,64 @@
259
285
  let tokenMetrics = $state.raw<Partial<LayoutMetrics>>({});
260
286
  const effectiveMetrics = $derived({ ...tokenMetrics, ...metrics });
261
287
  const lineMeasurer = $derived<LineMeasurer>(measureLines ?? cardLineMeasurer(effectiveMeasure));
288
+ const r7Mode = $derived(isR7ConnectorPresentation(presentation, view, semanticDocument));
262
289
 
263
290
  // O-4: the orientation record last emitted, fed back to the next layout
264
291
  // call. Deliberately not reactive state: it is an input of the next pass,
265
292
  // never a reason to run one. A different document starts with no record.
293
+ // On r7 scenes only, returning to a previously visited fold state within the
294
+ // same non-fold input revision reuses the orientation seed recorded on its
295
+ // first visit so unfolding restores initial geometry; any revision, hint,
296
+ // metric, or measurer change resets that map, and legacy scenes keep main O-4.
266
297
  let previousOrientation: SceneOrientations | undefined;
267
298
  let orientationDocument: string | undefined;
299
+ let orientationInputTuple: readonly unknown[] | undefined;
300
+ const orientationSeedByFold = new Map<string, SceneOrientations | undefined>();
268
301
 
269
302
  const layoutResult = $derived.by<LayoutResult>(() => {
270
303
  if (orientationDocument !== semanticDocument.documentId) {
271
304
  orientationDocument = semanticDocument.documentId;
272
305
  previousOrientation = undefined;
306
+ orientationInputTuple = undefined;
307
+ orientationSeedByFold.clear();
308
+ }
309
+ let orientationSeed: SceneOrientations | undefined = previousOrientation;
310
+ if (r7Mode) {
311
+ const nextInputs: readonly unknown[] = [
312
+ semanticDocument,
313
+ semanticDocument.revision,
314
+ view,
315
+ presentation,
316
+ JSON.stringify(hints ?? null),
317
+ JSON.stringify(effectiveMetrics),
318
+ JSON.stringify(rowPack ?? null),
319
+ targetWidth,
320
+ lineMeasurer,
321
+ lineMeasurer.version,
322
+ JSON.stringify(flowOptions),
323
+ JSON.stringify(flowTokens),
324
+ iconBindings,
325
+ strictIcons,
326
+ depthParityStart,
327
+ ];
328
+ const sameNonFoldInputs =
329
+ orientationInputTuple !== undefined &&
330
+ orientationInputTuple.length === nextInputs.length &&
331
+ nextInputs.every((value, index) => Object.is(value, orientationInputTuple![index]));
332
+ if (!sameNonFoldInputs) {
333
+ orientationInputTuple = nextInputs;
334
+ orientationSeedByFold.clear();
335
+ }
336
+ const foldKey = [...collapsedNow].sort().join("\0");
337
+ orientationSeed = orientationSeedByFold.has(foldKey)
338
+ ? orientationSeedByFold.get(foldKey)
339
+ : previousOrientation;
340
+ if (!orientationSeedByFold.has(foldKey)) {
341
+ orientationSeedByFold.set(foldKey, orientationSeed);
342
+ }
343
+ } else if (orientationSeedByFold.size > 0 || orientationInputTuple !== undefined) {
344
+ orientationInputTuple = undefined;
345
+ orientationSeedByFold.clear();
273
346
  }
274
347
  const result = layoutScene({
275
348
  cache: layoutCache ?? ownedCache,
@@ -290,7 +363,7 @@
290
363
  metrics: effectiveMetrics,
291
364
  ...(rowPack === undefined ? {} : { rowPack }),
292
365
  ...(targetWidth === undefined ? {} : { targetWidth }),
293
- ...(previousOrientation === undefined ? {} : { previousOrientation }),
366
+ ...(orientationSeed === undefined ? {} : { previousOrientation: orientationSeed }),
294
367
  });
295
368
  if (result.status === "laid-out" && result.orientations !== undefined) {
296
369
  previousOrientation = result.orientations;
@@ -298,6 +371,21 @@
298
371
  return result;
299
372
  });
300
373
 
374
+ let viewWidth = $state<number>();
375
+ let windowHeight = $state<number>();
376
+ let scrollbarHeight = $state(0);
377
+ let maxDisplayScale = $state<number>();
378
+ let minReadableScale = $state<number>();
379
+ const sceneFitInput = $derived({
380
+ // Before the frame is measured (server render, hidden mount) the fit
381
+ // box is the nominal 16:9 box of the layout target width.
382
+ viewWidth: frameWidth ?? targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
383
+ windowHeight: windowHeight ?? Number.POSITIVE_INFINITY,
384
+ ...(maxDisplayScale === undefined ? {} : { maxDisplayScale }),
385
+ ...(minReadableScale === undefined ? {} : { minReadableScale }),
386
+ ...(fitToWindow ? { fitToWindow: true } : {}),
387
+ });
388
+
301
389
  const scene = $derived<SceneModel | undefined>(
302
390
  layoutResult.status === "laid-out"
303
391
  ? resolveScene(layoutResult, {
@@ -307,11 +395,14 @@
307
395
  ...(iconBindings === undefined ? {} : { iconBindings }),
308
396
  strictIcons,
309
397
  ...(depthParityStart === undefined ? {} : { depthParityStart }),
398
+ ...(legend === undefined ? {} : { legend }),
399
+ ...(strings.legend === undefined ? {} : { legendTitle: strings.legend }),
400
+ ...(legendLabels === undefined ? {} : { legendLabels }),
310
401
  resolveGlyph,
311
402
  measureLines: lineMeasurer,
312
403
  flows: flowOptions,
313
404
  metrics: effectiveMetrics,
314
- })
405
+ }, fitToWindow ? sceneFitInput : undefined)
315
406
  : undefined,
316
407
  );
317
408
  const sceneRects = $derived<ReadonlyMap<string, Rect>>(scene === undefined ? new Map() : rectsOf(scene));
@@ -497,11 +588,6 @@
497
588
  if (select !== undefined && select !== null) select.value = filter === undefined ? "all" : `scenario:${filter}`;
498
589
  }
499
590
  });
500
- let viewWidth = $state<number>();
501
- let windowHeight = $state<number>();
502
- let scrollbarHeight = $state(0);
503
- let maxDisplayScale = $state<number>();
504
- let minReadableScale = $state<number>();
505
591
  let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect }>();
506
592
  const cameraBounds = $derived(renderedBounds?.scene === scene ? renderedBounds?.bounds : scene?.bounds);
507
593
  // `zoom` is the scale the world is painted at: the fit is quantised once,
@@ -542,6 +628,28 @@
542
628
  return value === "" ? undefined : value;
543
629
  }
544
630
 
631
+ function lengthTokenValue(name: string): number | undefined {
632
+ if (frameEl === undefined) return undefined;
633
+ const raw = tokenValue(name);
634
+ if (raw === undefined) return undefined;
635
+ const docEl = frameEl.ownerDocument?.documentElement;
636
+ const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
637
+ const elementFontSize = parseFloat(getComputedStyle(frameEl).fontSize);
638
+ const context = { rootFontSize, elementFontSize };
639
+ const parsed = parseCssLengthPx(raw, context);
640
+ if (parsed !== undefined || !/^(calc|min|max|clamp)\(/i.test(raw)) return parsed;
641
+ const probe = frameEl.ownerDocument.createElement("span");
642
+ probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
643
+ probe.style.fontSize = raw;
644
+ if (probe.style.fontSize === "") return undefined;
645
+ frameEl.appendChild(probe);
646
+ try {
647
+ return parseCssLengthPx(getComputedStyle(probe).fontSize, context);
648
+ } finally {
649
+ probe.remove();
650
+ }
651
+ }
652
+
545
653
  // A user zoom lasts until the next resize, fold or font load.
546
654
  let requestedZoom = $state<number>();
547
655
  let fittedFonts: Promise<FontFaceSet> | undefined;
@@ -576,13 +684,30 @@
576
684
  // input, so a post-mount theme change applies without waiting for a resize.
577
685
  function readCameraTokens(): void {
578
686
  const values: Record<string, number> = {};
579
- for (const key of ["gapMin","gapMinBlock","gapBase","gapBaseBlock","trackSpacing","trackSpacingBlock","labelBand","gapMax","bundleLabelMaxWidth","containerPadding"]) {
580
- const value = parseFloat(tokenValue('--st-component-diagramScene-' + key) ?? '');
687
+ const baseKeys = ["gapMin","gapMinBlock","gapBase","gapBaseBlock","trackSpacing","trackSpacingBlock","labelBand","gapMax","bundleLabelMaxWidth","containerPadding"];
688
+ const r7Keys = ["zoneGutter","routeSpacing","routeBorderClearance","edgeCornerRadius","linkStrokeWidth","linkRelatedStrokeWidth","linkEmphasisStrokeWidth"];
689
+ for (const key of baseKeys) {
690
+ const value = parseFloat(tokenValue("--st-component-diagramScene-" + key) ?? "");
581
691
  if (Number.isFinite(value)) values[key] = value;
582
692
  }
583
- const labelMargin = parseFloat(tokenValue('--st-component-diagramScene-labelPadding') ?? '');
693
+ const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding") ?? "");
584
694
  if (Number.isFinite(labelMargin)) values.labelMargin = labelMargin;
585
- if (JSON.stringify(values) !== JSON.stringify(tokenMetrics)) tokenMetrics = values;
695
+ if (r7Mode) {
696
+ for (const key of r7Keys) {
697
+ const value = lengthTokenValue("--st-component-diagramScene-" + key);
698
+ if (value !== undefined && Number.isFinite(value)) values[key] = value;
699
+ }
700
+ const edgeLabelSize = resolveEdgeLabelSizeToken(
701
+ lengthTokenValue("--st-component-diagramScene-edgeLabelSize"),
702
+ lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize"),
703
+ );
704
+ if (edgeLabelSize !== undefined) values.edgeLabelSize = edgeLabelSize;
705
+ }
706
+
707
+ if (JSON.stringify(values) !== JSON.stringify(tokenMetrics)) {
708
+ ownedCache.clear();
709
+ tokenMetrics = values;
710
+ }
586
711
  const nextTokens = { ...DEFAULT_FLOW_TOKENS };
587
712
  for (const name of Object.keys(nextTokens) as (keyof FlowTokens)[]) {
588
713
  const value = tokenValue(`--st-component-diagramScene-${name}`);
@@ -594,6 +719,11 @@
594
719
  minReadableScale = parseScale(tokenValue(TOKEN_MIN_READABLE_SCALE));
595
720
  }
596
721
 
722
+ $effect(() => {
723
+ void r7Mode;
724
+ untrack(readCameraTokens);
725
+ });
726
+
597
727
  let previousFrameHeight: number | undefined;
598
728
  let previousViewportHeight = 0;
599
729
 
@@ -645,12 +775,7 @@
645
775
  const measured = $derived(frameWidth !== undefined && windowHeight !== undefined);
646
776
  const fitInput = $derived({
647
777
  ...(cameraBounds === undefined ? {} : { bounds: cameraBounds }),
648
- // Before the frame is measured (server render, hidden mount) the fit
649
- // box is the nominal 16:9 box of the layout target width.
650
- viewWidth: frameWidth ?? targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
651
- windowHeight: windowHeight ?? Number.POSITIVE_INFINITY,
652
- ...(maxDisplayScale === undefined ? {} : { maxDisplayScale }),
653
- ...(minReadableScale === undefined ? {} : { minReadableScale }),
778
+ ...sceneFitInput,
654
779
  });
655
780
  // Try the full width first so scrollbars from a user zoom cannot trap
656
781
  // the next fit at the floor. If it still pans, account for the bars.
@@ -961,12 +1086,31 @@
961
1086
 
962
1087
  const erdTable = $derived(semanticDocument.profileRefs.includes("erd@1") ? renderErdTable(semanticDocument) : "");
963
1088
 
1089
+ const edgeCornerRadius = $derived(effectiveMetrics.edgeCornerRadius ?? DEFAULT_EDGE_CORNER_RADIUS);
1090
+ const pathOf = (points: readonly { readonly x: number; readonly y: number }[]): string =>
1091
+ connectorPath(points, edgeCornerRadius);
964
1092
  const pointsOf = (points: readonly { readonly x: number; readonly y: number }[]): string =>
965
1093
  points.map((point) => `${point.x},${point.y}`).join(" ");
966
1094
 
967
- const edgeLabelLineHeight = $derived(lineMeasurer({ text: "Mg", role: "edge-label", availableWidth: 400, allocatedLines: 1, folded: false }).height);
1095
+ const edgeLabelLineHeight = $derived(scaleEdgeLabelMeasurer(lineMeasurer, r7Mode ? effectiveMetrics.edgeLabelSize : undefined)({ text: "Mg", role: "edge-label", availableWidth: 400, allocatedLines: 1, folded: false }).height);
1096
+ const metricPaintVars = $derived(
1097
+ !r7Mode ? "" :
1098
+ (metrics?.edgeLabelSize !== undefined ||
1099
+ (effectiveMetrics.edgeLabelSize !== undefined && effectiveMetrics.edgeLabelSize !== DEFAULT_EDGE_LABEL_SIZE)
1100
+ ? `;--st-diagram-edge-label-size:${effectiveMetrics.edgeLabelSize}px`
1101
+ : "") +
1102
+ (metrics?.linkStrokeWidth !== undefined ? `;--st-diagram-link-stroke-width:${metrics.linkStrokeWidth}px` : "") +
1103
+ (metrics?.linkRelatedStrokeWidth !== undefined ? `;--st-diagram-link-related-stroke-width:${metrics.linkRelatedStrokeWidth}px` : "") +
1104
+ (metrics?.linkEmphasisStrokeWidth !== undefined ? `;--st-diagram-link-emphasis-stroke-width:${metrics.linkEmphasisStrokeWidth}px` : ""),
1105
+ );
1106
+ const overviewLabelPaintVars = $derived.by(() => {
1107
+ const size = scene?.overviewEdgeLabelSize;
1108
+ if (size === undefined) return "";
1109
+ const lineHeight = edgeLabelLineHeight * size / (effectiveMetrics.edgeLabelSize ?? DEFAULT_EDGE_LABEL_SIZE);
1110
+ return `;--st-diagram-overview-edge-label-size:${size}px;--st-diagram-overview-edge-label-line-height:${lineHeight}px`;
1111
+ });
968
1112
  const viewportStyle = $derived(
969
- `height:${viewportHeight}px;aspect-ratio:${FIT_ASPECT};overflow-x:${placement.overflowX ? 'auto' : 'hidden'};overflow-y:${placement.overflowY ? 'auto' : 'hidden'};--st-diagram-zoom:${zoom};--st-diagram-label-line-height:${edgeLabelLineHeight}px${flowSteps.length > 0 ? `;--st-diagramSceneFigure-flowHit:${flowHitSize(zoom, flowTokens)}px` : ""}`,
1113
+ `height:${viewportHeight}px;${fitToWindow ? "max-height:calc(100vh - 24px);max-width:100%;margin-inline:auto;" : `aspect-ratio:${FIT_ASPECT};`}overflow-x:${placement.overflowX ? 'auto' : 'hidden'};overflow-y:${placement.overflowY ? 'auto' : 'hidden'};--st-diagram-zoom:${zoom};--st-diagram-label-line-height:${edgeLabelLineHeight}px${metricPaintVars}${overviewLabelPaintVars}${flowSteps.length > 0 ? `;--st-diagramSceneFigure-flowHit:${flowHitSize(zoom, flowTokens)}px` : ""}`,
970
1114
  );
971
1115
  const worldStyle = $derived(
972
1116
  `transform:translate(${placement.translateX}px,${placement.translateY}px) scale(${zoom})`,
@@ -974,10 +1118,11 @@
974
1118
  </script>
975
1119
 
976
1120
  <figure
977
- class="st-diagramSceneFigure{compact ? " st-diagramSceneFigure--compact" : ""}"
1121
+ class="st-diagramSceneFigure{compact ? " st-diagramSceneFigure--compact" : ""}{fitToWindow ? " st-diagramSceneFigure--fitToWindow" : ""}"
978
1122
  aria-label={label ?? title}
979
1123
  data-zoom={zoom}
980
1124
  data-zoom-readout={readout}
1125
+ data-fit-to-window={fitToWindow ? "true" : undefined}
981
1126
  data-scene-refused={layoutResult.status === "refused" ? layoutResult.refusals[0]?.code : undefined}
982
1127
  >
983
1128
  {#if title !== undefined}
@@ -1076,6 +1221,7 @@
1076
1221
  </div>
1077
1222
  {/snippet}
1078
1223
  {@const connectorMask = sceneConnectorMask(scene)}
1224
+ {@const extraMarkers = extraConnectorMarkers(scene.edges, markerIds)}
1079
1225
  <!-- Paint order (diagram-canvas `scenePaintPlane`): expanded zone
1080
1226
  frames, connectors, boxes, labels last. A zone frame is opaque:
1081
1227
  painted after the connectors it would hide every route that
@@ -1089,10 +1235,14 @@
1089
1235
  aria-hidden="true"
1090
1236
  style={animating ? `opacity:${eased}` : undefined}
1091
1237
  >
1092
- <defs><marker id={arrowId} 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>{#if connectorMask !== undefined}<mask id={maskId} maskUnits="userSpaceOnUse" x={connectorMask.region.x} y={connectorMask.region.y} width={connectorMask.region.width} height={connectorMask.region.height}><rect x={connectorMask.region.x} y={connectorMask.region.y} width={connectorMask.region.width} height={connectorMask.region.height} fill="#fff" />{#each connectorMask.cutouts as cutout, index (index)}<rect data-scene-cutout={index} x={cutout.x} y={cutout.y} width={cutout.width} height={cutout.height} fill="#000" />{/each}</mask>{/if}</defs>
1238
+ <defs><marker id={arrowId} viewBox="0 0 10 10" refX="9" refY="5" markerUnits={scene.r7Connectors ? "userSpaceOnUse" : undefined} markerWidth={scene.r7Connectors ? "10.5" : "7"} markerHeight={scene.r7Connectors ? "10.5" : "7"} orient="auto-start-reverse"><path d="M0 0L10 5L0 10Z" fill="var(--st-component-diagramScene-edgeStroke, #64748b)" /></marker>{#each extraMarkers as marker (marker.id)}<marker id={marker.id} data-arrowhead-kind={marker.kind} data-arrowhead-emphasis={marker.emphasis} viewBox={marker.viewBox} refX={marker.refX} refY={marker.refY} markerUnits={marker.markerUnits} markerWidth={marker.markerWidth} markerHeight={marker.markerHeight} orient={marker.orient}><path d={marker.path} fill={marker.fill} stroke={marker.stroke} stroke-width={marker.strokeWidth} /></marker>{/each}{#if connectorMask !== undefined}<mask id={maskId} maskUnits="userSpaceOnUse" x={connectorMask.region.x} y={connectorMask.region.y} width={connectorMask.region.width} height={connectorMask.region.height}><rect x={connectorMask.region.x} y={connectorMask.region.y} width={connectorMask.region.width} height={connectorMask.region.height} fill="#fff" />{#each connectorMask.cutouts as cutout, index (index)}<rect data-scene-cutout={index} x={cutout.x} y={cutout.y} width={cutout.width} height={cutout.height} fill="#000" />{/each}</mask>{/if}</defs>
1093
1239
  <g data-scene-connectors="" mask={connectorMask === undefined ? undefined : `url(#${maskId})`}>
1094
1240
  {#each scene.edges as edge (edge.occurrence)}
1095
- <polyline marker-end={edge.markers === undefined && !edge.directed ? `url(#${arrowId})` : undefined} class="st-diagramSceneFigure-edge" data-scene-edge={edge.occurrence} data-flow-step={edge.flow?.relation} data-flow-bundle={edge.bundle?.id} data-flow-state={stateOf(edge.occurrence)} points={pointsOf(edge.points)} />
1241
+ {#if edge.r7}
1242
+ <path marker-end={connectorMarkerRef(edge, markerIds)} stroke-dasharray={connectorDashArray(edge.strokeStyle)} style={connectorDashPaint(edge.strokeStyle)} class="st-diagramSceneFigure-edge" data-scene-edge={edge.occurrence} data-connector-mode="r7" data-edge-stroke={edge.strokeStyle} data-edge-arrowhead={edge.arrowhead} data-edge-emphasis={edge.emphasis} data-flow-step={edge.flow?.relation} data-flow-bundle={edge.bundle?.id} data-flow-state={stateOf(edge.occurrence)} d={pathOf(edge.points)} />
1243
+ {:else}
1244
+ <polyline marker-end={edge.markers === undefined && !edge.directed ? `url(#${arrowId})` : undefined} class="st-diagramSceneFigure-edge" data-scene-edge={edge.occurrence} data-flow-step={edge.flow?.relation} data-flow-bundle={edge.bundle?.id} data-flow-state={stateOf(edge.occurrence)} points={pointsOf(edge.points)} />
1245
+ {/if}
1096
1246
  {#if edge.directed}
1097
1247
  <polyline class="st-diagramSceneFigure-flowHit" data-flow-hit={edge.occurrence} points={pointsOf(edge.points)} />
1098
1248
  {#each edge.arrows as arrow, index (index)}
@@ -1104,7 +1254,13 @@
1104
1254
  {#if edge.markers}<g>{@html edge.markers}</g>{/if}
1105
1255
  {/each}
1106
1256
  {#each scene.labels as edgeLabel (edgeLabel.occurrence)}
1107
- {#if edgeLabel.leader}<polyline class="st-diagramSceneFigure-edge" points={pointsOf(edgeLabel.leader)} />{/if}
1257
+ {#if edgeLabel.leader}
1258
+ {#if scene.r7Connectors && !edgeLabel.erd}
1259
+ <path class="st-diagramSceneFigure-edge" data-connector-mode="r7" d={pathOf(edgeLabel.leader)} />
1260
+ {:else}
1261
+ <polyline class="st-diagramSceneFigure-edge" points={pointsOf(edgeLabel.leader)} />
1262
+ {/if}
1263
+ {/if}
1108
1264
  {/each}
1109
1265
  </g>
1110
1266
  </svg>
@@ -1121,6 +1277,7 @@
1121
1277
  <div
1122
1278
  class="st-diagramSceneFigure-edgeLabel"
1123
1279
  data-scene-label={edgeLabel.occurrence}
1280
+ data-connector-mode={scene.r7Connectors && !edgeLabel.erd ? "r7" : undefined}
1124
1281
  title={edgeLabel.title}
1125
1282
  data-erd-label={edgeLabel.erd || undefined}
1126
1283
  style={`left:${edgeLabel.box.x}px;top:${edgeLabel.box.y}px;width:${edgeLabel.box.width}px;height:${edgeLabel.box.height}px${animating ? `;opacity:${eased}` : ""}`}
@@ -1137,6 +1294,52 @@
1137
1294
  {/if}
1138
1295
  </div>
1139
1296
  {/each}
1297
+ {#if scene.linkLegend !== undefined}
1298
+ <aside
1299
+ class="st-diagramSceneFigure-legend"
1300
+ role="region"
1301
+ aria-label={scene.linkLegend.title}
1302
+ data-scene-legend=""
1303
+ data-legend-anchor={scene.linkLegend.anchor}
1304
+ style={linkLegendBoxStyle(scene.linkLegend, animating ? eased : undefined)}
1305
+ >
1306
+ <div class="st-diagramSceneFigure-legendTitle">{scene.linkLegend.title}</div>
1307
+ <ul class="st-diagramSceneFigure-legendList">
1308
+ {#each scene.linkLegend.entries as entry (entry.key)}
1309
+ {@const swatch = linkLegendSwatchGeometry(entry, effectiveMetrics)}
1310
+ <li
1311
+ class="st-diagramSceneFigure-legendItem"
1312
+ data-legend-style={entry.key}
1313
+ data-edge-stroke={entry.strokeStyle}
1314
+ data-edge-arrowhead={entry.arrowhead}
1315
+ data-edge-emphasis={entry.emphasis}
1316
+ >
1317
+ <svg class="st-diagramSceneFigure-legendSwatch" viewBox={swatch.viewBox} aria-hidden="true">
1318
+ <path
1319
+ data-legend-swatch={entry.key}
1320
+ d={swatch.linePath}
1321
+ fill="none"
1322
+ stroke={swatch.stroke}
1323
+ stroke-width={swatch.strokeWidth}
1324
+ stroke-dasharray={swatch.dashArray}
1325
+ style={connectorDashPaint(entry.strokeStyle)}
1326
+ vector-effect="non-scaling-stroke"
1327
+ />
1328
+ {#if swatch.arrowPath !== undefined}
1329
+ <path
1330
+ d={swatch.arrowPath}
1331
+ fill={swatch.arrowFill}
1332
+ stroke={swatch.arrowStroke}
1333
+ stroke-width={swatch.arrowStrokeWidth}
1334
+ />
1335
+ {/if}
1336
+ </svg>
1337
+ <span class="st-diagramSceneFigure-legendLabel">{entry.label}</span>
1338
+ </li>
1339
+ {/each}
1340
+ </ul>
1341
+ </aside>
1342
+ {/if}
1140
1343
  {/if}
1141
1344
  </div>
1142
1345
  </div>
@@ -1184,6 +1387,15 @@
1184
1387
  .st-diagramSceneFigure--compact {
1185
1388
  gap: var(--st-spacing-1, 0.25rem);
1186
1389
  }
1390
+ .st-diagramSceneFigure--fitToWindow {
1391
+ margin-inline: auto;
1392
+ max-width: 100%;
1393
+ }
1394
+ .st-diagramSceneFigure--fitToWindow .st-diagramSceneFigure-viewport {
1395
+ margin-inline: auto;
1396
+ max-height: calc(100vh - var(--st-spacing-6, 1.5rem));
1397
+ max-width: 100%;
1398
+ }
1187
1399
  .st-diagramSceneFigure-title {
1188
1400
  color: var(--st-semantic-text-primary);
1189
1401
  grid-column: 1;
@@ -1264,6 +1476,16 @@
1264
1476
  stroke-width: var(--st-component-diagramZone-borderWidth, 1.5px);
1265
1477
  vector-effect: non-scaling-stroke;
1266
1478
  }
1479
+ .st-diagramSceneFigure-edge[data-connector-mode="r7"] {
1480
+ stroke-width: var(--st-diagram-link-stroke-width, var(--st-component-diagramScene-linkStrokeWidth, 2.5px));
1481
+ }
1482
+ .st-diagramSceneFigure-edge[data-connector-mode="r7"][data-edge-arrowhead="none"] {
1483
+ stroke-width: var(--st-diagram-link-related-stroke-width, var(--st-component-diagramScene-linkRelatedStrokeWidth, 3px));
1484
+ }
1485
+ .st-diagramSceneFigure-edge[data-connector-mode="r7"][data-edge-emphasis="emphasis"] {
1486
+ stroke: var(--st-component-diagramScene-linkEmphasisStroke, var(--st-semantic-border-interactive));
1487
+ stroke-width: var(--st-diagram-link-emphasis-stroke-width, var(--st-component-diagramScene-linkEmphasisStrokeWidth, 3.5px));
1488
+ }
1267
1489
  .st-diagramSceneFigure-edgeLabel {
1268
1490
  box-sizing: border-box;
1269
1491
  background: var(--st-component-diagramScene-labelSurface, var(--st-semantic-surface-raised));
@@ -1280,8 +1502,61 @@
1280
1502
  position: absolute;
1281
1503
  white-space: nowrap;
1282
1504
  }
1283
- .st-diagramSceneFigure-edgeLabel > span { display: block; flex: none; height: var(--st-diagram-label-line-height, 22px); }
1505
+ .st-diagramSceneFigure-edgeLabel[data-connector-mode="r7"] {
1506
+ font-size: var(--st-diagram-overview-edge-label-size, var(--st-diagram-edge-label-size, var(--st-component-diagramScene-edgeLabelSize, var(--st-component-diagramScene-edgeLabelFontSize, 18px))));
1507
+ --st-diagram-edge-label-line-height: var(--st-diagram-overview-edge-label-line-height, var(--st-diagram-label-line-height, 22px));
1508
+ line-height: var(--st-diagram-edge-label-line-height);
1509
+ }
1510
+ .st-diagramSceneFigure-edgeLabel > span { display: block; flex: none; height: var(--st-diagram-edge-label-line-height, var(--st-diagram-label-line-height, 22px)); }
1284
1511
  .st-diagramSceneFigure-bundleHeader { display: block; padding: var(--st-component-diagramScene-labelPadding, 4px); font-weight: 400; }
1285
1512
  .st-diagramSceneFigure-bundleRelation { display: flex; align-self: stretch; gap: var(--st-component-diagramScene-bundleMarkerGap, 6px); padding: var(--st-component-diagramScene-labelPadding, 4px); box-shadow: inset 0 var(--st-component-diagramScene-labelBorderWidth, 1px) 0 var(--st-component-diagramScene-labelBorder, var(--st-semantic-border-subtle)); }
1286
1513
  .st-diagramSceneFigure-bundleRelation div { display: flex; flex-direction: column; }
1514
+ .st-diagramSceneFigure-legend {
1515
+ background: var(--st-component-diagramScene-labelSurface, var(--st-semantic-surface-raised));
1516
+ box-shadow: inset 0 0 0 var(--st-component-diagramScene-labelBorderWidth, 1px) var(--st-component-diagramScene-labelBorder, var(--st-semantic-border-subtle));
1517
+ box-sizing: border-box;
1518
+ color: var(--st-component-diagramScene-labelText, var(--st-semantic-text-primary));
1519
+ display: flex;
1520
+ flex-direction: column;
1521
+ font-family: var(--st-component-diagramCard-fontFamily, var(--st-font-sans, Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif));
1522
+ font-size: var(--st-diagram-legend-font-size, var(--st-component-diagramScene-edgeLabelSize, var(--st-component-diagramScene-edgeLabelFontSize, 18px)));
1523
+ gap: var(--st-diagram-legend-header-gap);
1524
+ line-height: var(--st-diagram-label-line-height, var(--st-component-diagramScene-edgeLabelLineHeight, 22px));
1525
+ padding: var(--st-diagram-legend-padding);
1526
+ position: absolute;
1527
+ }
1528
+ .st-diagramSceneFigure-legendTitle {
1529
+ align-items: center;
1530
+ border-bottom: var(--st-component-diagramScene-labelBorderWidth, 1px) solid var(--st-component-diagramScene-labelBorder, var(--st-semantic-border-subtle));
1531
+ box-sizing: border-box;
1532
+ display: flex;
1533
+ flex: none;
1534
+ font-weight: var(--st-component-diagramCard-titleFontWeight, 700);
1535
+ height: var(--st-diagram-legend-header-height);
1536
+ white-space: nowrap;
1537
+ }
1538
+ .st-diagramSceneFigure-legendList {
1539
+ display: flex;
1540
+ flex-direction: column;
1541
+ gap: var(--st-diagram-legend-row-gap);
1542
+ list-style: none;
1543
+ margin: 0;
1544
+ padding: 0;
1545
+ }
1546
+ .st-diagramSceneFigure-legendItem {
1547
+ align-items: center;
1548
+ box-sizing: border-box;
1549
+ display: flex;
1550
+ flex: none;
1551
+ gap: var(--st-diagram-legend-swatch-gap);
1552
+ height: var(--st-diagram-legend-row-height);
1553
+ white-space: nowrap;
1554
+ }
1555
+ .st-diagramSceneFigure-legendSwatch {
1556
+ flex: none;
1557
+ height: var(--st-diagram-legend-swatch-height);
1558
+ overflow: visible;
1559
+ width: var(--st-diagram-legend-swatch-width);
1560
+ }
1561
+ .st-diagramSceneFigure-legendLabel { white-space: nowrap; }
1287
1562
  </style>
@@ -1,7 +1,7 @@
1
1
  import { type LayoutHints, type LayoutMetrics, type LayoutOptions, type LayoutResult, type LineMeasurer, type RowPackOptions } from "@sentropic/diagram-canvas";
2
2
  import { type StepChange, type EffectiveTarget } from "@sentropic/diagram-canvas/flowModel";
3
3
  import { type CardLineMeasure, type DiagramGlyphPaths } from "./diagramCardModel.js";
4
- import { type DiagramSceneSize, type SceneLayoutCache, type SceneDocument, type SceneOccurrenceRef, type ScenePresentation, type SceneView } from "@sentropic/diagram-canvas/diagramSceneModel";
4
+ import { type DiagramSceneSize, type SceneLayoutCache, type LinkLegendAnchor, type SceneDocument, type SceneOccurrenceRef, type ScenePresentation, type SceneView } from "@sentropic/diagram-canvas/diagramSceneModel";
5
5
  /**
6
6
  * `DiagramSceneFigure` — the generic scene host (DC-2a lot L4,
7
7
  * SPEC_EVOL_DC2A §4.3, §5, §6.7 and Appendix D; CARDS §7.6).
@@ -59,6 +59,8 @@ export interface DiagramSceneFigureLabels {
59
59
  collapse: (title: string) => string;
60
60
  /** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
61
61
  contains?: string;
62
+ /** Heading for the automatic link-style legend strip (DE-2). */
63
+ legend?: string;
62
64
  }
63
65
  export interface DiagramSceneCamera {
64
66
  readonly zoom: number;
@@ -106,11 +108,17 @@ export interface DiagramSceneFigureProps {
106
108
  /** Accessible name of the figure. Defaults to `title`. */
107
109
  label?: string;
108
110
  compact?: boolean;
111
+ /** Opt-in fit-to-window host framing (`max-height: calc(100vh - 24px)`, `max-width: 100%`, centred; DE-2 ask 9). Default `false` preserves `Z-3 / AC-23`. */
112
+ fitToWindow?: boolean;
109
113
  labels?: Partial<DiagramSceneFigureLabels>;
110
114
  iconBindings?: import("@sentropic/diagram-canvas/diagramSceneModel").SceneIconBindings;
111
115
  strictIcons?: boolean;
112
116
  /** Selectable start parity for alternating zone depth surfaces (`0` default, `1` flipped). */
113
117
  depthParityStart?: 0 | 1;
118
+ /** Automatic link-style legend anchor (`"right"` default; `"none"` suppresses). */
119
+ legend?: LinkLegendAnchor;
120
+ /** Optional custom labels for automatic link-style legend entries, keyed by `linkStyleKey(...)`. */
121
+ legendLabels?: Readonly<Record<string, string>>;
114
122
  resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
115
123
  onFoldChange?: (collapsed: readonly SceneOccurrenceRef[], change: {
116
124
  occurrence: SceneOccurrenceRef;
@@ -1 +1 @@
1
- {"version":3,"file":"DiagramSceneFigure.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramSceneFigure.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAMH,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASrC,OAAO,EAA+L,KAAK,UAAU,EAAE,KAAK,eAAe,EAAoB,MAAM,qCAAqC,CAAC;AAC3S,OAAO,EAMH,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AACjC,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAmBrB,KAAK,aAAa,EAGlB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,6CAA6C,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,M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kB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"diagramRenderedBounds.d.ts","sourceRoot":"","sources":["../src/lib/diagramRenderedBounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,+BAA+B,QAA8C,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CASzF;AAuDD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CA8ExH"}
1
+ {"version":3,"file":"diagramRenderedBounds.d.ts","sourceRoot":"","sources":["../src/lib/diagramRenderedBounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,+BAA+B,QAA8C,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CASzF;AAkED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CA8ExH"}
@@ -46,8 +46,10 @@ export function shouldRefitRenderedBounds(previous, next) {
46
46
  const delta = Math.max(Math.abs(next.x - previous.x), Math.abs(next.y - previous.y), Math.abs(next.x + next.width - previous.x - previous.width), Math.abs(next.y + next.height - previous.y - previous.height));
47
47
  return delta > RENDERED_BOUNDS_REFIT_TOLERANCE;
48
48
  }
49
- /** Token default of a resting connector stroke, CSS px. */
50
- const RESTING_EDGE_STROKE_WIDTH = 1.5;
49
+ /** Token default of a resting numbered-flow stroke, CSS px (DC-2c). */
50
+ const RESTING_FLOW_STROKE_WIDTH = 1.5;
51
+ /** Token default of a resting connector stroke, CSS px (DE-2 `linkStrokeWidth`). */
52
+ const RESTING_EDGE_STROKE_WIDTH = 2.5;
51
53
  /** Whether a computed colour paints nothing: `transparent` or a zero alpha. */
52
54
  function isTransparent(color) {
53
55
  const value = color.trim().toLowerCase();
@@ -60,11 +62,11 @@ function isTransparent(color) {
60
62
  }
61
63
  /**
62
64
  * What the scene hosts fade during a fold transition: the connector layer,
63
- * the edge labels and the entering nodes. A zero opacity on one of these is
64
- * a frame of that fade, not a hidden element: it is painted once the
65
- * transition settles, and the fit has to frame it.
65
+ * the edge labels, the entering nodes and the automatic link legend. A zero
66
+ * opacity on one of these is a frame of that fade, not a hidden element: it
67
+ * is painted once the transition settles, and the fit has to frame it.
66
68
  */
67
- const TRANSITION_FADED = '.st-diagramSceneFigure-edges,.st-diagramSceneFigure-edgeLabel,.st-diagramSceneFigure-node';
69
+ const TRANSITION_FADED = '.st-diagramSceneFigure-edges,.st-diagramSceneFigure-edgeLabel,.st-diagramSceneFigure-node,.st-diagramSceneFigure-legend';
68
70
  /** Whether an element removes itself and its subtree from the paint for
69
71
  * good: not rendered, fully transparent at rest, or clipped to nothing (the
70
72
  * screen-reader-only idioms: `clip-path: inset(50%)`, `clip: rect(0 0 0 0)`,
@@ -96,9 +98,18 @@ function restingStrokeWidth(element, style) {
96
98
  const state = element.getAttribute('data-flow-state');
97
99
  if (state !== 'primary' && state !== 'related')
98
100
  return width;
99
- const token = element.hasAttribute('data-flow-step') ? '--st-component-diagramScene-flowStrokeWidth' : '--st-component-diagramZone-borderWidth';
101
+ const isFlow = element.hasAttribute('data-flow-step');
102
+ const isR7 = element.getAttribute('data-connector-mode') === 'r7';
103
+ const token = isFlow
104
+ ? '--st-component-diagramScene-flowStrokeWidth'
105
+ : element.getAttribute('data-edge-emphasis') === 'emphasis'
106
+ ? '--st-component-diagramScene-linkEmphasisStrokeWidth'
107
+ : isR7
108
+ ? '--st-component-diagramScene-linkStrokeWidth'
109
+ : '--st-component-diagramZone-borderWidth';
100
110
  const resting = parseFloat(style.getPropertyValue(token));
101
- return Number.isFinite(resting) ? resting : Math.min(width, RESTING_EDGE_STROKE_WIDTH);
111
+ const fallbackWidth = isFlow || !isR7 ? RESTING_FLOW_STROKE_WIDTH : RESTING_EDGE_STROKE_WIDTH;
112
+ return Number.isFinite(resting) ? resting : Math.min(width, fallbackWidth);
102
113
  }
103
114
  /**
104
115
  * Painted bounds in world units, after font/layout settling. DOM-free scene
@@ -169,7 +180,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
169
180
  // computed value of the painting element itself counts.
170
181
  const paints = (element) => !element.closest('defs,[hidden],[data-flow-hit],[data-flow-node]')
171
182
  && styleOf(element).visibility !== 'hidden' && styleOf(element).visibility !== 'collapse' && inPaintedSubtree(element);
172
- for (const element of world.querySelectorAll('[data-scene-occurrence],.st-diagramCard,.st-diagramZone,[data-scene-label],[data-diagram-icon],.st-badge,[data-badge],.st-diagramCard-rule,.st-diagramZone-rule,.st-diagramZone-footerRule,button,svg polyline,svg path,svg line,svg rect,svg circle,svg text')) {
183
+ for (const element of world.querySelectorAll('[data-scene-occurrence],.st-diagramCard,.st-diagramZone,[data-scene-label],[data-scene-legend],[data-diagram-icon],.st-badge,[data-badge],.st-diagramCard-rule,.st-diagramZone-rule,.st-diagramZone-footerRule,button,svg polyline,svg path,svg line,svg rect,svg circle,svg text')) {
173
184
  if (!paints(element))
174
185
  continue;
175
186
  const style = styleOf(element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentropic/design-system-svelte",
3
- "version": "0.43.2",
3
+ "version": "0.44.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -65,8 +65,8 @@
65
65
  "@lucide/svelte": "^0.562.0",
66
66
  "@sentropic/design-system-review-core": "0.1.0",
67
67
  "@sentropic/design-system-rich-text": "0.1.1",
68
- "@sentropic/design-system-themes": "0.15.2",
69
- "@sentropic/diagram-canvas": "0.3.2",
68
+ "@sentropic/design-system-themes": "0.16.0",
69
+ "@sentropic/diagram-canvas": "0.4.0",
70
70
  "@sentropic/graph": "0.3.1"
71
71
  },
72
72
  "peerDependencies": {
@@ -98,7 +98,7 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@sentropic/design-system-theme-dsfr": "0.2.2",
101
- "@sentropic/design-system-themes": "0.15.2",
101
+ "@sentropic/design-system-themes": "0.16.0",
102
102
  "@sveltejs/package": "^2.5.0",
103
103
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
104
104
  "@testing-library/svelte": "^5.2.8",