@principal-ai/subsystems-react 0.53.0 → 0.53.2

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 (34) hide show
  1. package/dist/subsystem/C4Graph.d.ts +91 -1
  2. package/dist/subsystem/C4Graph.d.ts.map +1 -1
  3. package/dist/subsystem/C4Graph.js +672 -180
  4. package/dist/subsystem/C4Graph.js.map +1 -1
  5. package/dist/subsystem/C4NodeCard.d.ts +36 -1
  6. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  7. package/dist/subsystem/C4NodeCard.js +45 -10
  8. package/dist/subsystem/C4NodeCard.js.map +1 -1
  9. package/dist/subsystem/IssueList.d.ts.map +1 -1
  10. package/dist/subsystem/IssueList.js +14 -5
  11. package/dist/subsystem/IssueList.js.map +1 -1
  12. package/dist/subsystem/c4.d.ts +27 -3
  13. package/dist/subsystem/c4.d.ts.map +1 -1
  14. package/dist/subsystem/c4.js +48 -0
  15. package/dist/subsystem/c4.js.map +1 -1
  16. package/dist/utils/elkLayout.d.ts +68 -8
  17. package/dist/utils/elkLayout.d.ts.map +1 -1
  18. package/dist/utils/elkLayout.js +95 -14
  19. package/dist/utils/elkLayout.js.map +1 -1
  20. package/package.json +2 -1
  21. package/src/stories/Subsystem/C4Graph/C4CardGrow.stories.tsx +125 -0
  22. package/src/stories/Subsystem/C4Graph/C4Component.stories.tsx +21 -11
  23. package/src/stories/Subsystem/C4Graph/C4Container.stories.tsx +1 -9
  24. package/src/stories/Subsystem/C4Graph/C4Transition.stories.tsx +132 -0
  25. package/src/subsystem/C4Graph.groups.test.ts +217 -0
  26. package/src/subsystem/C4Graph.morph.test.tsx +208 -0
  27. package/src/subsystem/C4Graph.tsx +803 -226
  28. package/src/subsystem/C4NodeCard.test.ts +6 -3
  29. package/src/subsystem/C4NodeCard.tsx +92 -20
  30. package/src/subsystem/IssueList.category.test.ts +39 -0
  31. package/src/subsystem/IssueList.tsx +16 -5
  32. package/src/subsystem/c4.ts +74 -3
  33. package/src/utils/elkLayout.test.ts +131 -0
  34. package/src/utils/elkLayout.ts +133 -16
@@ -11,11 +11,20 @@
11
11
  * drawers, no trail playback.
12
12
  */
13
13
  /// <reference types="react" />
14
+ import type { CompoundGroupDef, ElkLayoutResult } from '../utils/elkLayout';
15
+ import { type C4Group } from './c4';
14
16
  import type { C4Model } from './c4';
15
17
  export interface C4GraphProps {
16
18
  model: C4Model;
17
- title?: string;
18
19
  onSelectNode?: (id: string | null) => void;
20
+ /**
21
+ * Drill-down. Called from the expand affordance on a container card; the host
22
+ * sets `openContainerId` on the model to swap the box for a frame with its
23
+ * components inside.
24
+ */
25
+ onOpenContainer?: (id: string) => void;
26
+ /** Called from the collapse affordance inside an opened container frame. */
27
+ onCloseContainer?: () => void;
19
28
  /**
20
29
  * Breathing room around each card, in flow px, applied as ELK spacing (not by
21
30
  * inflating the node box — that left the edge lines starting short of the
@@ -24,5 +33,86 @@ export interface C4GraphProps {
24
33
  */
25
34
  gutter?: number;
26
35
  }
36
+ /** Flow-space rect of a box node or a frame, for the drill-down morph. */
37
+ interface FlowRect {
38
+ x: number;
39
+ y: number;
40
+ width: number;
41
+ height: number;
42
+ }
43
+ /** A frame's growth for the drill-down morph: its flow rect before → after. */
44
+ interface FrameGrow {
45
+ from: FlowRect;
46
+ to: FlowRect;
47
+ }
48
+ /**
49
+ * Whether committing a layout should also move the camera.
50
+ *
51
+ * A morph — a commit that has rects to FLIP from — must not. Every element
52
+ * already on screen is sliding from the rect the reader last saw it at, and that
53
+ * anchoring *is* the morph; a viewport move on top of it makes each card's
54
+ * on-screen path the sum of two independent animations, so nothing lands where
55
+ * the FLIP said it would. `CAMERA_MS` also outlasts `MORPH_MS`, so the camera
56
+ * would still be drifting for 100ms after the cards had settled — which is what
57
+ * reads as the cards "still moving".
58
+ *
59
+ * A commit with no `grows` is a genuine change: the first paint, a new system, a
60
+ * different element set, or the grid fallback after an ELK failure. There is no
61
+ * continuity to preserve there and the content may genuinely not be on screen, so
62
+ * fit.
63
+ *
64
+ * An *empty* map fits for the same reason — no element is anchoring, so there is
65
+ * nothing a camera move could contradict. Testing the size rather than the
66
+ * identity keeps that total over the whole input domain instead of leaning on a
67
+ * caller convention (`growsFor` happens to hand back `null` rather than an empty
68
+ * map, but nothing forces it to).
69
+ *
70
+ * @param grows the rects to animate from, exactly as `injectGrow` received them.
71
+ */
72
+ export declare function shouldRefitCamera(grows: Map<string, FrameGrow> | null): boolean;
73
+ /**
74
+ * Whether a card shows its description line.
75
+ *
76
+ * Off for the whole morph: the card is resizing under it, so the line would slide
77
+ * across a moving box.
78
+ *
79
+ * And off for good once the container is grown, which is the half that is easy to
80
+ * get wrong. `settled` alone is not enough — the line comes back the moment the
81
+ * grow finishes, straight into the space the components now occupy. ELK reserves
82
+ * header chrome only (`padTop`), never a description, so the returning line does
83
+ * not push the internals down; it lands on top of the first component.
84
+ */
85
+ export declare function showDescriptionFor(open: boolean | undefined, settled: boolean | undefined): boolean;
86
+ /**
87
+ * `groupBounds` with every entry in absolute flow coordinates.
88
+ *
89
+ * `result.groupBounds` is absolute for a root-level group and *parent-relative*
90
+ * for a nested one — two spaces in one map, which is the same trap as
91
+ * `result.nodes`. The opened container is nested (inside the system frame), and
92
+ * `containerRect` reads this map before the node box, so an unrebased entry would
93
+ * be handed to the morph offset by the frame's origin: the container would glide
94
+ * to a place it was never drawn.
95
+ */
96
+ export declare function rebaseGroupBoundsAbsolute(result: Pick<ElkLayoutResult, 'absoluteRects' | 'groupBounds'>): Map<string, {
97
+ x: number;
98
+ y: number;
99
+ width: number;
100
+ height: number;
101
+ }>;
102
+ /**
103
+ * The compound groups one open state hands to ELK: the frames it draws, and the
104
+ * group defs that make ELK lay them out.
105
+ *
106
+ * Exported because the nesting here is the load-bearing part and it is invisible
107
+ * from the rendered output. The opened container sits *inside* the system frame, so
108
+ * the frame is the origin its contents are laid out from — as a sibling, or as a
109
+ * flat union, the frame has no stable corner and the whole boundary slides as
110
+ * ELK re-places its members.
111
+ */
112
+ export declare function c4GroupDefs(model: C4Model, openId: string | null): {
113
+ frames: C4Group[];
114
+ groups: CompoundGroupDef[];
115
+ };
27
116
  export declare function C4Graph(props: C4GraphProps): import("react").JSX.Element;
117
+ export {};
28
118
  //# sourceMappingURL=C4Graph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"C4Graph.d.ts","sourceRoot":"","sources":["../../src/subsystem/C4Graph.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;AAuBH,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA4tBD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAM1C"}
1
+ {"version":3,"file":"C4Graph.d.ts","sourceRoot":"","sources":["../../src/subsystem/C4Graph.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;AAmBH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE5E,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAKnE,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3C;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B;;;;;OAKG;IACH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