@sentropic/design-system-svelte 0.44.0 → 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 +298 -38
- package/dist/DiagramSceneFigure.svelte.d.ts +7 -0
- 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 +42 -22
- package/package.json +4 -4
package/LICENSE.THIRD-PARTY.md
CHANGED
|
@@ -25,16 +25,16 @@ sources à l'amont installé : il ne peut pas se désynchroniser en silence.
|
|
|
25
25
|
|
|
26
26
|
**Ce qui est copié.** Des chaînes de tracé SVG (attribut `d`) identiques octet pour octet aux données d'icônes lucide, écrites directement dans nos fichiers source et compilées dans le `dist/` publié.
|
|
27
27
|
|
|
28
|
-
**Étendue mesurée.**
|
|
29
|
-
|
|
28
|
+
**Étendue mesurée.** 29 chaîne(s) de tracé distincte(s),
|
|
29
|
+
32 occurrence(s), dans 2 fichier(s) source de ce paquet :
|
|
30
30
|
|
|
31
31
|
| Fichier source | Occurrences |
|
|
32
32
|
|---|---|
|
|
33
33
|
| `src/lib/cellDecoration.ts` | 21 |
|
|
34
|
-
| `src/lib/flow-fixtures/before.html` |
|
|
34
|
+
| `src/lib/flow-fixtures/before.html` | 11 |
|
|
35
35
|
|
|
36
36
|
Glyphes amont concernés (une chaîne partagée par plusieurs glyphes les nomme tous) :
|
|
37
|
-
`arrow-down`, `arrow-right`, `arrow-up`, `badge-percent`, `barcode`, `check`, `circle-check-big`, `circle-percent`, `circle-question-mark`, `circle-x`, `cloud-snow`, `file-exclamation-point`, `file-question-mark`, `flame`, `house-wifi`, `info`, `message-circle-question-mark`, `message-circle-x`, `minus`, `octagon-x`, `plus`, `shield-question-mark`, `square-check-big`, `square-percent`, `square-x`, `ticket-percent`, `trending-down`, `trending-up`, `triangle-alert`, `x`.
|
|
37
|
+
`arrow-down`, `arrow-right`, `arrow-up`, `badge-percent`, `barcode`, `check`, `circle-check-big`, `circle-percent`, `circle-question-mark`, `circle-x`, `cloud-snow`, `external-link`, `file-exclamation-point`, `file-question-mark`, `flame`, `focus`, `fullscreen`, `house-wifi`, `info`, `maximize-2`, `message-circle-question-mark`, `message-circle-x`, `minimize-2`, `minus`, `octagon-x`, `plus`, `scan`, `scan-barcode`, `scan-eye`, `scan-face`, `scan-heart`, `scan-line`, `scan-qr-code`, `scan-search`, `scan-text`, `shield-question-mark`, `square-arrow-out-down-left`, `square-arrow-out-up-right`, `square-check-big`, `square-percent`, `square-x`, `ticket-percent`, `trending-down`, `trending-up`, `triangle-alert`, `x`.
|
|
38
38
|
|
|
39
39
|
**Pourquoi c'est une redistribution.** Le jeu d'icônes du design system est lucide : `packages/components-angular/src/Icon.ts` le dit explicitement (« the same lucide (stroke-24) path data the other frameworks wrap — the single visual source of truth »). Inliner les données plutôt que dépendre du paquet ne supprime pas l'obligation : cela la déplace du `node_modules` du consommateur vers notre propre tarball. Le port Angular ne déclare aucune dépendance lucide et n'embarque que des copies ; les ports React, Vue et Svelte dépendent du paquet lucide ET en recopient une partie.
|
|
40
40
|
|
|
@@ -1,11 +1,12 @@
|
|
|
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,
|
|
10
11
|
isR7ConnectorPresentation,
|
|
11
12
|
zoomReadout,
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
import DiagramCard from "./DiagramCard.svelte";
|
|
22
23
|
import DiagramZone from "./DiagramZone.svelte";
|
|
23
24
|
import IconButton from "./IconButton.svelte";
|
|
24
|
-
import { measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
|
|
25
|
+
import { committedWorldScale, measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
|
|
25
26
|
import { measureRenderedSceneFont } from "./diagramFontMeasure.js";
|
|
26
27
|
import Select from "./Select.svelte";
|
|
27
28
|
import { DEFAULT_FLOW_TOKENS, type FlowTokens } from "@sentropic/diagram-canvas";
|
|
@@ -130,6 +131,10 @@
|
|
|
130
131
|
zoomOut: string;
|
|
131
132
|
/** Visible text of the fit / reset control (« Ajuster »). */
|
|
132
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;
|
|
133
138
|
/** Accessible name of the readout, e.g. « Zoom 85 % ». */
|
|
134
139
|
zoomLevel: (percent: number) => string;
|
|
135
140
|
/** Accessible name of the scrollable drawing region. */
|
|
@@ -212,7 +217,7 @@
|
|
|
212
217
|
onSizeChange?: (size: DiagramSceneSize) => void;
|
|
213
218
|
}
|
|
214
219
|
|
|
215
|
-
const DEFAULT_LABELS
|
|
220
|
+
const DEFAULT_LABELS = DEFAULT_SCENE_LABELS;
|
|
216
221
|
|
|
217
222
|
const TOKEN_MAX_DISPLAY_SCALE = "--st-component-diagramScene-maxDisplayScale";
|
|
218
223
|
const TOKEN_MIN_READABLE_SCALE = "--st-component-diagramScene-minReadableScale";
|
|
@@ -373,14 +378,34 @@
|
|
|
373
378
|
|
|
374
379
|
let viewWidth = $state<number>();
|
|
375
380
|
let windowHeight = $state<number>();
|
|
381
|
+
let measuredFrameHeight = $state<number>();
|
|
382
|
+
let controlsHeight = $state(0);
|
|
376
383
|
let scrollbarHeight = $state(0);
|
|
377
384
|
let maxDisplayScale = $state<number>();
|
|
378
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
|
+
);
|
|
379
402
|
const sceneFitInput = $derived({
|
|
380
403
|
// Before the frame is measured (server render, hidden mount) the fit
|
|
381
404
|
// box is the nominal 16:9 box of the layout target width.
|
|
382
405
|
viewWidth: frameWidth ?? targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
|
|
383
406
|
windowHeight: windowHeight ?? Number.POSITIVE_INFINITY,
|
|
407
|
+
...(fullscreenViewHeight === undefined ? {} : { viewHeight: fullscreenViewHeight }),
|
|
408
|
+
...(viewAll ? { unconstrained: true } : {}),
|
|
384
409
|
...(maxDisplayScale === undefined ? {} : { maxDisplayScale }),
|
|
385
410
|
...(minReadableScale === undefined ? {} : { minReadableScale }),
|
|
386
411
|
...(fitToWindow ? { fitToWindow: true } : {}),
|
|
@@ -579,6 +604,8 @@
|
|
|
579
604
|
|
|
580
605
|
/* ── measured frame and tokens (client only) ───────────────────── */
|
|
581
606
|
|
|
607
|
+
let figureEl = $state<HTMLElement>();
|
|
608
|
+
let controlsEl = $state<HTMLElement>();
|
|
582
609
|
let frameEl = $state<HTMLElement>();
|
|
583
610
|
let viewportEl = $state<HTMLElement>();
|
|
584
611
|
$effect(() => {
|
|
@@ -588,22 +615,25 @@
|
|
|
588
615
|
if (select !== undefined && select !== null) select.value = filter === undefined ? "all" : `scenario:${filter}`;
|
|
589
616
|
}
|
|
590
617
|
});
|
|
591
|
-
let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect }>();
|
|
618
|
+
let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect; scale: number }>();
|
|
592
619
|
const cameraBounds = $derived(renderedBounds?.scene === scene ? renderedBounds?.bounds : scene?.bounds);
|
|
593
620
|
// `zoom` is the scale the world is painted at: the fit is quantised once,
|
|
594
621
|
// in `sceneFit`, and printed as it is, so painted rects divide back by it.
|
|
595
622
|
// The first read of a scene fits; a later one refits only when it differs
|
|
596
|
-
// from that read by more than the measurement granularity
|
|
597
|
-
// comes back as the model bounds is a
|
|
598
|
-
// earlier, larger one, and the next one
|
|
599
|
-
// A fold transition paints interpolated rectangles and
|
|
600
|
-
// 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.
|
|
601
628
|
function readRenderedBounds(): void {
|
|
602
629
|
if (frameEl === undefined || scene === undefined || animating) return;
|
|
603
|
-
const
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
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 };
|
|
607
637
|
}
|
|
608
638
|
$effect(() => {
|
|
609
639
|
const current = scene;
|
|
@@ -622,21 +652,27 @@
|
|
|
622
652
|
return () => { active = false; };
|
|
623
653
|
});
|
|
624
654
|
|
|
625
|
-
function tokenValue(name: string): string | undefined {
|
|
655
|
+
function tokenValue(name: string, style?: CSSStyleDeclaration): string | undefined {
|
|
626
656
|
if (frameEl === undefined) return undefined;
|
|
627
|
-
const value = getComputedStyle(frameEl).getPropertyValue(name).trim();
|
|
657
|
+
const value = (style ?? getComputedStyle(frameEl)).getPropertyValue(name).trim();
|
|
628
658
|
return value === "" ? undefined : value;
|
|
629
659
|
}
|
|
630
660
|
|
|
631
|
-
function lengthTokenValue(
|
|
661
|
+
function lengthTokenValue(
|
|
662
|
+
name: string,
|
|
663
|
+
style?: CSSStyleDeclaration,
|
|
664
|
+
context?: { readonly rootFontSize?: number; readonly elementFontSize?: number },
|
|
665
|
+
): number | undefined {
|
|
632
666
|
if (frameEl === undefined) return undefined;
|
|
633
|
-
const raw = tokenValue(name);
|
|
667
|
+
const raw = tokenValue(name, style);
|
|
634
668
|
if (raw === undefined) return undefined;
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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);
|
|
640
676
|
if (parsed !== undefined || !/^(calc|min|max|clamp)\(/i.test(raw)) return parsed;
|
|
641
677
|
const probe = frameEl.ownerDocument.createElement("span");
|
|
642
678
|
probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
|
|
@@ -644,7 +680,7 @@
|
|
|
644
680
|
if (probe.style.fontSize === "") return undefined;
|
|
645
681
|
frameEl.appendChild(probe);
|
|
646
682
|
try {
|
|
647
|
-
return parseCssLengthPx(getComputedStyle(probe).fontSize,
|
|
683
|
+
return parseCssLengthPx(getComputedStyle(probe).fontSize, resolvedContext);
|
|
648
684
|
} finally {
|
|
649
685
|
probe.remove();
|
|
650
686
|
}
|
|
@@ -683,23 +719,28 @@
|
|
|
683
719
|
// m3: camera tokens are re-read on every measure and before every camera
|
|
684
720
|
// input, so a post-mount theme change applies without waiting for a resize.
|
|
685
721
|
function readCameraTokens(): void {
|
|
722
|
+
const style = frameEl === undefined ? undefined : getComputedStyle(frameEl);
|
|
686
723
|
const values: Record<string, number> = {};
|
|
687
724
|
const baseKeys = ["gapMin","gapMinBlock","gapBase","gapBaseBlock","trackSpacing","trackSpacingBlock","labelBand","gapMax","bundleLabelMaxWidth","containerPadding"];
|
|
688
725
|
const r7Keys = ["zoneGutter","routeSpacing","routeBorderClearance","edgeCornerRadius","linkStrokeWidth","linkRelatedStrokeWidth","linkEmphasisStrokeWidth"];
|
|
689
726
|
for (const key of baseKeys) {
|
|
690
|
-
const value = parseFloat(tokenValue("--st-component-diagramScene-" + key) ?? "");
|
|
727
|
+
const value = parseFloat(tokenValue("--st-component-diagramScene-" + key, style) ?? "");
|
|
691
728
|
if (Number.isFinite(value)) values[key] = value;
|
|
692
729
|
}
|
|
693
|
-
const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding") ?? "");
|
|
730
|
+
const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding", style) ?? "");
|
|
694
731
|
if (Number.isFinite(labelMargin)) values.labelMargin = labelMargin;
|
|
695
|
-
if (r7Mode) {
|
|
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 };
|
|
696
737
|
for (const key of r7Keys) {
|
|
697
|
-
const value = lengthTokenValue("--st-component-diagramScene-" + key);
|
|
738
|
+
const value = lengthTokenValue("--st-component-diagramScene-" + key, style, lengthContext);
|
|
698
739
|
if (value !== undefined && Number.isFinite(value)) values[key] = value;
|
|
699
740
|
}
|
|
700
741
|
const edgeLabelSize = resolveEdgeLabelSizeToken(
|
|
701
|
-
lengthTokenValue("--st-component-diagramScene-edgeLabelSize"),
|
|
702
|
-
lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize"),
|
|
742
|
+
lengthTokenValue("--st-component-diagramScene-edgeLabelSize", style, lengthContext),
|
|
743
|
+
lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize", style, lengthContext),
|
|
703
744
|
);
|
|
704
745
|
if (edgeLabelSize !== undefined) values.edgeLabelSize = edgeLabelSize;
|
|
705
746
|
}
|
|
@@ -710,13 +751,13 @@
|
|
|
710
751
|
}
|
|
711
752
|
const nextTokens = { ...DEFAULT_FLOW_TOKENS };
|
|
712
753
|
for (const name of Object.keys(nextTokens) as (keyof FlowTokens)[]) {
|
|
713
|
-
const value = tokenValue(`--st-component-diagramScene-${name}
|
|
754
|
+
const value = tokenValue(`--st-component-diagramScene-${name}`, style);
|
|
714
755
|
if (name === "flowArrowPath") { if (value?.trim()) nextTokens.flowArrowPath = value.trim(); }
|
|
715
756
|
else { const number = parseScale(value); if (number !== undefined) (nextTokens as unknown as Record<string, number>)[name] = number; }
|
|
716
757
|
}
|
|
717
758
|
if (JSON.stringify(nextTokens) !== JSON.stringify(flowTokens)) flowTokens = nextTokens;
|
|
718
|
-
maxDisplayScale = parseScale(tokenValue(TOKEN_MAX_DISPLAY_SCALE));
|
|
719
|
-
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));
|
|
720
761
|
}
|
|
721
762
|
|
|
722
763
|
$effect(() => {
|
|
@@ -729,7 +770,12 @@
|
|
|
729
770
|
|
|
730
771
|
function measureFrame(resize = false): void {
|
|
731
772
|
if (frameEl === undefined) return;
|
|
732
|
-
const
|
|
773
|
+
const rawWidth = frameEl.clientWidth;
|
|
774
|
+
const width = rawWidth > 0
|
|
775
|
+
? rawWidth
|
|
776
|
+
: fullscreen && window.innerWidth > 0
|
|
777
|
+
? window.innerWidth
|
|
778
|
+
: undefined;
|
|
733
779
|
const frameHeight = frameEl.clientHeight;
|
|
734
780
|
const viewportOuterHeight = viewportEl?.offsetHeight ?? 0;
|
|
735
781
|
// The frame can grow with its viewport when a scrollbar appears.
|
|
@@ -742,6 +788,8 @@
|
|
|
742
788
|
const height = window.innerHeight > 0 ? window.innerHeight : undefined;
|
|
743
789
|
const refit = resize || width !== frameWidth || frameHeightChanged || height !== windowHeight;
|
|
744
790
|
frameWidth = width;
|
|
791
|
+
measuredFrameHeight = frameHeight > 0 ? frameHeight : undefined;
|
|
792
|
+
controlsHeight = controlsEl?.offsetHeight ?? 0;
|
|
745
793
|
viewWidth = viewportEl?.clientWidth || width;
|
|
746
794
|
scrollbarHeight = viewportOuterHeight - (viewportEl?.clientHeight ?? 0);
|
|
747
795
|
windowHeight = height;
|
|
@@ -756,17 +804,32 @@
|
|
|
756
804
|
const element = frameEl;
|
|
757
805
|
if (element === undefined) return;
|
|
758
806
|
untrack(() => measureFrame());
|
|
807
|
+
const doc = element.ownerDocument;
|
|
759
808
|
const onResize = (): void => measureFrame(true);
|
|
760
|
-
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;
|
|
761
819
|
window.addEventListener("resize", onResize);
|
|
820
|
+
doc.addEventListener("fullscreenchange", onFullscreenChange);
|
|
762
821
|
fonts?.addEventListener?.("loadingdone", refitForFonts);
|
|
763
822
|
const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(() => measureFrame());
|
|
764
823
|
observer?.observe(element);
|
|
765
824
|
if (viewportEl !== undefined) observer?.observe(viewportEl);
|
|
766
825
|
return () => {
|
|
767
826
|
window.removeEventListener("resize", onResize);
|
|
827
|
+
doc.removeEventListener("fullscreenchange", onFullscreenChange);
|
|
768
828
|
fonts?.removeEventListener?.("loadingdone", refitForFonts);
|
|
769
829
|
observer?.disconnect();
|
|
830
|
+
if (figureEl !== undefined && doc.fullscreenElement === figureEl && typeof doc.exitFullscreen === "function") {
|
|
831
|
+
try { void doc.exitFullscreen()?.catch?.(() => undefined); } catch { /* ignore */ }
|
|
832
|
+
}
|
|
770
833
|
};
|
|
771
834
|
});
|
|
772
835
|
|
|
@@ -797,7 +860,11 @@
|
|
|
797
860
|
$effect.pre(() => {
|
|
798
861
|
const id = semanticDocument.documentId;
|
|
799
862
|
if (cameraDocument !== undefined && cameraDocument !== id) {
|
|
800
|
-
untrack(
|
|
863
|
+
untrack(() => {
|
|
864
|
+
viewAll = false;
|
|
865
|
+
if (fullscreen) exitFullscreen();
|
|
866
|
+
resetToFit();
|
|
867
|
+
});
|
|
801
868
|
fittedFonts = undefined;
|
|
802
869
|
browserMeasure = undefined;
|
|
803
870
|
renderedBounds = undefined;
|
|
@@ -885,6 +952,113 @@
|
|
|
885
952
|
resetToFit();
|
|
886
953
|
}
|
|
887
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
|
+
|
|
888
1062
|
export function getCamera(): DiagramSceneCamera {
|
|
889
1063
|
return {
|
|
890
1064
|
zoom,
|
|
@@ -896,6 +1070,19 @@
|
|
|
896
1070
|
};
|
|
897
1071
|
}
|
|
898
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
|
+
|
|
899
1086
|
function onKeydown(event: KeyboardEvent): void {
|
|
900
1087
|
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
901
1088
|
// m5: shortcuts work from non-input descendants (card buttons, nodes);
|
|
@@ -905,8 +1092,18 @@
|
|
|
905
1092
|
const tag = target.tagName;
|
|
906
1093
|
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable || target.closest("[contenteditable]")) return;
|
|
907
1094
|
}
|
|
1095
|
+
if (!event.shiftKey && event.key === "Escape" && fallbackFullscreen) {
|
|
1096
|
+
exitFullscreen();
|
|
1097
|
+
event.preventDefault();
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
908
1100
|
if (!event.shiftKey && roveFlow(event)) return;
|
|
909
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
|
+
}
|
|
910
1107
|
dispatchFlow({ type: event.key === "]" ? "next" : event.key === "[" ? "previous" : "escape" }); event.preventDefault(); return;
|
|
911
1108
|
}
|
|
912
1109
|
if (event.key === "+" || event.key === "=") zoomIn();
|
|
@@ -1110,25 +1307,30 @@
|
|
|
1110
1307
|
return `;--st-diagram-overview-edge-label-size:${size}px;--st-diagram-overview-edge-label-line-height:${lineHeight}px`;
|
|
1111
1308
|
});
|
|
1112
1309
|
const viewportStyle = $derived(
|
|
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` : ""}`,
|
|
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` : ""}`,
|
|
1114
1311
|
);
|
|
1115
1312
|
const worldStyle = $derived(
|
|
1116
1313
|
`transform:translate(${placement.translateX}px,${placement.translateY}px) scale(${zoom})`,
|
|
1117
1314
|
);
|
|
1118
1315
|
</script>
|
|
1119
1316
|
|
|
1317
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
1120
1318
|
<figure
|
|
1121
|
-
|
|
1319
|
+
bind:this={figureEl}
|
|
1320
|
+
class={`st-diagramSceneFigure${compact ? " st-diagramSceneFigure--compact" : ""}${fitToWindow ? " st-diagramSceneFigure--fitToWindow" : ""}${fullscreen ? " st-diagramSceneFigure--fullscreen" : ""}${fallbackFullscreen ? " st-diagramSceneFigure--fullscreenFallback" : ""}`}
|
|
1122
1321
|
aria-label={label ?? title}
|
|
1123
1322
|
data-zoom={zoom}
|
|
1124
1323
|
data-zoom-readout={readout}
|
|
1125
1324
|
data-fit-to-window={fitToWindow ? "true" : undefined}
|
|
1325
|
+
data-view-all={viewAll ? "true" : undefined}
|
|
1326
|
+
data-fullscreen={fullscreenMode}
|
|
1126
1327
|
data-scene-refused={layoutResult.status === "refused" ? layoutResult.refusals[0]?.code : undefined}
|
|
1328
|
+
onkeydown={onFigureKeydown}
|
|
1127
1329
|
>
|
|
1128
1330
|
{#if title !== undefined}
|
|
1129
1331
|
<figcaption class="st-diagramSceneFigure-title">{title}</figcaption>
|
|
1130
1332
|
{/if}
|
|
1131
|
-
<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}>
|
|
1132
1334
|
<IconButton size="sm" variant="secondary" aria-label={strings.zoomOut} disabled={!canZoomOut} onclick={zoomOut}>
|
|
1133
1335
|
<Minus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
|
|
1134
1336
|
</IconButton>
|
|
@@ -1139,6 +1341,17 @@
|
|
|
1139
1341
|
<Plus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
|
|
1140
1342
|
</IconButton>
|
|
1141
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>
|
|
1142
1355
|
</div>
|
|
1143
1356
|
{#if flowSteps.length > 0}
|
|
1144
1357
|
<div class="st-diagramSceneFigure-flowNavigator" role="group" aria-label={strings.navigator}>
|
|
@@ -1407,8 +1620,55 @@
|
|
|
1407
1620
|
.st-diagramSceneFigure-controls {
|
|
1408
1621
|
align-items: center;
|
|
1409
1622
|
display: inline-flex;
|
|
1623
|
+
flex-wrap: wrap;
|
|
1410
1624
|
gap: var(--st-spacing-1, 0.25rem);
|
|
1411
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
|
+
}
|
|
1412
1672
|
}
|
|
1413
1673
|
.st-diagramSceneFigure-readout {
|
|
1414
1674
|
color: var(--st-semantic-text-secondary);
|
|
@@ -51,6 +51,10 @@ export interface DiagramSceneFigureLabels {
|
|
|
51
51
|
zoomOut: string;
|
|
52
52
|
/** Visible text of the fit / reset control (« Ajuster »). */
|
|
53
53
|
fit: string;
|
|
54
|
+
/** Visible text of the whole-scene fit control (« Tout voir »). */
|
|
55
|
+
viewAll?: string;
|
|
56
|
+
/** Accessible name of the fullscreen control (« Plein écran »). */
|
|
57
|
+
fullscreen?: string;
|
|
54
58
|
/** Accessible name of the readout, e.g. « Zoom 85 % ». */
|
|
55
59
|
zoomLevel: (percent: number) => string;
|
|
56
60
|
/** Accessible name of the scrollable drawing region. */
|
|
@@ -139,6 +143,9 @@ declare const DiagramSceneFigure: import("svelte").Component<DiagramSceneFigureP
|
|
|
139
143
|
zoomIn: () => void;
|
|
140
144
|
zoomOut: () => void;
|
|
141
145
|
fitToFrame: () => void;
|
|
146
|
+
toggleFullscreen: () => void;
|
|
147
|
+
setViewAll: (enabled: boolean) => void;
|
|
148
|
+
toggleViewAll: () => void;
|
|
142
149
|
getCamera: () => DiagramSceneCamera;
|
|
143
150
|
}, "contentSize">;
|
|
144
151
|
type DiagramSceneFigure = ReturnType<typeof DiagramSceneFigure>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagramSceneFigure.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramSceneFigure.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"DiagramSceneFigure.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramSceneFigure.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAQH,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,EAaH,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAsBrB,KAAK,gBAAgB,EACrB,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,M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operands on the
|
|
14
14
|
* LayoutUnit grid, so a read places it within one LayoutUnit of screen
|
|
15
15
|
* space: `1 / (64 × zoom)` world unit;
|
|
16
|
-
* - no read happens under the readability floor (
|
|
17
|
-
*
|
|
16
|
+
* - on the default path, no read happens under the readability floor (0.30),
|
|
17
|
+
* where that step is at its widest: `1 / (64 × 0.30)`;
|
|
18
|
+
* - in unconstrained (« Tout voir ») or `fitToWindow` mode, zoom can drop
|
|
19
|
+
* below 0.30, widening that step to `1 / (64 × zoom)`;
|
|
18
20
|
* - the edge is then rounded outward to the 1/64 world-unit grid, which
|
|
19
21
|
* moves it by less than one more step;
|
|
20
22
|
* - a stroke is added to its edge in world units, at one width for every
|
|
21
|
-
* zoom and interaction state
|
|
22
|
-
* both reads alike.
|
|
23
|
+
* zoom and interaction state within the current fit mode (see
|
|
24
|
+
* `measureRenderedBounds`): it shifts both reads alike.
|
|
23
25
|
*
|
|
24
|
-
* Two reads of an unchanged edge, through any two transforms
|
|
25
|
-
* differ by less than `(2 / 0.30 + 1) / 64`
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* last grid step, and a fit then alternates between two transforms. At the
|
|
31
|
-
* 0.62 cap the tolerance is 0.075 CSS px, far under the 1 CSS px paint
|
|
32
|
-
* inset, so it cannot hide a real overflow.
|
|
26
|
+
* Two reads of an unchanged edge, through any two transforms at or above
|
|
27
|
+
* `scale`, therefore differ by less than `(2 / min(0.30, scale) + 1) / 64`
|
|
28
|
+
* world units (`≈ 0.120` at the 0.30 floor, `≈ 0.151` at 0.23, `≈ 0.276` at
|
|
29
|
+
* 0.12). On screen at that scale this stays near `(2 + scale) / 64` CSS px
|
|
30
|
+
* (`≈ 0.035` CSS px), far under the 1 CSS px paint inset, so it cannot hide
|
|
31
|
+
* a real overflow while preventing LayoutUnit flip oscillation.
|
|
33
32
|
*/
|
|
34
33
|
export declare const RENDERED_BOUNDS_REFIT_TOLERANCE: number;
|
|
34
|
+
/**
|
|
35
|
+
* Scale-aware refit tolerance, world units. Equals
|
|
36
|
+
* `RENDERED_BOUNDS_REFIT_TOLERANCE` for scales at or above
|
|
37
|
+
* `DEFAULT_MIN_READABLE_SCALE` (0.30), and widens proportionally below 0.30
|
|
38
|
+
* to match the 1/64 CSS px LayoutUnit quantisation at sub-floor scales.
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderedBoundsRefitTolerance(scale?: number): number;
|
|
41
|
+
/** Scale committed on the world element's transform, falling back to `hostZoom`. */
|
|
42
|
+
export declare function committedWorldScale(frame: HTMLElement, hostZoom: number): number;
|
|
35
43
|
/**
|
|
36
44
|
* Whether a painted-bounds read differs enough from the previous read of
|
|
37
45
|
* the same scene to refit. The first read (`previous` absent) always fits:
|
|
38
46
|
* the tolerance bounds the distance between two reads, not between a read
|
|
39
|
-
* and the model geometry.
|
|
40
|
-
*
|
|
47
|
+
* and the model geometry. Pass the minimum painted scale of the two reads
|
|
48
|
+
* when comparing sub-0.30 fits so a fit remains a fixed point.
|
|
41
49
|
*/
|
|
42
|
-
export declare function shouldRefitRenderedBounds(previous: Rect | undefined, next: Rect): boolean;
|
|
50
|
+
export declare function shouldRefitRenderedBounds(previous: Rect | undefined, next: Rect, scale?: number): boolean;
|
|
43
51
|
/**
|
|
44
52
|
* Painted bounds in world units, after font/layout settling. DOM-free scene
|
|
45
53
|
* geometry remains the SSR fallback. Include text ink and SVG strokes:
|
|
@@ -53,14 +61,14 @@ export declare function shouldRefitRenderedBounds(previous: Rect | undefined, ne
|
|
|
53
61
|
*
|
|
54
62
|
* - a stroke that scales with the world has a constant world width;
|
|
55
63
|
* - a `non-scaling-stroke` has a constant screen width, so its world width
|
|
56
|
-
* is `width / zoom`. It is framed at its widest
|
|
57
|
-
*
|
|
58
|
-
*
|
|
64
|
+
* is `width / zoom`. It is framed at its widest within the active fit mode
|
|
65
|
+
* (`min(DEFAULT_MIN_READABLE_SCALE, minScale, zoom)`), at every zoom, and
|
|
66
|
+
* at its resting width;
|
|
59
67
|
* - geometry that paints nothing is left out: flow hit targets
|
|
60
68
|
* (`[data-flow-hit]`, a transparent 16 px stroke), flow focus targets
|
|
61
69
|
* (`[data-flow-node]`, hidden at rest and sized in screen px), transparent
|
|
62
70
|
* strokes and text, shapes with neither stroke nor fill, and hidden or
|
|
63
71
|
* clipped subtrees. What a fold transition is fading in stays in.
|
|
64
72
|
*/
|
|
65
|
-
export declare function measureRenderedBounds(frame: HTMLElement, fallback: Rect | undefined, hostZoom: number): Rect | undefined;
|
|
73
|
+
export declare function measureRenderedBounds(frame: HTMLElement, fallback: Rect | undefined, hostZoom: number, minScale?: number): Rect | undefined;
|
|
66
74
|
//# sourceMappingURL=diagramRenderedBounds.d.ts.map
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,+BAA+B,QAA8C,CAAC;AAE3F;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,GAAE,MAAmC,GAAG,MAAM,CAK/F;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKhF;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CASzG;AAkED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,IAAI,GAAG,SAAS,EAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAmC,GAC5C,IAAI,GAAG,SAAS,CAmFlB"}
|
|
@@ -14,37 +14,56 @@ const GRID = RENDERED_BOUNDS_GRID_STEPS;
|
|
|
14
14
|
* - a painted edge is read as `(edge − origin) / zoom`, both operands on the
|
|
15
15
|
* LayoutUnit grid, so a read places it within one LayoutUnit of screen
|
|
16
16
|
* space: `1 / (64 × zoom)` world unit;
|
|
17
|
-
* - no read happens under the readability floor (
|
|
18
|
-
*
|
|
17
|
+
* - on the default path, no read happens under the readability floor (0.30),
|
|
18
|
+
* where that step is at its widest: `1 / (64 × 0.30)`;
|
|
19
|
+
* - in unconstrained (« Tout voir ») or `fitToWindow` mode, zoom can drop
|
|
20
|
+
* below 0.30, widening that step to `1 / (64 × zoom)`;
|
|
19
21
|
* - the edge is then rounded outward to the 1/64 world-unit grid, which
|
|
20
22
|
* moves it by less than one more step;
|
|
21
23
|
* - a stroke is added to its edge in world units, at one width for every
|
|
22
|
-
* zoom and interaction state
|
|
23
|
-
* both reads alike.
|
|
24
|
+
* zoom and interaction state within the current fit mode (see
|
|
25
|
+
* `measureRenderedBounds`): it shifts both reads alike.
|
|
24
26
|
*
|
|
25
|
-
* Two reads of an unchanged edge, through any two transforms
|
|
26
|
-
* differ by less than `(2 / 0.30 + 1) / 64`
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* last grid step, and a fit then alternates between two transforms. At the
|
|
32
|
-
* 0.62 cap the tolerance is 0.075 CSS px, far under the 1 CSS px paint
|
|
33
|
-
* inset, so it cannot hide a real overflow.
|
|
27
|
+
* Two reads of an unchanged edge, through any two transforms at or above
|
|
28
|
+
* `scale`, therefore differ by less than `(2 / min(0.30, scale) + 1) / 64`
|
|
29
|
+
* world units (`≈ 0.120` at the 0.30 floor, `≈ 0.151` at 0.23, `≈ 0.276` at
|
|
30
|
+
* 0.12). On screen at that scale this stays near `(2 + scale) / 64` CSS px
|
|
31
|
+
* (`≈ 0.035` CSS px), far under the 1 CSS px paint inset, so it cannot hide
|
|
32
|
+
* a real overflow while preventing LayoutUnit flip oscillation.
|
|
34
33
|
*/
|
|
35
34
|
export const RENDERED_BOUNDS_REFIT_TOLERANCE = (2 / DEFAULT_MIN_READABLE_SCALE + 1) / GRID;
|
|
35
|
+
/**
|
|
36
|
+
* Scale-aware refit tolerance, world units. Equals
|
|
37
|
+
* `RENDERED_BOUNDS_REFIT_TOLERANCE` for scales at or above
|
|
38
|
+
* `DEFAULT_MIN_READABLE_SCALE` (0.30), and widens proportionally below 0.30
|
|
39
|
+
* to match the 1/64 CSS px LayoutUnit quantisation at sub-floor scales.
|
|
40
|
+
*/
|
|
41
|
+
export function renderedBoundsRefitTolerance(scale = DEFAULT_MIN_READABLE_SCALE) {
|
|
42
|
+
const floor = Number.isFinite(scale) && scale > 0
|
|
43
|
+
? Math.min(DEFAULT_MIN_READABLE_SCALE, scale)
|
|
44
|
+
: DEFAULT_MIN_READABLE_SCALE;
|
|
45
|
+
return (2 / floor + 1) / GRID;
|
|
46
|
+
}
|
|
47
|
+
/** Scale committed on the world element's transform, falling back to `hostZoom`. */
|
|
48
|
+
export function committedWorldScale(frame, hostZoom) {
|
|
49
|
+
const world = frame.querySelector('.st-diagramSceneFigure-world');
|
|
50
|
+
if (!world)
|
|
51
|
+
return hostZoom;
|
|
52
|
+
const committed = Number(/\bscale\(\s*([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)\s*\)/i.exec(world.style.transform)?.[1]);
|
|
53
|
+
return committed > 0 ? committed : hostZoom;
|
|
54
|
+
}
|
|
36
55
|
/**
|
|
37
56
|
* Whether a painted-bounds read differs enough from the previous read of
|
|
38
57
|
* the same scene to refit. The first read (`previous` absent) always fits:
|
|
39
58
|
* the tolerance bounds the distance between two reads, not between a read
|
|
40
|
-
* and the model geometry.
|
|
41
|
-
*
|
|
59
|
+
* and the model geometry. Pass the minimum painted scale of the two reads
|
|
60
|
+
* when comparing sub-0.30 fits so a fit remains a fixed point.
|
|
42
61
|
*/
|
|
43
|
-
export function shouldRefitRenderedBounds(previous, next) {
|
|
62
|
+
export function shouldRefitRenderedBounds(previous, next, scale) {
|
|
44
63
|
if (previous === undefined)
|
|
45
64
|
return true;
|
|
46
65
|
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
|
-
return delta >
|
|
66
|
+
return delta > renderedBoundsRefitTolerance(scale);
|
|
48
67
|
}
|
|
49
68
|
/** Token default of a resting numbered-flow stroke, CSS px (DC-2c). */
|
|
50
69
|
const RESTING_FLOW_STROKE_WIDTH = 1.5;
|
|
@@ -124,16 +143,16 @@ function restingStrokeWidth(element, style) {
|
|
|
124
143
|
*
|
|
125
144
|
* - a stroke that scales with the world has a constant world width;
|
|
126
145
|
* - a `non-scaling-stroke` has a constant screen width, so its world width
|
|
127
|
-
* is `width / zoom`. It is framed at its widest
|
|
128
|
-
*
|
|
129
|
-
*
|
|
146
|
+
* is `width / zoom`. It is framed at its widest within the active fit mode
|
|
147
|
+
* (`min(DEFAULT_MIN_READABLE_SCALE, minScale, zoom)`), at every zoom, and
|
|
148
|
+
* at its resting width;
|
|
130
149
|
* - geometry that paints nothing is left out: flow hit targets
|
|
131
150
|
* (`[data-flow-hit]`, a transparent 16 px stroke), flow focus targets
|
|
132
151
|
* (`[data-flow-node]`, hidden at rest and sized in screen px), transparent
|
|
133
152
|
* strokes and text, shapes with neither stroke nor fill, and hidden or
|
|
134
153
|
* clipped subtrees. What a fold transition is fading in stays in.
|
|
135
154
|
*/
|
|
136
|
-
export function measureRenderedBounds(frame, fallback, hostZoom) {
|
|
155
|
+
export function measureRenderedBounds(frame, fallback, hostZoom, minScale = DEFAULT_MIN_READABLE_SCALE) {
|
|
137
156
|
const world = frame.querySelector('.st-diagramSceneFigure-world');
|
|
138
157
|
if (!world)
|
|
139
158
|
return fallback;
|
|
@@ -141,6 +160,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
|
|
|
141
160
|
const zoom = committed > 0 ? committed : hostZoom;
|
|
142
161
|
if (!(zoom > 0))
|
|
143
162
|
return fallback;
|
|
163
|
+
const strokeScale = Math.min(DEFAULT_MIN_READABLE_SCALE, zoom, Number.isFinite(minScale) && minScale > 0 ? minScale : DEFAULT_MIN_READABLE_SCALE);
|
|
144
164
|
const first = world.querySelector('[data-scene-occurrence],[data-scene-label]')?.getBoundingClientRect();
|
|
145
165
|
if (!first || first.width === 0 && first.height === 0)
|
|
146
166
|
return fallback;
|
|
@@ -191,7 +211,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
|
|
|
191
211
|
continue;
|
|
192
212
|
if (stroked) {
|
|
193
213
|
if (style.vectorEffect === 'non-scaling-stroke')
|
|
194
|
-
pad = restingStrokeWidth(element, style) / 2 /
|
|
214
|
+
pad = restingStrokeWidth(element, style) / 2 / strokeScale;
|
|
195
215
|
else {
|
|
196
216
|
const matrix = element.getScreenCTM?.();
|
|
197
217
|
const scale = matrix ? Math.max(Math.hypot(matrix.a, matrix.b), Math.hypot(matrix.c, matrix.d)) : zoom;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentropic/design-system-svelte",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
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.16.
|
|
69
|
-
"@sentropic/diagram-canvas": "0.4.
|
|
68
|
+
"@sentropic/design-system-themes": "0.16.1",
|
|
69
|
+
"@sentropic/diagram-canvas": "0.4.1",
|
|
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.16.
|
|
101
|
+
"@sentropic/design-system-themes": "0.16.1",
|
|
102
102
|
"@sveltejs/package": "^2.5.0",
|
|
103
103
|
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
104
104
|
"@testing-library/svelte": "^5.2.8",
|