@sentropic/design-system-svelte 0.43.2 → 0.44.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.
- package/LICENSE.THIRD-PARTY.md +4 -4
- package/dist/DiagramSceneFigure.svelte +581 -46
- package/dist/DiagramSceneFigure.svelte.d.ts +16 -1
- package/dist/DiagramSceneFigure.svelte.d.ts.map +1 -1
- package/dist/diagramRenderedBounds.d.ts +28 -20
- package/dist/diagramRenderedBounds.d.ts.map +1 -1
- package/dist/diagramRenderedBounds.js +62 -31
- package/package.json +4 -4
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getDiagramGlyph } from "./diagram-icons/registry.js";
|
|
3
3
|
import { tick, untrack } from "svelte";
|
|
4
|
-
import { Minus, Plus } from "@lucide/svelte";
|
|
4
|
+
import { Maximize2, Minimize2, Minus, Plus, Scan } from "@lucide/svelte";
|
|
5
5
|
import {
|
|
6
6
|
renderErdCardSvg, renderErdTable,
|
|
7
7
|
clampZoom,
|
|
8
8
|
createLayoutCache,
|
|
9
|
+
DEFAULT_MIN_READABLE_SCALE,
|
|
9
10
|
FIT_ASPECT,
|
|
11
|
+
isR7ConnectorPresentation,
|
|
10
12
|
zoomReadout,
|
|
11
13
|
type LayoutHints,
|
|
12
14
|
type LayoutMetrics,
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
import DiagramCard from "./DiagramCard.svelte";
|
|
21
23
|
import DiagramZone from "./DiagramZone.svelte";
|
|
22
24
|
import IconButton from "./IconButton.svelte";
|
|
23
|
-
import { measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
|
|
25
|
+
import { committedWorldScale, measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
|
|
24
26
|
import { measureRenderedSceneFont } from "./diagramFontMeasure.js";
|
|
25
27
|
import Select from "./Select.svelte";
|
|
26
28
|
import { DEFAULT_FLOW_TOKENS, type FlowTokens } from "@sentropic/diagram-canvas";
|
|
@@ -36,13 +38,24 @@
|
|
|
36
38
|
} from "./diagramCardModel.js";
|
|
37
39
|
import {
|
|
38
40
|
collapsedOccurrencesOf,
|
|
41
|
+
connectorDashArray, connectorDashPaint,
|
|
42
|
+
connectorMarkerIds,
|
|
43
|
+
connectorMarkerRef,
|
|
44
|
+
connectorPath,
|
|
45
|
+
DEFAULT_EDGE_CORNER_RADIUS,
|
|
46
|
+
DEFAULT_EDGE_LABEL_SIZE,
|
|
39
47
|
DEFAULT_SCENE_LABELS,
|
|
48
|
+
parseCssLengthPx,
|
|
49
|
+
resolveEdgeLabelSizeToken,
|
|
50
|
+
extraConnectorMarkers,
|
|
40
51
|
sceneContentSize,
|
|
41
52
|
type DiagramSceneSize,
|
|
42
53
|
type SceneLayoutCache,
|
|
43
54
|
DEFAULT_SCENE_TARGET_WIDTH,
|
|
44
55
|
displayedRects,
|
|
45
56
|
layoutScene,
|
|
57
|
+
linkLegendBoxStyle,
|
|
58
|
+
linkLegendSwatchGeometry,
|
|
46
59
|
parseDurationMs,
|
|
47
60
|
parseEasing,
|
|
48
61
|
parseScale,
|
|
@@ -50,6 +63,7 @@
|
|
|
50
63
|
resolveScene,
|
|
51
64
|
resolveZoom,
|
|
52
65
|
sameRects,
|
|
66
|
+
scaleEdgeLabelMeasurer,
|
|
53
67
|
sceneConnectorMask,
|
|
54
68
|
sceneFit,
|
|
55
69
|
sceneNodesOnPlane,
|
|
@@ -58,6 +72,7 @@
|
|
|
58
72
|
WHEEL_ZOOM_RATE,
|
|
59
73
|
ZOOM_STEP_RATIO,
|
|
60
74
|
type Easing,
|
|
75
|
+
type LinkLegendAnchor,
|
|
61
76
|
type SceneDocument,
|
|
62
77
|
type SceneModel,
|
|
63
78
|
type SceneNodeModel,
|
|
@@ -116,6 +131,10 @@
|
|
|
116
131
|
zoomOut: string;
|
|
117
132
|
/** Visible text of the fit / reset control (« Ajuster »). */
|
|
118
133
|
fit: string;
|
|
134
|
+
/** Visible text of the whole-scene fit control (« Tout voir »). */
|
|
135
|
+
viewAll?: string;
|
|
136
|
+
/** Accessible name of the fullscreen control (« Plein écran »). */
|
|
137
|
+
fullscreen?: string;
|
|
119
138
|
/** Accessible name of the readout, e.g. « Zoom 85 % ». */
|
|
120
139
|
zoomLevel: (percent: number) => string;
|
|
121
140
|
/** Accessible name of the scrollable drawing region. */
|
|
@@ -124,6 +143,8 @@
|
|
|
124
143
|
collapse: (title: string) => string;
|
|
125
144
|
/** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
|
|
126
145
|
contains?: string;
|
|
146
|
+
/** Heading for the automatic link-style legend strip (DE-2). */
|
|
147
|
+
legend?: string;
|
|
127
148
|
}
|
|
128
149
|
|
|
129
150
|
export interface DiagramSceneCamera {
|
|
@@ -171,11 +192,17 @@
|
|
|
171
192
|
/** Accessible name of the figure. Defaults to `title`. */
|
|
172
193
|
label?: string;
|
|
173
194
|
compact?: boolean;
|
|
195
|
+
/** 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`. */
|
|
196
|
+
fitToWindow?: boolean;
|
|
174
197
|
labels?: Partial<DiagramSceneFigureLabels>;
|
|
175
198
|
iconBindings?: import("@sentropic/diagram-canvas/diagramSceneModel").SceneIconBindings;
|
|
176
199
|
strictIcons?: boolean;
|
|
177
200
|
/** Selectable start parity for alternating zone depth surfaces (`0` default, `1` flipped). */
|
|
178
201
|
depthParityStart?: 0 | 1;
|
|
202
|
+
/** Automatic link-style legend anchor (`"right"` default; `"none"` suppresses). */
|
|
203
|
+
legend?: LinkLegendAnchor;
|
|
204
|
+
/** Optional custom labels for automatic link-style legend entries, keyed by `linkStyleKey(...)`. */
|
|
205
|
+
legendLabels?: Readonly<Record<string, string>>;
|
|
179
206
|
resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
|
|
180
207
|
onFoldChange?: (
|
|
181
208
|
collapsed: readonly SceneOccurrenceRef[],
|
|
@@ -190,7 +217,7 @@
|
|
|
190
217
|
onSizeChange?: (size: DiagramSceneSize) => void;
|
|
191
218
|
}
|
|
192
219
|
|
|
193
|
-
const DEFAULT_LABELS
|
|
220
|
+
const DEFAULT_LABELS = DEFAULT_SCENE_LABELS;
|
|
194
221
|
|
|
195
222
|
const TOKEN_MAX_DISPLAY_SCALE = "--st-component-diagramScene-maxDisplayScale";
|
|
196
223
|
const TOKEN_MIN_READABLE_SCALE = "--st-component-diagramScene-minReadableScale";
|
|
@@ -215,11 +242,14 @@
|
|
|
215
242
|
title,
|
|
216
243
|
label,
|
|
217
244
|
compact = false,
|
|
245
|
+
fitToWindow = false,
|
|
218
246
|
labels,
|
|
219
247
|
resolveGlyph = getDiagramGlyph,
|
|
220
248
|
iconBindings,
|
|
221
249
|
strictIcons = true,
|
|
222
250
|
depthParityStart,
|
|
251
|
+
legend,
|
|
252
|
+
legendLabels,
|
|
223
253
|
onFoldChange,
|
|
224
254
|
onSelect,
|
|
225
255
|
onLayout,
|
|
@@ -252,6 +282,7 @@
|
|
|
252
282
|
const collapsedNow = $derived(collapsed ?? foldState);
|
|
253
283
|
const arrowInstance = $props.id();
|
|
254
284
|
const arrowId = "diagram-arrow-" + arrowInstance;
|
|
285
|
+
const markerIds = connectorMarkerIds(arrowId);
|
|
255
286
|
const maskId = "diagram-connector-mask-" + arrowInstance;
|
|
256
287
|
let browserMeasure = $state.raw<CardLineMeasure>();
|
|
257
288
|
let frameWidth = $state<number>();
|
|
@@ -259,17 +290,64 @@
|
|
|
259
290
|
let tokenMetrics = $state.raw<Partial<LayoutMetrics>>({});
|
|
260
291
|
const effectiveMetrics = $derived({ ...tokenMetrics, ...metrics });
|
|
261
292
|
const lineMeasurer = $derived<LineMeasurer>(measureLines ?? cardLineMeasurer(effectiveMeasure));
|
|
293
|
+
const r7Mode = $derived(isR7ConnectorPresentation(presentation, view, semanticDocument));
|
|
262
294
|
|
|
263
295
|
// O-4: the orientation record last emitted, fed back to the next layout
|
|
264
296
|
// call. Deliberately not reactive state: it is an input of the next pass,
|
|
265
297
|
// never a reason to run one. A different document starts with no record.
|
|
298
|
+
// On r7 scenes only, returning to a previously visited fold state within the
|
|
299
|
+
// same non-fold input revision reuses the orientation seed recorded on its
|
|
300
|
+
// first visit so unfolding restores initial geometry; any revision, hint,
|
|
301
|
+
// metric, or measurer change resets that map, and legacy scenes keep main O-4.
|
|
266
302
|
let previousOrientation: SceneOrientations | undefined;
|
|
267
303
|
let orientationDocument: string | undefined;
|
|
304
|
+
let orientationInputTuple: readonly unknown[] | undefined;
|
|
305
|
+
const orientationSeedByFold = new Map<string, SceneOrientations | undefined>();
|
|
268
306
|
|
|
269
307
|
const layoutResult = $derived.by<LayoutResult>(() => {
|
|
270
308
|
if (orientationDocument !== semanticDocument.documentId) {
|
|
271
309
|
orientationDocument = semanticDocument.documentId;
|
|
272
310
|
previousOrientation = undefined;
|
|
311
|
+
orientationInputTuple = undefined;
|
|
312
|
+
orientationSeedByFold.clear();
|
|
313
|
+
}
|
|
314
|
+
let orientationSeed: SceneOrientations | undefined = previousOrientation;
|
|
315
|
+
if (r7Mode) {
|
|
316
|
+
const nextInputs: readonly unknown[] = [
|
|
317
|
+
semanticDocument,
|
|
318
|
+
semanticDocument.revision,
|
|
319
|
+
view,
|
|
320
|
+
presentation,
|
|
321
|
+
JSON.stringify(hints ?? null),
|
|
322
|
+
JSON.stringify(effectiveMetrics),
|
|
323
|
+
JSON.stringify(rowPack ?? null),
|
|
324
|
+
targetWidth,
|
|
325
|
+
lineMeasurer,
|
|
326
|
+
lineMeasurer.version,
|
|
327
|
+
JSON.stringify(flowOptions),
|
|
328
|
+
JSON.stringify(flowTokens),
|
|
329
|
+
iconBindings,
|
|
330
|
+
strictIcons,
|
|
331
|
+
depthParityStart,
|
|
332
|
+
];
|
|
333
|
+
const sameNonFoldInputs =
|
|
334
|
+
orientationInputTuple !== undefined &&
|
|
335
|
+
orientationInputTuple.length === nextInputs.length &&
|
|
336
|
+
nextInputs.every((value, index) => Object.is(value, orientationInputTuple![index]));
|
|
337
|
+
if (!sameNonFoldInputs) {
|
|
338
|
+
orientationInputTuple = nextInputs;
|
|
339
|
+
orientationSeedByFold.clear();
|
|
340
|
+
}
|
|
341
|
+
const foldKey = [...collapsedNow].sort().join("\0");
|
|
342
|
+
orientationSeed = orientationSeedByFold.has(foldKey)
|
|
343
|
+
? orientationSeedByFold.get(foldKey)
|
|
344
|
+
: previousOrientation;
|
|
345
|
+
if (!orientationSeedByFold.has(foldKey)) {
|
|
346
|
+
orientationSeedByFold.set(foldKey, orientationSeed);
|
|
347
|
+
}
|
|
348
|
+
} else if (orientationSeedByFold.size > 0 || orientationInputTuple !== undefined) {
|
|
349
|
+
orientationInputTuple = undefined;
|
|
350
|
+
orientationSeedByFold.clear();
|
|
273
351
|
}
|
|
274
352
|
const result = layoutScene({
|
|
275
353
|
cache: layoutCache ?? ownedCache,
|
|
@@ -290,7 +368,7 @@
|
|
|
290
368
|
metrics: effectiveMetrics,
|
|
291
369
|
...(rowPack === undefined ? {} : { rowPack }),
|
|
292
370
|
...(targetWidth === undefined ? {} : { targetWidth }),
|
|
293
|
-
...(
|
|
371
|
+
...(orientationSeed === undefined ? {} : { previousOrientation: orientationSeed }),
|
|
294
372
|
});
|
|
295
373
|
if (result.status === "laid-out" && result.orientations !== undefined) {
|
|
296
374
|
previousOrientation = result.orientations;
|
|
@@ -298,6 +376,41 @@
|
|
|
298
376
|
return result;
|
|
299
377
|
});
|
|
300
378
|
|
|
379
|
+
let viewWidth = $state<number>();
|
|
380
|
+
let windowHeight = $state<number>();
|
|
381
|
+
let measuredFrameHeight = $state<number>();
|
|
382
|
+
let controlsHeight = $state(0);
|
|
383
|
+
let scrollbarHeight = $state(0);
|
|
384
|
+
let maxDisplayScale = $state<number>();
|
|
385
|
+
let minReadableScale = $state<number>();
|
|
386
|
+
let viewAll = $state(false);
|
|
387
|
+
let nativeFullscreen = $state(false);
|
|
388
|
+
let fallbackFullscreen = $state(false);
|
|
389
|
+
const fullscreen = $derived(nativeFullscreen || fallbackFullscreen);
|
|
390
|
+
const fullscreenMode = $derived<"native" | "fallback" | undefined>(
|
|
391
|
+
nativeFullscreen ? "native" : fallbackFullscreen ? "fallback" : undefined,
|
|
392
|
+
);
|
|
393
|
+
const fullscreenViewHeight = $derived(
|
|
394
|
+
fullscreen
|
|
395
|
+
? measuredFrameHeight !== undefined && measuredFrameHeight > 0
|
|
396
|
+
? measuredFrameHeight
|
|
397
|
+
: windowHeight !== undefined
|
|
398
|
+
? Math.max(0, windowHeight - controlsHeight)
|
|
399
|
+
: undefined
|
|
400
|
+
: undefined,
|
|
401
|
+
);
|
|
402
|
+
const sceneFitInput = $derived({
|
|
403
|
+
// Before the frame is measured (server render, hidden mount) the fit
|
|
404
|
+
// box is the nominal 16:9 box of the layout target width.
|
|
405
|
+
viewWidth: frameWidth ?? targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
|
|
406
|
+
windowHeight: windowHeight ?? Number.POSITIVE_INFINITY,
|
|
407
|
+
...(fullscreenViewHeight === undefined ? {} : { viewHeight: fullscreenViewHeight }),
|
|
408
|
+
...(viewAll ? { unconstrained: true } : {}),
|
|
409
|
+
...(maxDisplayScale === undefined ? {} : { maxDisplayScale }),
|
|
410
|
+
...(minReadableScale === undefined ? {} : { minReadableScale }),
|
|
411
|
+
...(fitToWindow ? { fitToWindow: true } : {}),
|
|
412
|
+
});
|
|
413
|
+
|
|
301
414
|
const scene = $derived<SceneModel | undefined>(
|
|
302
415
|
layoutResult.status === "laid-out"
|
|
303
416
|
? resolveScene(layoutResult, {
|
|
@@ -307,11 +420,14 @@
|
|
|
307
420
|
...(iconBindings === undefined ? {} : { iconBindings }),
|
|
308
421
|
strictIcons,
|
|
309
422
|
...(depthParityStart === undefined ? {} : { depthParityStart }),
|
|
423
|
+
...(legend === undefined ? {} : { legend }),
|
|
424
|
+
...(strings.legend === undefined ? {} : { legendTitle: strings.legend }),
|
|
425
|
+
...(legendLabels === undefined ? {} : { legendLabels }),
|
|
310
426
|
resolveGlyph,
|
|
311
427
|
measureLines: lineMeasurer,
|
|
312
428
|
flows: flowOptions,
|
|
313
429
|
metrics: effectiveMetrics,
|
|
314
|
-
})
|
|
430
|
+
}, fitToWindow ? sceneFitInput : undefined)
|
|
315
431
|
: undefined,
|
|
316
432
|
);
|
|
317
433
|
const sceneRects = $derived<ReadonlyMap<string, Rect>>(scene === undefined ? new Map() : rectsOf(scene));
|
|
@@ -488,6 +604,8 @@
|
|
|
488
604
|
|
|
489
605
|
/* ── measured frame and tokens (client only) ───────────────────── */
|
|
490
606
|
|
|
607
|
+
let figureEl = $state<HTMLElement>();
|
|
608
|
+
let controlsEl = $state<HTMLElement>();
|
|
491
609
|
let frameEl = $state<HTMLElement>();
|
|
492
610
|
let viewportEl = $state<HTMLElement>();
|
|
493
611
|
$effect(() => {
|
|
@@ -497,27 +615,25 @@
|
|
|
497
615
|
if (select !== undefined && select !== null) select.value = filter === undefined ? "all" : `scenario:${filter}`;
|
|
498
616
|
}
|
|
499
617
|
});
|
|
500
|
-
let
|
|
501
|
-
let windowHeight = $state<number>();
|
|
502
|
-
let scrollbarHeight = $state(0);
|
|
503
|
-
let maxDisplayScale = $state<number>();
|
|
504
|
-
let minReadableScale = $state<number>();
|
|
505
|
-
let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect }>();
|
|
618
|
+
let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect; scale: number }>();
|
|
506
619
|
const cameraBounds = $derived(renderedBounds?.scene === scene ? renderedBounds?.bounds : scene?.bounds);
|
|
507
620
|
// `zoom` is the scale the world is painted at: the fit is quantised once,
|
|
508
621
|
// in `sceneFit`, and printed as it is, so painted rects divide back by it.
|
|
509
622
|
// The first read of a scene fits; a later one refits only when it differs
|
|
510
|
-
// from that read by more than the measurement granularity
|
|
511
|
-
// comes back as the model bounds is a
|
|
512
|
-
// earlier, larger one, and the next one
|
|
513
|
-
// A fold transition paints interpolated rectangles and
|
|
514
|
-
// read happens while it runs, one happens when it settles.
|
|
623
|
+
// from that read by more than the measurement granularity at the minimum
|
|
624
|
+
// scale of the two reads. A read that comes back as the model bounds is a
|
|
625
|
+
// read like any other: it replaces an earlier, larger one, and the next one
|
|
626
|
+
// is compared to it. A fold transition paints interpolated rectangles and
|
|
627
|
+
// fading layers: no read happens while it runs, one happens when it settles.
|
|
515
628
|
function readRenderedBounds(): void {
|
|
516
629
|
if (frameEl === undefined || scene === undefined || animating) return;
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
630
|
+
const readScale = committedWorldScale(frameEl, zoom);
|
|
631
|
+
const strokeFloor = Math.min(DEFAULT_MIN_READABLE_SCALE, fit.minZoom, readScale);
|
|
632
|
+
const bounds = measureRenderedBounds(frameEl, scene.bounds, zoom, strokeFloor);
|
|
633
|
+
const previous = renderedBounds?.scene === scene ? renderedBounds : undefined;
|
|
634
|
+
const toleranceScale = previous === undefined ? readScale : Math.min(previous.scale, readScale);
|
|
635
|
+
if (bounds === undefined || !shouldRefitRenderedBounds(previous?.bounds, bounds, toleranceScale)) return;
|
|
636
|
+
renderedBounds = { scene, bounds, scale: readScale };
|
|
521
637
|
}
|
|
522
638
|
$effect(() => {
|
|
523
639
|
const current = scene;
|
|
@@ -536,12 +652,40 @@
|
|
|
536
652
|
return () => { active = false; };
|
|
537
653
|
});
|
|
538
654
|
|
|
539
|
-
function tokenValue(name: string): string | undefined {
|
|
655
|
+
function tokenValue(name: string, style?: CSSStyleDeclaration): string | undefined {
|
|
540
656
|
if (frameEl === undefined) return undefined;
|
|
541
|
-
const value = getComputedStyle(frameEl).getPropertyValue(name).trim();
|
|
657
|
+
const value = (style ?? getComputedStyle(frameEl)).getPropertyValue(name).trim();
|
|
542
658
|
return value === "" ? undefined : value;
|
|
543
659
|
}
|
|
544
660
|
|
|
661
|
+
function lengthTokenValue(
|
|
662
|
+
name: string,
|
|
663
|
+
style?: CSSStyleDeclaration,
|
|
664
|
+
context?: { readonly rootFontSize?: number; readonly elementFontSize?: number },
|
|
665
|
+
): number | undefined {
|
|
666
|
+
if (frameEl === undefined) return undefined;
|
|
667
|
+
const raw = tokenValue(name, style);
|
|
668
|
+
if (raw === undefined) return undefined;
|
|
669
|
+
const resolvedContext = context ?? (() => {
|
|
670
|
+
const docEl = frameEl.ownerDocument?.documentElement;
|
|
671
|
+
const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
|
|
672
|
+
const elementFontSize = parseFloat((style ?? getComputedStyle(frameEl)).fontSize);
|
|
673
|
+
return { rootFontSize, elementFontSize };
|
|
674
|
+
})();
|
|
675
|
+
const parsed = parseCssLengthPx(raw, resolvedContext);
|
|
676
|
+
if (parsed !== undefined || !/^(calc|min|max|clamp)\(/i.test(raw)) return parsed;
|
|
677
|
+
const probe = frameEl.ownerDocument.createElement("span");
|
|
678
|
+
probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
|
|
679
|
+
probe.style.fontSize = raw;
|
|
680
|
+
if (probe.style.fontSize === "") return undefined;
|
|
681
|
+
frameEl.appendChild(probe);
|
|
682
|
+
try {
|
|
683
|
+
return parseCssLengthPx(getComputedStyle(probe).fontSize, resolvedContext);
|
|
684
|
+
} finally {
|
|
685
|
+
probe.remove();
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
545
689
|
// A user zoom lasts until the next resize, fold or font load.
|
|
546
690
|
let requestedZoom = $state<number>();
|
|
547
691
|
let fittedFonts: Promise<FontFaceSet> | undefined;
|
|
@@ -575,31 +719,63 @@
|
|
|
575
719
|
// m3: camera tokens are re-read on every measure and before every camera
|
|
576
720
|
// input, so a post-mount theme change applies without waiting for a resize.
|
|
577
721
|
function readCameraTokens(): void {
|
|
722
|
+
const style = frameEl === undefined ? undefined : getComputedStyle(frameEl);
|
|
578
723
|
const values: Record<string, number> = {};
|
|
579
|
-
|
|
580
|
-
|
|
724
|
+
const baseKeys = ["gapMin","gapMinBlock","gapBase","gapBaseBlock","trackSpacing","trackSpacingBlock","labelBand","gapMax","bundleLabelMaxWidth","containerPadding"];
|
|
725
|
+
const r7Keys = ["zoneGutter","routeSpacing","routeBorderClearance","edgeCornerRadius","linkStrokeWidth","linkRelatedStrokeWidth","linkEmphasisStrokeWidth"];
|
|
726
|
+
for (const key of baseKeys) {
|
|
727
|
+
const value = parseFloat(tokenValue("--st-component-diagramScene-" + key, style) ?? "");
|
|
581
728
|
if (Number.isFinite(value)) values[key] = value;
|
|
582
729
|
}
|
|
583
|
-
const labelMargin = parseFloat(tokenValue(
|
|
730
|
+
const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding", style) ?? "");
|
|
584
731
|
if (Number.isFinite(labelMargin)) values.labelMargin = labelMargin;
|
|
585
|
-
if (
|
|
732
|
+
if (r7Mode && frameEl !== undefined) {
|
|
733
|
+
const docEl = frameEl.ownerDocument?.documentElement;
|
|
734
|
+
const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
|
|
735
|
+
const elementFontSize = parseFloat((style ?? getComputedStyle(frameEl)).fontSize);
|
|
736
|
+
const lengthContext = { rootFontSize, elementFontSize };
|
|
737
|
+
for (const key of r7Keys) {
|
|
738
|
+
const value = lengthTokenValue("--st-component-diagramScene-" + key, style, lengthContext);
|
|
739
|
+
if (value !== undefined && Number.isFinite(value)) values[key] = value;
|
|
740
|
+
}
|
|
741
|
+
const edgeLabelSize = resolveEdgeLabelSizeToken(
|
|
742
|
+
lengthTokenValue("--st-component-diagramScene-edgeLabelSize", style, lengthContext),
|
|
743
|
+
lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize", style, lengthContext),
|
|
744
|
+
);
|
|
745
|
+
if (edgeLabelSize !== undefined) values.edgeLabelSize = edgeLabelSize;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (JSON.stringify(values) !== JSON.stringify(tokenMetrics)) {
|
|
749
|
+
ownedCache.clear();
|
|
750
|
+
tokenMetrics = values;
|
|
751
|
+
}
|
|
586
752
|
const nextTokens = { ...DEFAULT_FLOW_TOKENS };
|
|
587
753
|
for (const name of Object.keys(nextTokens) as (keyof FlowTokens)[]) {
|
|
588
|
-
const value = tokenValue(`--st-component-diagramScene-${name}
|
|
754
|
+
const value = tokenValue(`--st-component-diagramScene-${name}`, style);
|
|
589
755
|
if (name === "flowArrowPath") { if (value?.trim()) nextTokens.flowArrowPath = value.trim(); }
|
|
590
756
|
else { const number = parseScale(value); if (number !== undefined) (nextTokens as unknown as Record<string, number>)[name] = number; }
|
|
591
757
|
}
|
|
592
758
|
if (JSON.stringify(nextTokens) !== JSON.stringify(flowTokens)) flowTokens = nextTokens;
|
|
593
|
-
maxDisplayScale = parseScale(tokenValue(TOKEN_MAX_DISPLAY_SCALE));
|
|
594
|
-
minReadableScale = parseScale(tokenValue(TOKEN_MIN_READABLE_SCALE));
|
|
759
|
+
maxDisplayScale = parseScale(tokenValue(TOKEN_MAX_DISPLAY_SCALE, style));
|
|
760
|
+
minReadableScale = parseScale(tokenValue(TOKEN_MIN_READABLE_SCALE, style));
|
|
595
761
|
}
|
|
596
762
|
|
|
763
|
+
$effect(() => {
|
|
764
|
+
void r7Mode;
|
|
765
|
+
untrack(readCameraTokens);
|
|
766
|
+
});
|
|
767
|
+
|
|
597
768
|
let previousFrameHeight: number | undefined;
|
|
598
769
|
let previousViewportHeight = 0;
|
|
599
770
|
|
|
600
771
|
function measureFrame(resize = false): void {
|
|
601
772
|
if (frameEl === undefined) return;
|
|
602
|
-
const
|
|
773
|
+
const rawWidth = frameEl.clientWidth;
|
|
774
|
+
const width = rawWidth > 0
|
|
775
|
+
? rawWidth
|
|
776
|
+
: fullscreen && window.innerWidth > 0
|
|
777
|
+
? window.innerWidth
|
|
778
|
+
: undefined;
|
|
603
779
|
const frameHeight = frameEl.clientHeight;
|
|
604
780
|
const viewportOuterHeight = viewportEl?.offsetHeight ?? 0;
|
|
605
781
|
// The frame can grow with its viewport when a scrollbar appears.
|
|
@@ -612,6 +788,8 @@
|
|
|
612
788
|
const height = window.innerHeight > 0 ? window.innerHeight : undefined;
|
|
613
789
|
const refit = resize || width !== frameWidth || frameHeightChanged || height !== windowHeight;
|
|
614
790
|
frameWidth = width;
|
|
791
|
+
measuredFrameHeight = frameHeight > 0 ? frameHeight : undefined;
|
|
792
|
+
controlsHeight = controlsEl?.offsetHeight ?? 0;
|
|
615
793
|
viewWidth = viewportEl?.clientWidth || width;
|
|
616
794
|
scrollbarHeight = viewportOuterHeight - (viewportEl?.clientHeight ?? 0);
|
|
617
795
|
windowHeight = height;
|
|
@@ -626,17 +804,32 @@
|
|
|
626
804
|
const element = frameEl;
|
|
627
805
|
if (element === undefined) return;
|
|
628
806
|
untrack(() => measureFrame());
|
|
807
|
+
const doc = element.ownerDocument;
|
|
629
808
|
const onResize = (): void => measureFrame(true);
|
|
630
|
-
const
|
|
809
|
+
const onFullscreenChange = (): void => {
|
|
810
|
+
const active = figureEl !== undefined && doc.fullscreenElement === figureEl;
|
|
811
|
+
if (active !== nativeFullscreen) {
|
|
812
|
+
if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
|
|
813
|
+
nativeFullscreen = active;
|
|
814
|
+
if (active) fallbackFullscreen = false;
|
|
815
|
+
void tick().then(() => measureFrame(true));
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const fonts = doc.fonts;
|
|
631
819
|
window.addEventListener("resize", onResize);
|
|
820
|
+
doc.addEventListener("fullscreenchange", onFullscreenChange);
|
|
632
821
|
fonts?.addEventListener?.("loadingdone", refitForFonts);
|
|
633
822
|
const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(() => measureFrame());
|
|
634
823
|
observer?.observe(element);
|
|
635
824
|
if (viewportEl !== undefined) observer?.observe(viewportEl);
|
|
636
825
|
return () => {
|
|
637
826
|
window.removeEventListener("resize", onResize);
|
|
827
|
+
doc.removeEventListener("fullscreenchange", onFullscreenChange);
|
|
638
828
|
fonts?.removeEventListener?.("loadingdone", refitForFonts);
|
|
639
829
|
observer?.disconnect();
|
|
830
|
+
if (figureEl !== undefined && doc.fullscreenElement === figureEl && typeof doc.exitFullscreen === "function") {
|
|
831
|
+
try { void doc.exitFullscreen()?.catch?.(() => undefined); } catch { /* ignore */ }
|
|
832
|
+
}
|
|
640
833
|
};
|
|
641
834
|
});
|
|
642
835
|
|
|
@@ -645,12 +838,7 @@
|
|
|
645
838
|
const measured = $derived(frameWidth !== undefined && windowHeight !== undefined);
|
|
646
839
|
const fitInput = $derived({
|
|
647
840
|
...(cameraBounds === undefined ? {} : { bounds: cameraBounds }),
|
|
648
|
-
|
|
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 }),
|
|
841
|
+
...sceneFitInput,
|
|
654
842
|
});
|
|
655
843
|
// Try the full width first so scrollbars from a user zoom cannot trap
|
|
656
844
|
// the next fit at the floor. If it still pans, account for the bars.
|
|
@@ -672,7 +860,11 @@
|
|
|
672
860
|
$effect.pre(() => {
|
|
673
861
|
const id = semanticDocument.documentId;
|
|
674
862
|
if (cameraDocument !== undefined && cameraDocument !== id) {
|
|
675
|
-
untrack(
|
|
863
|
+
untrack(() => {
|
|
864
|
+
viewAll = false;
|
|
865
|
+
if (fullscreen) exitFullscreen();
|
|
866
|
+
resetToFit();
|
|
867
|
+
});
|
|
676
868
|
fittedFonts = undefined;
|
|
677
869
|
browserMeasure = undefined;
|
|
678
870
|
renderedBounds = undefined;
|
|
@@ -760,6 +952,113 @@
|
|
|
760
952
|
resetToFit();
|
|
761
953
|
}
|
|
762
954
|
|
|
955
|
+
function enterFullscreen(): void {
|
|
956
|
+
const target = figureEl;
|
|
957
|
+
if (target === undefined) return;
|
|
958
|
+
if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
|
|
959
|
+
const doc = target.ownerDocument;
|
|
960
|
+
const canNative = typeof target.requestFullscreen === "function" && doc.fullscreenEnabled !== false;
|
|
961
|
+
if (canNative) {
|
|
962
|
+
try {
|
|
963
|
+
const pending = target.requestFullscreen();
|
|
964
|
+
if (pending !== undefined && typeof pending.then === "function") {
|
|
965
|
+
void pending.then(
|
|
966
|
+
() => {
|
|
967
|
+
if (doc.fullscreenElement === target) {
|
|
968
|
+
nativeFullscreen = true;
|
|
969
|
+
fallbackFullscreen = false;
|
|
970
|
+
} else {
|
|
971
|
+
nativeFullscreen = false;
|
|
972
|
+
fallbackFullscreen = true;
|
|
973
|
+
}
|
|
974
|
+
void tick().then(() => measureFrame(true));
|
|
975
|
+
},
|
|
976
|
+
() => {
|
|
977
|
+
nativeFullscreen = false;
|
|
978
|
+
fallbackFullscreen = true;
|
|
979
|
+
void tick().then(() => measureFrame(true));
|
|
980
|
+
},
|
|
981
|
+
);
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
if (doc.fullscreenElement === target) {
|
|
985
|
+
nativeFullscreen = true;
|
|
986
|
+
fallbackFullscreen = false;
|
|
987
|
+
void tick().then(() => measureFrame(true));
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
} catch {
|
|
991
|
+
// Fall through to the fixed-position overlay fallback.
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
nativeFullscreen = false;
|
|
995
|
+
fallbackFullscreen = true;
|
|
996
|
+
void tick().then(() => measureFrame(true));
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function exitFullscreen(): void {
|
|
1000
|
+
const target = figureEl;
|
|
1001
|
+
const doc = target?.ownerDocument;
|
|
1002
|
+
const wasActive = nativeFullscreen || fallbackFullscreen;
|
|
1003
|
+
if (wasActive && renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
|
|
1004
|
+
fallbackFullscreen = false;
|
|
1005
|
+
if (doc !== undefined && doc.fullscreenElement === target && typeof doc.exitFullscreen === "function") {
|
|
1006
|
+
try {
|
|
1007
|
+
const pending = doc.exitFullscreen();
|
|
1008
|
+
if (pending !== undefined && typeof pending.then === "function") {
|
|
1009
|
+
void pending.then(
|
|
1010
|
+
() => {
|
|
1011
|
+
nativeFullscreen = doc.fullscreenElement === target;
|
|
1012
|
+
void tick().then(() => measureFrame(true));
|
|
1013
|
+
},
|
|
1014
|
+
() => {
|
|
1015
|
+
nativeFullscreen = false;
|
|
1016
|
+
void tick().then(() => measureFrame(true));
|
|
1017
|
+
},
|
|
1018
|
+
);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
} catch {
|
|
1022
|
+
// Clear local state below.
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
nativeFullscreen = false;
|
|
1026
|
+
if (wasActive) {
|
|
1027
|
+
void tick().then(() => measureFrame(true));
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** Toggle fullscreen using the Fullscreen API when available, with a fixed overlay fallback. */
|
|
1032
|
+
export function toggleFullscreen(): void {
|
|
1033
|
+
readCameraTokens();
|
|
1034
|
+
if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
|
|
1035
|
+
if (fullscreen) exitFullscreen();
|
|
1036
|
+
else enterFullscreen();
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/** Enable or leave « Tout voir » mode (whole scene, no readability floor, no scroll). */
|
|
1040
|
+
export function setViewAll(enabled: boolean): void {
|
|
1041
|
+
const next = Boolean(enabled);
|
|
1042
|
+
if (next === viewAll) return;
|
|
1043
|
+
if (animating) settle();
|
|
1044
|
+
readCameraTokens();
|
|
1045
|
+
const exitingFullscreen = !next && fullscreen;
|
|
1046
|
+
renderedBounds = undefined;
|
|
1047
|
+
viewAll = next;
|
|
1048
|
+
if (exitingFullscreen) exitFullscreen();
|
|
1049
|
+
resetToFit();
|
|
1050
|
+
if (!exitingFullscreen) {
|
|
1051
|
+
const targetScene = scene;
|
|
1052
|
+
void tick().then(() => {
|
|
1053
|
+
if (scene === targetScene && viewAll === next) readRenderedBounds();
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
export function toggleViewAll(): void {
|
|
1059
|
+
setViewAll(!viewAll);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
763
1062
|
export function getCamera(): DiagramSceneCamera {
|
|
764
1063
|
return {
|
|
765
1064
|
zoom,
|
|
@@ -771,6 +1070,19 @@
|
|
|
771
1070
|
};
|
|
772
1071
|
}
|
|
773
1072
|
|
|
1073
|
+
function onFigureKeydown(event: KeyboardEvent): void {
|
|
1074
|
+
if (event.key !== "Escape" || event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
|
|
1075
|
+
if (fallbackFullscreen) {
|
|
1076
|
+
exitFullscreen();
|
|
1077
|
+
event.preventDefault();
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
if (viewAll && !fullscreen) {
|
|
1081
|
+
setViewAll(false);
|
|
1082
|
+
event.preventDefault();
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
774
1086
|
function onKeydown(event: KeyboardEvent): void {
|
|
775
1087
|
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
776
1088
|
// m5: shortcuts work from non-input descendants (card buttons, nodes);
|
|
@@ -780,8 +1092,18 @@
|
|
|
780
1092
|
const tag = target.tagName;
|
|
781
1093
|
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable || target.closest("[contenteditable]")) return;
|
|
782
1094
|
}
|
|
1095
|
+
if (!event.shiftKey && event.key === "Escape" && fallbackFullscreen) {
|
|
1096
|
+
exitFullscreen();
|
|
1097
|
+
event.preventDefault();
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
783
1100
|
if (!event.shiftKey && roveFlow(event)) return;
|
|
784
1101
|
if (!event.shiftKey && flowSteps.length > 0 && ["]", "[", "Escape"].includes(event.key)) {
|
|
1102
|
+
if (event.key === "Escape" && flowState.selection === null && viewAll && !fullscreen) {
|
|
1103
|
+
setViewAll(false);
|
|
1104
|
+
event.preventDefault();
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
785
1107
|
dispatchFlow({ type: event.key === "]" ? "next" : event.key === "[" ? "previous" : "escape" }); event.preventDefault(); return;
|
|
786
1108
|
}
|
|
787
1109
|
if (event.key === "+" || event.key === "=") zoomIn();
|
|
@@ -961,29 +1283,54 @@
|
|
|
961
1283
|
|
|
962
1284
|
const erdTable = $derived(semanticDocument.profileRefs.includes("erd@1") ? renderErdTable(semanticDocument) : "");
|
|
963
1285
|
|
|
1286
|
+
const edgeCornerRadius = $derived(effectiveMetrics.edgeCornerRadius ?? DEFAULT_EDGE_CORNER_RADIUS);
|
|
1287
|
+
const pathOf = (points: readonly { readonly x: number; readonly y: number }[]): string =>
|
|
1288
|
+
connectorPath(points, edgeCornerRadius);
|
|
964
1289
|
const pointsOf = (points: readonly { readonly x: number; readonly y: number }[]): string =>
|
|
965
1290
|
points.map((point) => `${point.x},${point.y}`).join(" ");
|
|
966
1291
|
|
|
967
|
-
const edgeLabelLineHeight = $derived(lineMeasurer({ text: "Mg", role: "edge-label", availableWidth: 400, allocatedLines: 1, folded: false }).height);
|
|
1292
|
+
const edgeLabelLineHeight = $derived(scaleEdgeLabelMeasurer(lineMeasurer, r7Mode ? effectiveMetrics.edgeLabelSize : undefined)({ text: "Mg", role: "edge-label", availableWidth: 400, allocatedLines: 1, folded: false }).height);
|
|
1293
|
+
const metricPaintVars = $derived(
|
|
1294
|
+
!r7Mode ? "" :
|
|
1295
|
+
(metrics?.edgeLabelSize !== undefined ||
|
|
1296
|
+
(effectiveMetrics.edgeLabelSize !== undefined && effectiveMetrics.edgeLabelSize !== DEFAULT_EDGE_LABEL_SIZE)
|
|
1297
|
+
? `;--st-diagram-edge-label-size:${effectiveMetrics.edgeLabelSize}px`
|
|
1298
|
+
: "") +
|
|
1299
|
+
(metrics?.linkStrokeWidth !== undefined ? `;--st-diagram-link-stroke-width:${metrics.linkStrokeWidth}px` : "") +
|
|
1300
|
+
(metrics?.linkRelatedStrokeWidth !== undefined ? `;--st-diagram-link-related-stroke-width:${metrics.linkRelatedStrokeWidth}px` : "") +
|
|
1301
|
+
(metrics?.linkEmphasisStrokeWidth !== undefined ? `;--st-diagram-link-emphasis-stroke-width:${metrics.linkEmphasisStrokeWidth}px` : ""),
|
|
1302
|
+
);
|
|
1303
|
+
const overviewLabelPaintVars = $derived.by(() => {
|
|
1304
|
+
const size = scene?.overviewEdgeLabelSize;
|
|
1305
|
+
if (size === undefined) return "";
|
|
1306
|
+
const lineHeight = edgeLabelLineHeight * size / (effectiveMetrics.edgeLabelSize ?? DEFAULT_EDGE_LABEL_SIZE);
|
|
1307
|
+
return `;--st-diagram-overview-edge-label-size:${size}px;--st-diagram-overview-edge-label-line-height:${lineHeight}px`;
|
|
1308
|
+
});
|
|
968
1309
|
const viewportStyle = $derived(
|
|
969
|
-
`height:${viewportHeight}px;aspect-ratio:${FIT_ASPECT}
|
|
1310
|
+
`height:${viewportHeight}px;${fullscreen ? "" : 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
1311
|
);
|
|
971
1312
|
const worldStyle = $derived(
|
|
972
1313
|
`transform:translate(${placement.translateX}px,${placement.translateY}px) scale(${zoom})`,
|
|
973
1314
|
);
|
|
974
1315
|
</script>
|
|
975
1316
|
|
|
1317
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
976
1318
|
<figure
|
|
977
|
-
|
|
1319
|
+
bind:this={figureEl}
|
|
1320
|
+
class={`st-diagramSceneFigure${compact ? " st-diagramSceneFigure--compact" : ""}${fitToWindow ? " st-diagramSceneFigure--fitToWindow" : ""}${fullscreen ? " st-diagramSceneFigure--fullscreen" : ""}${fallbackFullscreen ? " st-diagramSceneFigure--fullscreenFallback" : ""}`}
|
|
978
1321
|
aria-label={label ?? title}
|
|
979
1322
|
data-zoom={zoom}
|
|
980
1323
|
data-zoom-readout={readout}
|
|
1324
|
+
data-fit-to-window={fitToWindow ? "true" : undefined}
|
|
1325
|
+
data-view-all={viewAll ? "true" : undefined}
|
|
1326
|
+
data-fullscreen={fullscreenMode}
|
|
981
1327
|
data-scene-refused={layoutResult.status === "refused" ? layoutResult.refusals[0]?.code : undefined}
|
|
1328
|
+
onkeydown={onFigureKeydown}
|
|
982
1329
|
>
|
|
983
1330
|
{#if title !== undefined}
|
|
984
1331
|
<figcaption class="st-diagramSceneFigure-title">{title}</figcaption>
|
|
985
1332
|
{/if}
|
|
986
|
-
<div class="st-diagramSceneFigure-controls" role="group" aria-label={strings.controls}>
|
|
1333
|
+
<div class="st-diagramSceneFigure-controls" bind:this={controlsEl} role="group" aria-label={strings.controls}>
|
|
987
1334
|
<IconButton size="sm" variant="secondary" aria-label={strings.zoomOut} disabled={!canZoomOut} onclick={zoomOut}>
|
|
988
1335
|
<Minus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
|
|
989
1336
|
</IconButton>
|
|
@@ -994,6 +1341,17 @@
|
|
|
994
1341
|
<Plus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
|
|
995
1342
|
</IconButton>
|
|
996
1343
|
<Button size="sm" variant="secondary" onclick={fitToFrame}>{strings.fit}</Button>
|
|
1344
|
+
<Button size="sm" variant="secondary" class="st-diagramSceneFigure-viewAll" aria-pressed={viewAll} onclick={toggleViewAll}>
|
|
1345
|
+
<Scan size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
|
|
1346
|
+
<span>{strings.viewAll}</span>
|
|
1347
|
+
</Button>
|
|
1348
|
+
<IconButton size="sm" variant="secondary" class="st-diagramSceneFigure-fullscreen" aria-label={strings.fullscreen} aria-pressed={fullscreen} onclick={toggleFullscreen}>
|
|
1349
|
+
{#if fullscreen}
|
|
1350
|
+
<Minimize2 size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
|
|
1351
|
+
{:else}
|
|
1352
|
+
<Maximize2 size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
|
|
1353
|
+
{/if}
|
|
1354
|
+
</IconButton>
|
|
997
1355
|
</div>
|
|
998
1356
|
{#if flowSteps.length > 0}
|
|
999
1357
|
<div class="st-diagramSceneFigure-flowNavigator" role="group" aria-label={strings.navigator}>
|
|
@@ -1076,6 +1434,7 @@
|
|
|
1076
1434
|
</div>
|
|
1077
1435
|
{/snippet}
|
|
1078
1436
|
{@const connectorMask = sceneConnectorMask(scene)}
|
|
1437
|
+
{@const extraMarkers = extraConnectorMarkers(scene.edges, markerIds)}
|
|
1079
1438
|
<!-- Paint order (diagram-canvas `scenePaintPlane`): expanded zone
|
|
1080
1439
|
frames, connectors, boxes, labels last. A zone frame is opaque:
|
|
1081
1440
|
painted after the connectors it would hide every route that
|
|
@@ -1089,10 +1448,14 @@
|
|
|
1089
1448
|
aria-hidden="true"
|
|
1090
1449
|
style={animating ? `opacity:${eased}` : undefined}
|
|
1091
1450
|
>
|
|
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>
|
|
1451
|
+
<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
1452
|
<g data-scene-connectors="" mask={connectorMask === undefined ? undefined : `url(#${maskId})`}>
|
|
1094
1453
|
{#each scene.edges as edge (edge.occurrence)}
|
|
1095
|
-
|
|
1454
|
+
{#if edge.r7}
|
|
1455
|
+
<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)} />
|
|
1456
|
+
{:else}
|
|
1457
|
+
<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)} />
|
|
1458
|
+
{/if}
|
|
1096
1459
|
{#if edge.directed}
|
|
1097
1460
|
<polyline class="st-diagramSceneFigure-flowHit" data-flow-hit={edge.occurrence} points={pointsOf(edge.points)} />
|
|
1098
1461
|
{#each edge.arrows as arrow, index (index)}
|
|
@@ -1104,7 +1467,13 @@
|
|
|
1104
1467
|
{#if edge.markers}<g>{@html edge.markers}</g>{/if}
|
|
1105
1468
|
{/each}
|
|
1106
1469
|
{#each scene.labels as edgeLabel (edgeLabel.occurrence)}
|
|
1107
|
-
{#if edgeLabel.leader}
|
|
1470
|
+
{#if edgeLabel.leader}
|
|
1471
|
+
{#if scene.r7Connectors && !edgeLabel.erd}
|
|
1472
|
+
<path class="st-diagramSceneFigure-edge" data-connector-mode="r7" d={pathOf(edgeLabel.leader)} />
|
|
1473
|
+
{:else}
|
|
1474
|
+
<polyline class="st-diagramSceneFigure-edge" points={pointsOf(edgeLabel.leader)} />
|
|
1475
|
+
{/if}
|
|
1476
|
+
{/if}
|
|
1108
1477
|
{/each}
|
|
1109
1478
|
</g>
|
|
1110
1479
|
</svg>
|
|
@@ -1121,6 +1490,7 @@
|
|
|
1121
1490
|
<div
|
|
1122
1491
|
class="st-diagramSceneFigure-edgeLabel"
|
|
1123
1492
|
data-scene-label={edgeLabel.occurrence}
|
|
1493
|
+
data-connector-mode={scene.r7Connectors && !edgeLabel.erd ? "r7" : undefined}
|
|
1124
1494
|
title={edgeLabel.title}
|
|
1125
1495
|
data-erd-label={edgeLabel.erd || undefined}
|
|
1126
1496
|
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 +1507,52 @@
|
|
|
1137
1507
|
{/if}
|
|
1138
1508
|
</div>
|
|
1139
1509
|
{/each}
|
|
1510
|
+
{#if scene.linkLegend !== undefined}
|
|
1511
|
+
<aside
|
|
1512
|
+
class="st-diagramSceneFigure-legend"
|
|
1513
|
+
role="region"
|
|
1514
|
+
aria-label={scene.linkLegend.title}
|
|
1515
|
+
data-scene-legend=""
|
|
1516
|
+
data-legend-anchor={scene.linkLegend.anchor}
|
|
1517
|
+
style={linkLegendBoxStyle(scene.linkLegend, animating ? eased : undefined)}
|
|
1518
|
+
>
|
|
1519
|
+
<div class="st-diagramSceneFigure-legendTitle">{scene.linkLegend.title}</div>
|
|
1520
|
+
<ul class="st-diagramSceneFigure-legendList">
|
|
1521
|
+
{#each scene.linkLegend.entries as entry (entry.key)}
|
|
1522
|
+
{@const swatch = linkLegendSwatchGeometry(entry, effectiveMetrics)}
|
|
1523
|
+
<li
|
|
1524
|
+
class="st-diagramSceneFigure-legendItem"
|
|
1525
|
+
data-legend-style={entry.key}
|
|
1526
|
+
data-edge-stroke={entry.strokeStyle}
|
|
1527
|
+
data-edge-arrowhead={entry.arrowhead}
|
|
1528
|
+
data-edge-emphasis={entry.emphasis}
|
|
1529
|
+
>
|
|
1530
|
+
<svg class="st-diagramSceneFigure-legendSwatch" viewBox={swatch.viewBox} aria-hidden="true">
|
|
1531
|
+
<path
|
|
1532
|
+
data-legend-swatch={entry.key}
|
|
1533
|
+
d={swatch.linePath}
|
|
1534
|
+
fill="none"
|
|
1535
|
+
stroke={swatch.stroke}
|
|
1536
|
+
stroke-width={swatch.strokeWidth}
|
|
1537
|
+
stroke-dasharray={swatch.dashArray}
|
|
1538
|
+
style={connectorDashPaint(entry.strokeStyle)}
|
|
1539
|
+
vector-effect="non-scaling-stroke"
|
|
1540
|
+
/>
|
|
1541
|
+
{#if swatch.arrowPath !== undefined}
|
|
1542
|
+
<path
|
|
1543
|
+
d={swatch.arrowPath}
|
|
1544
|
+
fill={swatch.arrowFill}
|
|
1545
|
+
stroke={swatch.arrowStroke}
|
|
1546
|
+
stroke-width={swatch.arrowStrokeWidth}
|
|
1547
|
+
/>
|
|
1548
|
+
{/if}
|
|
1549
|
+
</svg>
|
|
1550
|
+
<span class="st-diagramSceneFigure-legendLabel">{entry.label}</span>
|
|
1551
|
+
</li>
|
|
1552
|
+
{/each}
|
|
1553
|
+
</ul>
|
|
1554
|
+
</aside>
|
|
1555
|
+
{/if}
|
|
1140
1556
|
{/if}
|
|
1141
1557
|
</div>
|
|
1142
1558
|
</div>
|
|
@@ -1184,6 +1600,15 @@
|
|
|
1184
1600
|
.st-diagramSceneFigure--compact {
|
|
1185
1601
|
gap: var(--st-spacing-1, 0.25rem);
|
|
1186
1602
|
}
|
|
1603
|
+
.st-diagramSceneFigure--fitToWindow {
|
|
1604
|
+
margin-inline: auto;
|
|
1605
|
+
max-width: 100%;
|
|
1606
|
+
}
|
|
1607
|
+
.st-diagramSceneFigure--fitToWindow .st-diagramSceneFigure-viewport {
|
|
1608
|
+
margin-inline: auto;
|
|
1609
|
+
max-height: calc(100vh - var(--st-spacing-6, 1.5rem));
|
|
1610
|
+
max-width: 100%;
|
|
1611
|
+
}
|
|
1187
1612
|
.st-diagramSceneFigure-title {
|
|
1188
1613
|
color: var(--st-semantic-text-primary);
|
|
1189
1614
|
grid-column: 1;
|
|
@@ -1195,8 +1620,55 @@
|
|
|
1195
1620
|
.st-diagramSceneFigure-controls {
|
|
1196
1621
|
align-items: center;
|
|
1197
1622
|
display: inline-flex;
|
|
1623
|
+
flex-wrap: wrap;
|
|
1198
1624
|
gap: var(--st-spacing-1, 0.25rem);
|
|
1199
1625
|
grid-column: 2;
|
|
1626
|
+
justify-content: flex-end;
|
|
1627
|
+
}
|
|
1628
|
+
.st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll) {
|
|
1629
|
+
gap: var(--st-component-diagramScene-controlGap, var(--st-spacing-1, 0.25rem));
|
|
1630
|
+
}
|
|
1631
|
+
.st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll[aria-pressed="true"]),
|
|
1632
|
+
.st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-fullscreen[aria-pressed="true"]),
|
|
1633
|
+
.st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll[aria-pressed="true"]:not(:disabled):hover),
|
|
1634
|
+
.st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-fullscreen[aria-pressed="true"]:not(:disabled):hover) {
|
|
1635
|
+
background: var(--st-component-diagramScene-controlActiveBackground, var(--st-semantic-action-primary));
|
|
1636
|
+
border-color: var(--st-component-diagramScene-controlActiveBorder, var(--st-semantic-action-primary));
|
|
1637
|
+
color: var(--st-component-diagramScene-controlActiveText, var(--st-semantic-action-primaryText));
|
|
1638
|
+
}
|
|
1639
|
+
.st-diagramSceneFigure--fullscreen,
|
|
1640
|
+
.st-diagramSceneFigure:fullscreen {
|
|
1641
|
+
align-content: stretch;
|
|
1642
|
+
background: var(--st-component-diagramScene-fullscreenBackground, var(--st-semantic-surface-default));
|
|
1643
|
+
box-sizing: border-box;
|
|
1644
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
1645
|
+
height: 100vh;
|
|
1646
|
+
height: 100dvh;
|
|
1647
|
+
inset: 0;
|
|
1648
|
+
padding: var(--st-component-diagramScene-fullscreenPadding, var(--st-spacing-4, 1rem));
|
|
1649
|
+
width: 100vw;
|
|
1650
|
+
}
|
|
1651
|
+
.st-diagramSceneFigure--fullscreen:has(.st-diagramSceneFigure-flowNavigator),
|
|
1652
|
+
.st-diagramSceneFigure:fullscreen:has(.st-diagramSceneFigure-flowNavigator) {
|
|
1653
|
+
grid-template-rows: auto auto minmax(0, 1fr);
|
|
1654
|
+
}
|
|
1655
|
+
.st-diagramSceneFigure--fullscreenFallback {
|
|
1656
|
+
position: fixed;
|
|
1657
|
+
z-index: var(--st-component-diagramScene-fullscreenZIndex, var(--st-component-overlay-zIndex, 90));
|
|
1658
|
+
}
|
|
1659
|
+
.st-diagramSceneFigure--fullscreen .st-diagramSceneFigure-frame,
|
|
1660
|
+
.st-diagramSceneFigure:fullscreen .st-diagramSceneFigure-frame {
|
|
1661
|
+
height: 100%;
|
|
1662
|
+
min-height: 0;
|
|
1663
|
+
}
|
|
1664
|
+
.st-diagramSceneFigure--fullscreen .st-diagramSceneFigure-viewport,
|
|
1665
|
+
.st-diagramSceneFigure:fullscreen .st-diagramSceneFigure-viewport {
|
|
1666
|
+
max-height: none;
|
|
1667
|
+
}
|
|
1668
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1669
|
+
.st-diagramSceneFigure-controls :global(button) {
|
|
1670
|
+
transition: none;
|
|
1671
|
+
}
|
|
1200
1672
|
}
|
|
1201
1673
|
.st-diagramSceneFigure-readout {
|
|
1202
1674
|
color: var(--st-semantic-text-secondary);
|
|
@@ -1264,6 +1736,16 @@
|
|
|
1264
1736
|
stroke-width: var(--st-component-diagramZone-borderWidth, 1.5px);
|
|
1265
1737
|
vector-effect: non-scaling-stroke;
|
|
1266
1738
|
}
|
|
1739
|
+
.st-diagramSceneFigure-edge[data-connector-mode="r7"] {
|
|
1740
|
+
stroke-width: var(--st-diagram-link-stroke-width, var(--st-component-diagramScene-linkStrokeWidth, 2.5px));
|
|
1741
|
+
}
|
|
1742
|
+
.st-diagramSceneFigure-edge[data-connector-mode="r7"][data-edge-arrowhead="none"] {
|
|
1743
|
+
stroke-width: var(--st-diagram-link-related-stroke-width, var(--st-component-diagramScene-linkRelatedStrokeWidth, 3px));
|
|
1744
|
+
}
|
|
1745
|
+
.st-diagramSceneFigure-edge[data-connector-mode="r7"][data-edge-emphasis="emphasis"] {
|
|
1746
|
+
stroke: var(--st-component-diagramScene-linkEmphasisStroke, var(--st-semantic-border-interactive));
|
|
1747
|
+
stroke-width: var(--st-diagram-link-emphasis-stroke-width, var(--st-component-diagramScene-linkEmphasisStrokeWidth, 3.5px));
|
|
1748
|
+
}
|
|
1267
1749
|
.st-diagramSceneFigure-edgeLabel {
|
|
1268
1750
|
box-sizing: border-box;
|
|
1269
1751
|
background: var(--st-component-diagramScene-labelSurface, var(--st-semantic-surface-raised));
|
|
@@ -1280,8 +1762,61 @@
|
|
|
1280
1762
|
position: absolute;
|
|
1281
1763
|
white-space: nowrap;
|
|
1282
1764
|
}
|
|
1283
|
-
.st-diagramSceneFigure-edgeLabel
|
|
1765
|
+
.st-diagramSceneFigure-edgeLabel[data-connector-mode="r7"] {
|
|
1766
|
+
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))));
|
|
1767
|
+
--st-diagram-edge-label-line-height: var(--st-diagram-overview-edge-label-line-height, var(--st-diagram-label-line-height, 22px));
|
|
1768
|
+
line-height: var(--st-diagram-edge-label-line-height);
|
|
1769
|
+
}
|
|
1770
|
+
.st-diagramSceneFigure-edgeLabel > span { display: block; flex: none; height: var(--st-diagram-edge-label-line-height, var(--st-diagram-label-line-height, 22px)); }
|
|
1284
1771
|
.st-diagramSceneFigure-bundleHeader { display: block; padding: var(--st-component-diagramScene-labelPadding, 4px); font-weight: 400; }
|
|
1285
1772
|
.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
1773
|
.st-diagramSceneFigure-bundleRelation div { display: flex; flex-direction: column; }
|
|
1774
|
+
.st-diagramSceneFigure-legend {
|
|
1775
|
+
background: var(--st-component-diagramScene-labelSurface, var(--st-semantic-surface-raised));
|
|
1776
|
+
box-shadow: inset 0 0 0 var(--st-component-diagramScene-labelBorderWidth, 1px) var(--st-component-diagramScene-labelBorder, var(--st-semantic-border-subtle));
|
|
1777
|
+
box-sizing: border-box;
|
|
1778
|
+
color: var(--st-component-diagramScene-labelText, var(--st-semantic-text-primary));
|
|
1779
|
+
display: flex;
|
|
1780
|
+
flex-direction: column;
|
|
1781
|
+
font-family: var(--st-component-diagramCard-fontFamily, var(--st-font-sans, Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif));
|
|
1782
|
+
font-size: var(--st-diagram-legend-font-size, var(--st-component-diagramScene-edgeLabelSize, var(--st-component-diagramScene-edgeLabelFontSize, 18px)));
|
|
1783
|
+
gap: var(--st-diagram-legend-header-gap);
|
|
1784
|
+
line-height: var(--st-diagram-label-line-height, var(--st-component-diagramScene-edgeLabelLineHeight, 22px));
|
|
1785
|
+
padding: var(--st-diagram-legend-padding);
|
|
1786
|
+
position: absolute;
|
|
1787
|
+
}
|
|
1788
|
+
.st-diagramSceneFigure-legendTitle {
|
|
1789
|
+
align-items: center;
|
|
1790
|
+
border-bottom: var(--st-component-diagramScene-labelBorderWidth, 1px) solid var(--st-component-diagramScene-labelBorder, var(--st-semantic-border-subtle));
|
|
1791
|
+
box-sizing: border-box;
|
|
1792
|
+
display: flex;
|
|
1793
|
+
flex: none;
|
|
1794
|
+
font-weight: var(--st-component-diagramCard-titleFontWeight, 700);
|
|
1795
|
+
height: var(--st-diagram-legend-header-height);
|
|
1796
|
+
white-space: nowrap;
|
|
1797
|
+
}
|
|
1798
|
+
.st-diagramSceneFigure-legendList {
|
|
1799
|
+
display: flex;
|
|
1800
|
+
flex-direction: column;
|
|
1801
|
+
gap: var(--st-diagram-legend-row-gap);
|
|
1802
|
+
list-style: none;
|
|
1803
|
+
margin: 0;
|
|
1804
|
+
padding: 0;
|
|
1805
|
+
}
|
|
1806
|
+
.st-diagramSceneFigure-legendItem {
|
|
1807
|
+
align-items: center;
|
|
1808
|
+
box-sizing: border-box;
|
|
1809
|
+
display: flex;
|
|
1810
|
+
flex: none;
|
|
1811
|
+
gap: var(--st-diagram-legend-swatch-gap);
|
|
1812
|
+
height: var(--st-diagram-legend-row-height);
|
|
1813
|
+
white-space: nowrap;
|
|
1814
|
+
}
|
|
1815
|
+
.st-diagramSceneFigure-legendSwatch {
|
|
1816
|
+
flex: none;
|
|
1817
|
+
height: var(--st-diagram-legend-swatch-height);
|
|
1818
|
+
overflow: visible;
|
|
1819
|
+
width: var(--st-diagram-legend-swatch-width);
|
|
1820
|
+
}
|
|
1821
|
+
.st-diagramSceneFigure-legendLabel { white-space: nowrap; }
|
|
1287
1822
|
</style>
|