@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.
- package/dist/graphify/anchor.d.ts +1 -44
- package/dist/graphify/anchor.d.ts.map +1 -1
- package/dist/graphify/anchor.js +1 -172
- package/dist/graphify/anchor.js.map +1 -1
- package/dist/graphify/consolidated.d.ts +1 -258
- package/dist/graphify/consolidated.d.ts.map +1 -1
- package/dist/graphify/consolidated.js +1 -10
- package/dist/graphify/consolidated.js.map +1 -1
- package/dist/graphify/construct.d.ts +1 -40
- package/dist/graphify/construct.d.ts.map +1 -1
- package/dist/graphify/construct.js +1 -99
- package/dist/graphify/construct.js.map +1 -1
- package/dist/graphify/ids.d.ts +1 -18
- package/dist/graphify/ids.d.ts.map +1 -1
- package/dist/graphify/ids.js +1 -45
- package/dist/graphify/ids.js.map +1 -1
- package/dist/graphify/resolve.d.ts +1 -47
- package/dist/graphify/resolve.d.ts.map +1 -1
- package/dist/graphify/resolve.js +1 -82
- package/dist/graphify/resolve.js.map +1 -1
- package/dist/graphify/signature.d.ts +1 -86
- package/dist/graphify/signature.d.ts.map +1 -1
- package/dist/graphify/signature.js +1 -275
- package/dist/graphify/signature.js.map +1 -1
- package/dist/graphify/types.d.ts +1 -140
- package/dist/graphify/types.d.ts.map +1 -1
- package/dist/graphify/types.js +1 -7
- package/dist/graphify/types.js.map +1 -1
- package/dist/subsystem/IssueList.d.ts.map +1 -1
- package/dist/subsystem/IssueList.js +5 -2
- package/dist/subsystem/IssueList.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +33 -19
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +6 -0
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +16 -1
- package/dist/subsystem/containerCard.js.map +1 -1
- package/dist/utils/elkLayout.d.ts +22 -0
- package/dist/utils/elkLayout.d.ts.map +1 -1
- package/dist/utils/elkLayout.js +55 -0
- package/dist/utils/elkLayout.js.map +1 -1
- package/package.json +3 -3
- package/src/graphify/anchor.ts +1 -206
- package/src/graphify/consolidated.ts +1 -298
- package/src/graphify/construct.ts +1 -153
- package/src/graphify/ids.ts +1 -48
- package/src/graphify/resolve.ts +1 -115
- package/src/graphify/signature.ts +1 -354
- package/src/graphify/types.ts +1 -164
- package/src/stories/Canvases/Subsystem/FocusReset.stories.tsx +55 -0
- package/src/stories/Canvases/Subsystem/fixtures/focus-reset-case.json +479 -0
- package/src/subsystem/IssueList.category.test.ts +11 -0
- package/src/subsystem/IssueList.tsx +5 -2
- package/src/subsystem/SubsystemComponentGraph.tsx +47 -19
- package/src/subsystem/containerCard.test.ts +30 -0
- package/src/subsystem/containerCard.tsx +34 -1
- package/src/utils/elkLayout.test.ts +33 -0
- 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
|
package/src/utils/elkLayout.ts
CHANGED
|
@@ -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;
|