@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.
@@ -1,7 +1,7 @@
1
1
  import { type LayoutHints, type LayoutMetrics, type LayoutOptions, type LayoutResult, type LineMeasurer, type RowPackOptions } from "@sentropic/diagram-canvas";
2
2
  import { type StepChange, type EffectiveTarget } from "@sentropic/diagram-canvas/flowModel";
3
3
  import { type CardLineMeasure, type DiagramGlyphPaths } from "./diagramCardModel.js";
4
- import { type DiagramSceneSize, type SceneLayoutCache, type SceneDocument, type SceneOccurrenceRef, type ScenePresentation, type SceneView } from "@sentropic/diagram-canvas/diagramSceneModel";
4
+ import { type DiagramSceneSize, type SceneLayoutCache, type LinkLegendAnchor, type SceneDocument, type SceneOccurrenceRef, type ScenePresentation, type SceneView } from "@sentropic/diagram-canvas/diagramSceneModel";
5
5
  /**
6
6
  * `DiagramSceneFigure` — the generic scene host (DC-2a lot L4,
7
7
  * SPEC_EVOL_DC2A §4.3, §5, §6.7 and Appendix D; CARDS §7.6).
@@ -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. */
@@ -59,6 +63,8 @@ export interface DiagramSceneFigureLabels {
59
63
  collapse: (title: string) => string;
60
64
  /** Localized fallback label for containment relations without an explicit edge label (DE-1b). */
61
65
  contains?: string;
66
+ /** Heading for the automatic link-style legend strip (DE-2). */
67
+ legend?: string;
62
68
  }
63
69
  export interface DiagramSceneCamera {
64
70
  readonly zoom: number;
@@ -106,11 +112,17 @@ export interface DiagramSceneFigureProps {
106
112
  /** Accessible name of the figure. Defaults to `title`. */
107
113
  label?: string;
108
114
  compact?: boolean;
115
+ /** 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`. */
116
+ fitToWindow?: boolean;
109
117
  labels?: Partial<DiagramSceneFigureLabels>;
110
118
  iconBindings?: import("@sentropic/diagram-canvas/diagramSceneModel").SceneIconBindings;
111
119
  strictIcons?: boolean;
112
120
  /** Selectable start parity for alternating zone depth surfaces (`0` default, `1` flipped). */
113
121
  depthParityStart?: 0 | 1;
122
+ /** Automatic link-style legend anchor (`"right"` default; `"none"` suppresses). */
123
+ legend?: LinkLegendAnchor;
124
+ /** Optional custom labels for automatic link-style legend entries, keyed by `linkStyleKey(...)`. */
125
+ legendLabels?: Readonly<Record<string, string>>;
114
126
  resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
115
127
  onFoldChange?: (collapsed: readonly SceneOccurrenceRef[], change: {
116
128
  occurrence: SceneOccurrenceRef;
@@ -131,6 +143,9 @@ declare const DiagramSceneFigure: import("svelte").Component<DiagramSceneFigureP
131
143
  zoomIn: () => void;
132
144
  zoomOut: () => void;
133
145
  fitToFrame: () => void;
146
+ toggleFullscreen: () => void;
147
+ setViewAll: (enabled: boolean) => void;
148
+ toggleViewAll: () => void;
134
149
  getCamera: () => DiagramSceneCamera;
135
150
  }, "contentSize">;
136
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,EAMH,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASrC,OAAO,EAA+L,KAAK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AAS,CAAC;IAC/D,YAAY,CAAC,EAAE,CACb,SAAS,EAAE,SAAS,kBAAkB,EAAE,EACxC,MAAM,EAAE;QAAE,UAAU,EAAE,kBAAkB,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,KAC3D,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACjD;AAowCH,QAAA,MAAM,kBAAkB;oBA7jBE,MAAM,KAAG,IAAI;kBAyBjB,IAAI;mBAIH,IAAI;sBAKD,IAAI;4BAwFE,IAAI;0BAQJ,OAAO,KAAG,IAAI;yBAkBjB,IAAI;qBAIR,kBAAkB;iBAqaqB,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -13,33 +13,41 @@ export declare const RENDERED_BOUNDS_GRID_STEPS = 64;
13
13
  * - a painted edge is read as `(edge − origin) / zoom`, both 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 (the camera never applies
17
- * a smaller zoom), where that step is at its widest: `1 / (64 × 0.30)`;
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 (see `measureRenderedBounds`): it shifts
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, therefore
25
- * differ by less than `(2 / 0.30 + 1) / 64` ≈ 0.120 world unit. On screen
26
- * that is more than `(1 + zoom) / 64` CSS px at every zoom the camera
27
- * applies: one LayoutUnit step read back through the outward rounding,
28
- * which spans up to `ceil(1 / zoom) / 64` world unit (2/64 at 0.62, 4/64 at
29
- * 0.30). A bare 1/64 CSS px is under that step: it refits on a flip of the
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. From then on a fit is a fixed point: reading the
40
- * same paint again, through any transform, never moves it.
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, the one it has at the
57
- * readability floor (`DEFAULT_MIN_READABLE_SCALE`, under which the camera
58
- * never paints), at every zoom, and at its resting width;
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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,+BAA+B,QAA8C,CAAC;AAE3F;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CASzF;AAuDD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CA8ExH"}
1
+ {"version":3,"file":"diagramRenderedBounds.d.ts","sourceRoot":"","sources":["../src/lib/diagramRenderedBounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;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,40 +14,61 @@ 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 (the camera never applies
18
- * a smaller zoom), where that step is at its widest: `1 / (64 × 0.30)`;
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 (see `measureRenderedBounds`): it shifts
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, therefore
26
- * differ by less than `(2 / 0.30 + 1) / 64` ≈ 0.120 world unit. On screen
27
- * that is more than `(1 + zoom) / 64` CSS px at every zoom the camera
28
- * applies: one LayoutUnit step read back through the outward rounding,
29
- * which spans up to `ceil(1 / zoom) / 64` world unit (2/64 at 0.62, 4/64 at
30
- * 0.30). A bare 1/64 CSS px is under that step: it refits on a flip of the
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. From then on a fit is a fixed point: reading the
41
- * same paint again, through any transform, never moves it.
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 > RENDERED_BOUNDS_REFIT_TOLERANCE;
66
+ return delta > renderedBoundsRefitTolerance(scale);
48
67
  }
49
- /** Token default of a resting connector stroke, CSS px. */
50
- const RESTING_EDGE_STROKE_WIDTH = 1.5;
68
+ /** Token default of a resting numbered-flow stroke, CSS px (DC-2c). */
69
+ const RESTING_FLOW_STROKE_WIDTH = 1.5;
70
+ /** Token default of a resting connector stroke, CSS px (DE-2 `linkStrokeWidth`). */
71
+ const RESTING_EDGE_STROKE_WIDTH = 2.5;
51
72
  /** Whether a computed colour paints nothing: `transparent` or a zero alpha. */
52
73
  function isTransparent(color) {
53
74
  const value = color.trim().toLowerCase();
@@ -60,11 +81,11 @@ function isTransparent(color) {
60
81
  }
61
82
  /**
62
83
  * What the scene hosts fade during a fold transition: the connector layer,
63
- * the edge labels and the entering nodes. A zero opacity on one of these is
64
- * a frame of that fade, not a hidden element: it is painted once the
65
- * transition settles, and the fit has to frame it.
84
+ * the edge labels, the entering nodes and the automatic link legend. A zero
85
+ * opacity on one of these is a frame of that fade, not a hidden element: it
86
+ * is painted once the transition settles, and the fit has to frame it.
66
87
  */
67
- const TRANSITION_FADED = '.st-diagramSceneFigure-edges,.st-diagramSceneFigure-edgeLabel,.st-diagramSceneFigure-node';
88
+ const TRANSITION_FADED = '.st-diagramSceneFigure-edges,.st-diagramSceneFigure-edgeLabel,.st-diagramSceneFigure-node,.st-diagramSceneFigure-legend';
68
89
  /** Whether an element removes itself and its subtree from the paint for
69
90
  * good: not rendered, fully transparent at rest, or clipped to nothing (the
70
91
  * screen-reader-only idioms: `clip-path: inset(50%)`, `clip: rect(0 0 0 0)`,
@@ -96,9 +117,18 @@ function restingStrokeWidth(element, style) {
96
117
  const state = element.getAttribute('data-flow-state');
97
118
  if (state !== 'primary' && state !== 'related')
98
119
  return width;
99
- const token = element.hasAttribute('data-flow-step') ? '--st-component-diagramScene-flowStrokeWidth' : '--st-component-diagramZone-borderWidth';
120
+ const isFlow = element.hasAttribute('data-flow-step');
121
+ const isR7 = element.getAttribute('data-connector-mode') === 'r7';
122
+ const token = isFlow
123
+ ? '--st-component-diagramScene-flowStrokeWidth'
124
+ : element.getAttribute('data-edge-emphasis') === 'emphasis'
125
+ ? '--st-component-diagramScene-linkEmphasisStrokeWidth'
126
+ : isR7
127
+ ? '--st-component-diagramScene-linkStrokeWidth'
128
+ : '--st-component-diagramZone-borderWidth';
100
129
  const resting = parseFloat(style.getPropertyValue(token));
101
- return Number.isFinite(resting) ? resting : Math.min(width, RESTING_EDGE_STROKE_WIDTH);
130
+ const fallbackWidth = isFlow || !isR7 ? RESTING_FLOW_STROKE_WIDTH : RESTING_EDGE_STROKE_WIDTH;
131
+ return Number.isFinite(resting) ? resting : Math.min(width, fallbackWidth);
102
132
  }
103
133
  /**
104
134
  * Painted bounds in world units, after font/layout settling. DOM-free scene
@@ -113,16 +143,16 @@ function restingStrokeWidth(element, style) {
113
143
  *
114
144
  * - a stroke that scales with the world has a constant world width;
115
145
  * - a `non-scaling-stroke` has a constant screen width, so its world width
116
- * is `width / zoom`. It is framed at its widest, the one it has at the
117
- * readability floor (`DEFAULT_MIN_READABLE_SCALE`, under which the camera
118
- * never paints), at every zoom, and at its resting width;
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;
119
149
  * - geometry that paints nothing is left out: flow hit targets
120
150
  * (`[data-flow-hit]`, a transparent 16 px stroke), flow focus targets
121
151
  * (`[data-flow-node]`, hidden at rest and sized in screen px), transparent
122
152
  * strokes and text, shapes with neither stroke nor fill, and hidden or
123
153
  * clipped subtrees. What a fold transition is fading in stays in.
124
154
  */
125
- export function measureRenderedBounds(frame, fallback, hostZoom) {
155
+ export function measureRenderedBounds(frame, fallback, hostZoom, minScale = DEFAULT_MIN_READABLE_SCALE) {
126
156
  const world = frame.querySelector('.st-diagramSceneFigure-world');
127
157
  if (!world)
128
158
  return fallback;
@@ -130,6 +160,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
130
160
  const zoom = committed > 0 ? committed : hostZoom;
131
161
  if (!(zoom > 0))
132
162
  return fallback;
163
+ const strokeScale = Math.min(DEFAULT_MIN_READABLE_SCALE, zoom, Number.isFinite(minScale) && minScale > 0 ? minScale : DEFAULT_MIN_READABLE_SCALE);
133
164
  const first = world.querySelector('[data-scene-occurrence],[data-scene-label]')?.getBoundingClientRect();
134
165
  if (!first || first.width === 0 && first.height === 0)
135
166
  return fallback;
@@ -169,7 +200,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
169
200
  // computed value of the painting element itself counts.
170
201
  const paints = (element) => !element.closest('defs,[hidden],[data-flow-hit],[data-flow-node]')
171
202
  && styleOf(element).visibility !== 'hidden' && styleOf(element).visibility !== 'collapse' && inPaintedSubtree(element);
172
- for (const element of world.querySelectorAll('[data-scene-occurrence],.st-diagramCard,.st-diagramZone,[data-scene-label],[data-diagram-icon],.st-badge,[data-badge],.st-diagramCard-rule,.st-diagramZone-rule,.st-diagramZone-footerRule,button,svg polyline,svg path,svg line,svg rect,svg circle,svg text')) {
203
+ for (const element of world.querySelectorAll('[data-scene-occurrence],.st-diagramCard,.st-diagramZone,[data-scene-label],[data-scene-legend],[data-diagram-icon],.st-badge,[data-badge],.st-diagramCard-rule,.st-diagramZone-rule,.st-diagramZone-footerRule,button,svg polyline,svg path,svg line,svg rect,svg circle,svg text')) {
173
204
  if (!paints(element))
174
205
  continue;
175
206
  const style = styleOf(element);
@@ -180,7 +211,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
180
211
  continue;
181
212
  if (stroked) {
182
213
  if (style.vectorEffect === 'non-scaling-stroke')
183
- pad = restingStrokeWidth(element, style) / 2 / DEFAULT_MIN_READABLE_SCALE;
214
+ pad = restingStrokeWidth(element, style) / 2 / strokeScale;
184
215
  else {
185
216
  const matrix = element.getScreenCTM?.();
186
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.43.2",
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.15.2",
69
- "@sentropic/diagram-canvas": "0.3.2",
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.15.2",
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",