@principal-ai/subsystems-react 0.56.31 → 0.56.33

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.
Files changed (59) hide show
  1. package/dist/graphify/anchor.d.ts +1 -44
  2. package/dist/graphify/anchor.d.ts.map +1 -1
  3. package/dist/graphify/anchor.js +1 -172
  4. package/dist/graphify/anchor.js.map +1 -1
  5. package/dist/graphify/consolidated.d.ts +1 -258
  6. package/dist/graphify/consolidated.d.ts.map +1 -1
  7. package/dist/graphify/consolidated.js +1 -10
  8. package/dist/graphify/consolidated.js.map +1 -1
  9. package/dist/graphify/construct.d.ts +1 -40
  10. package/dist/graphify/construct.d.ts.map +1 -1
  11. package/dist/graphify/construct.js +1 -99
  12. package/dist/graphify/construct.js.map +1 -1
  13. package/dist/graphify/ids.d.ts +1 -18
  14. package/dist/graphify/ids.d.ts.map +1 -1
  15. package/dist/graphify/ids.js +1 -45
  16. package/dist/graphify/ids.js.map +1 -1
  17. package/dist/graphify/resolve.d.ts +1 -47
  18. package/dist/graphify/resolve.d.ts.map +1 -1
  19. package/dist/graphify/resolve.js +1 -82
  20. package/dist/graphify/resolve.js.map +1 -1
  21. package/dist/graphify/signature.d.ts +1 -86
  22. package/dist/graphify/signature.d.ts.map +1 -1
  23. package/dist/graphify/signature.js +1 -275
  24. package/dist/graphify/signature.js.map +1 -1
  25. package/dist/graphify/types.d.ts +1 -140
  26. package/dist/graphify/types.d.ts.map +1 -1
  27. package/dist/graphify/types.js +1 -7
  28. package/dist/graphify/types.js.map +1 -1
  29. package/dist/subsystem/IssueList.d.ts.map +1 -1
  30. package/dist/subsystem/IssueList.js +5 -2
  31. package/dist/subsystem/IssueList.js.map +1 -1
  32. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  33. package/dist/subsystem/SubsystemComponentGraph.js +33 -19
  34. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  35. package/dist/subsystem/containerCard.d.ts +6 -0
  36. package/dist/subsystem/containerCard.d.ts.map +1 -1
  37. package/dist/subsystem/containerCard.js +16 -1
  38. package/dist/subsystem/containerCard.js.map +1 -1
  39. package/dist/utils/elkLayout.d.ts +22 -0
  40. package/dist/utils/elkLayout.d.ts.map +1 -1
  41. package/dist/utils/elkLayout.js +55 -0
  42. package/dist/utils/elkLayout.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/graphify/anchor.ts +1 -206
  45. package/src/graphify/consolidated.ts +1 -298
  46. package/src/graphify/construct.ts +1 -153
  47. package/src/graphify/ids.ts +1 -48
  48. package/src/graphify/resolve.ts +1 -115
  49. package/src/graphify/signature.ts +1 -354
  50. package/src/graphify/types.ts +1 -164
  51. package/src/stories/Canvases/Subsystem/FocusReset.stories.tsx +55 -0
  52. package/src/stories/Canvases/Subsystem/fixtures/focus-reset-case.json +479 -0
  53. package/src/subsystem/IssueList.category.test.ts +11 -0
  54. package/src/subsystem/IssueList.tsx +5 -2
  55. package/src/subsystem/SubsystemComponentGraph.tsx +47 -19
  56. package/src/subsystem/containerCard.test.ts +30 -0
  57. package/src/subsystem/containerCard.tsx +34 -1
  58. package/src/utils/elkLayout.test.ts +33 -0
  59. package/src/utils/elkLayout.ts +75 -0
@@ -9,6 +9,7 @@
9
9
  * known quantity for the layout that has to reserve room for it.
10
10
  */
11
11
 
12
+ import { Fragment } from 'react';
12
13
  import { useTheme } from '@principal-ade/industry-theme';
13
14
  import type { LucideIcon } from 'lucide-react';
14
15
  import { TechMark } from './techIcons';
@@ -110,6 +111,29 @@ export const OPEN_FOOTER_PAD = TOGGLE_INSET + TOGGLE_SIZE + 8;
110
111
  */
111
112
  export const OPEN_SIDE_PAD = OPEN_FOOTER_PAD;
112
113
 
114
+ /** Split path-like labels at `/`, keeping each segment (and its slash) together. */
115
+ export function containerLabelChunks(label: string): Array<{
116
+ text: string;
117
+ pathSegment: boolean;
118
+ breakAfter: boolean;
119
+ }> {
120
+ return label.split(/(\s+)/).flatMap((part): Array<{
121
+ text: string;
122
+ pathSegment: boolean;
123
+ breakAfter: boolean;
124
+ }> => {
125
+ if (!part.includes('/') || /^\s+$/.test(part)) {
126
+ return [{ text: part, pathSegment: false, breakAfter: false }];
127
+ }
128
+ const segments = part.split('/');
129
+ return segments.map((segment, index) => ({
130
+ text: `${segment}${index < segments.length - 1 ? '/' : ''}`,
131
+ pathSegment: true,
132
+ breakAfter: index < segments.length - 1,
133
+ }));
134
+ });
135
+ }
136
+
113
137
  export interface ContainerCardHeaderProps {
114
138
  label: string;
115
139
  /** The kind glyph beside the label — a container's sort, a package's mark. */
@@ -194,7 +218,16 @@ export function ContainerCardHeader({
194
218
  minWidth: 0,
195
219
  }}
196
220
  >
197
- {label}
221
+ {containerLabelChunks(label).map((chunk, index) => (
222
+ <Fragment key={index}>
223
+ {chunk.pathSegment ? (
224
+ <span style={{ whiteSpace: 'nowrap' }}>{chunk.text}</span>
225
+ ) : (
226
+ chunk.text
227
+ )}
228
+ {chunk.breakAfter && <wbr />}
229
+ </Fragment>
230
+ ))}
198
231
  </span>
199
232
  {Icon && (
200
233
  <span
@@ -14,6 +14,7 @@ import {
14
14
  calculatePathMidpoint,
15
15
  pointAlongPath,
16
16
  fractionAlongPath,
17
+ graphGeometryBounds,
17
18
  planCompoundGroups,
18
19
  getElkOptions,
19
20
  absoluteBoundsOf,
@@ -103,6 +104,38 @@ describe('absolute coordinate space', () => {
103
104
  });
104
105
  });
105
106
 
107
+ describe('graph camera bounds', () => {
108
+ test('includes routed edge points and label boxes beyond the node bounds', () => {
109
+ const nodes = [
110
+ { x: 0, y: 0, width: 100, height: 60 },
111
+ { x: 300, y: 0, width: 100, height: 60 },
112
+ ];
113
+ const bounds = graphGeometryBounds(nodes, [{
114
+ labelCenter: { x: 180, y: 150 },
115
+ points: [
116
+ { x: 100, y: 30 },
117
+ { x: 180, y: 30 },
118
+ { x: 180, y: 150 },
119
+ { x: 300, y: 30 },
120
+ ],
121
+ }], { width: 140, height: 40 });
122
+
123
+ expect(bounds).toEqual({
124
+ x: 0,
125
+ y: 0,
126
+ width: 400,
127
+ height: 170,
128
+ });
129
+ });
130
+
131
+ test('returns undefined when there is no finite graph geometry', () => {
132
+ expect(graphGeometryBounds([], [{ points: [{ x: Number.NaN, y: 1 }] }], {
133
+ width: 140,
134
+ height: 40,
135
+ })).toBeUndefined();
136
+ });
137
+ });
138
+
106
139
  /**
107
140
  * A card's FLIP offset is the difference between where it was and where the new
108
141
  * layout puts it. If this is computed in the wrong space the card slides to a
@@ -254,6 +254,81 @@ export interface Point {
254
254
  y: number;
255
255
  }
256
256
 
257
+ export interface LayoutRect {
258
+ x: number;
259
+ y: number;
260
+ width: number;
261
+ height: number;
262
+ }
263
+
264
+ export interface EdgeBoundsGeometry {
265
+ points?: readonly Point[];
266
+ /** Center of the edge's overlay label, in absolute flow coordinates. */
267
+ labelCenter?: Point;
268
+ }
269
+
270
+ /**
271
+ * Bounds the visible graph geometry in ELK's absolute flow coordinate space.
272
+ * React Flow's `fitView` frames nodes only; routed edges and their overlay labels
273
+ * can extend beyond those rectangles. Callers can include label boxes as rects.
274
+ */
275
+ export function boundsOfRectsAndPoints(
276
+ rects: Iterable<LayoutRect>,
277
+ points: Iterable<Point>,
278
+ ): LayoutRect | undefined {
279
+ let minX = Infinity;
280
+ let minY = Infinity;
281
+ let maxX = -Infinity;
282
+ let maxY = -Infinity;
283
+
284
+ for (const rect of rects) {
285
+ const right = rect.x + rect.width;
286
+ const bottom = rect.y + rect.height;
287
+ if (![rect.x, rect.y, right, bottom].every(Number.isFinite)) continue;
288
+ minX = Math.min(minX, rect.x);
289
+ minY = Math.min(minY, rect.y);
290
+ maxX = Math.max(maxX, right);
291
+ maxY = Math.max(maxY, bottom);
292
+ }
293
+ for (const point of points) {
294
+ if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) continue;
295
+ minX = Math.min(minX, point.x);
296
+ minY = Math.min(minY, point.y);
297
+ maxX = Math.max(maxX, point.x);
298
+ maxY = Math.max(maxY, point.y);
299
+ }
300
+
301
+ if (!Number.isFinite(minX) || !Number.isFinite(minY)) return undefined;
302
+ return {
303
+ x: minX,
304
+ y: minY,
305
+ width: Math.max(1, maxX - minX),
306
+ height: Math.max(1, maxY - minY),
307
+ };
308
+ }
309
+
310
+ /** Bounds node rectangles together with routed edge paths and centered labels. */
311
+ export function graphGeometryBounds(
312
+ nodeRects: Iterable<LayoutRect>,
313
+ edges: Iterable<EdgeBoundsGeometry>,
314
+ labelSize: { width: number; height: number },
315
+ ): LayoutRect | undefined {
316
+ const rects = [...nodeRects];
317
+ const points: Point[] = [];
318
+ for (const edge of edges) {
319
+ if (edge.points) points.push(...edge.points);
320
+ if (edge.labelCenter) {
321
+ rects.push({
322
+ x: edge.labelCenter.x - labelSize.width / 2,
323
+ y: edge.labelCenter.y - labelSize.height / 2,
324
+ width: labelSize.width,
325
+ height: labelSize.height,
326
+ });
327
+ }
328
+ }
329
+ return boundsOfRectsAndPoints(rects, points);
330
+ }
331
+
257
332
  /** ELK edge section with bend points */
258
333
  interface ElkEdgeSection {
259
334
  id: string;