@principal-ai/subsystems-react 0.56.24 → 0.56.26

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 (133) hide show
  1. package/dist/index.d.ts +7 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts +4 -0
  6. package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts.map +1 -0
  7. package/dist/stories/Canvases/Subsystem/issuesFixtures.js +189 -0
  8. package/dist/stories/Canvases/Subsystem/issuesFixtures.js.map +1 -0
  9. package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts +8 -0
  10. package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts.map +1 -0
  11. package/dist/stories/Canvases/Subsystem/reorderFixtures.js +103 -0
  12. package/dist/stories/Canvases/Subsystem/reorderFixtures.js.map +1 -0
  13. package/dist/subsystem/C4ContainersPanel.d.ts +35 -0
  14. package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -0
  15. package/dist/subsystem/C4ContainersPanel.js +165 -0
  16. package/dist/subsystem/C4ContainersPanel.js.map +1 -0
  17. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  18. package/dist/subsystem/C4NodeCard.js +10 -4
  19. package/dist/subsystem/C4NodeCard.js.map +1 -1
  20. package/dist/subsystem/C4ProjectionView.d.ts +12 -2
  21. package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
  22. package/dist/subsystem/C4ProjectionView.js +100 -33
  23. package/dist/subsystem/C4ProjectionView.js.map +1 -1
  24. package/dist/subsystem/C4SketchView.d.ts.map +1 -1
  25. package/dist/subsystem/C4SketchView.js +53 -34
  26. package/dist/subsystem/C4SketchView.js.map +1 -1
  27. package/dist/subsystem/ConstructsCatalog.d.ts +18 -11
  28. package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
  29. package/dist/subsystem/ConstructsCatalog.js +25 -27
  30. package/dist/subsystem/ConstructsCatalog.js.map +1 -1
  31. package/dist/subsystem/DescriptionOverlay.d.ts +10 -2
  32. package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -1
  33. package/dist/subsystem/DescriptionOverlay.js +4 -4
  34. package/dist/subsystem/DescriptionOverlay.js.map +1 -1
  35. package/dist/subsystem/DescriptionPreview.d.ts +31 -0
  36. package/dist/subsystem/DescriptionPreview.d.ts.map +1 -0
  37. package/dist/subsystem/DescriptionPreview.js +31 -0
  38. package/dist/subsystem/DescriptionPreview.js.map +1 -0
  39. package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -3
  40. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  41. package/dist/subsystem/SubsystemComponentGraph.js +18 -23
  42. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  43. package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -1
  44. package/dist/subsystem/__fixtures__/c4Sketch.js +1 -0
  45. package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -1
  46. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +29 -0
  47. package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -0
  48. package/dist/subsystem/__fixtures__/c4SketchGallery.js +320 -0
  49. package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -0
  50. package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
  51. package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
  52. package/dist/subsystem/c4Sketch.d.ts +12 -0
  53. package/dist/subsystem/c4Sketch.d.ts.map +1 -1
  54. package/dist/subsystem/c4Sketch.js +2 -1
  55. package/dist/subsystem/c4Sketch.js.map +1 -1
  56. package/dist/subsystem/containerCard.d.ts +3 -1
  57. package/dist/subsystem/containerCard.d.ts.map +1 -1
  58. package/dist/subsystem/containerCard.js +2 -2
  59. package/dist/subsystem/containerCard.js.map +1 -1
  60. package/dist/subsystem/techIcons/index.d.ts +3 -1
  61. package/dist/subsystem/techIcons/index.d.ts.map +1 -1
  62. package/dist/subsystem/techIcons/index.js +2 -2
  63. package/dist/subsystem/techIcons/index.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/index.ts +10 -0
  66. package/src/stories/Canvases/C4/C4CardGrow.stories.tsx +1 -1
  67. package/src/stories/Canvases/C4/C4Component.stories.tsx +1 -1
  68. package/src/stories/Canvases/C4/C4Container.stories.tsx +1 -1
  69. package/src/stories/Canvases/C4/C4Draft.stories.tsx +1 -1
  70. package/src/stories/Canvases/C4/C4NodeGallery.stories.tsx +1 -1
  71. package/src/stories/Canvases/C4/C4Sketch.stories.tsx +62 -4
  72. package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +1 -1
  73. package/src/stories/Canvases/C4/C4Transition.stories.tsx +1 -1
  74. package/src/stories/Canvases/Subsystem/AnimatedProgression.stories.tsx +1 -1
  75. package/src/stories/Canvases/Subsystem/Appearance.stories.tsx +1 -1
  76. package/src/stories/Canvases/Subsystem/Basics.stories.tsx +1 -1
  77. package/src/stories/Canvases/Subsystem/Captures.stories.tsx +1 -1
  78. package/src/stories/Canvases/Subsystem/Constructs.stories.tsx +3 -7
  79. package/src/stories/Canvases/Subsystem/ConstructsEmbed.stories.tsx +27 -0
  80. package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +7 -4
  81. package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +3 -2
  82. package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +2 -100
  83. package/src/stories/Canvases/Subsystem/DeprecatedGraph.stories.tsx +124 -0
  84. package/src/stories/Canvases/Subsystem/DetailPanel.stories.tsx +1 -1
  85. package/src/stories/Canvases/Subsystem/Diagnostics.stories.tsx +1 -43
  86. package/src/stories/Canvases/Subsystem/DiagnosticsStates.stories.tsx +63 -0
  87. package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +3 -2
  88. package/src/stories/Canvases/Subsystem/FrameworkStereotype.stories.tsx +1 -1
  89. package/src/stories/Canvases/Subsystem/GraphTitle.stories.tsx +1 -19
  90. package/src/stories/Canvases/Subsystem/GraphTitleGraph.stories.tsx +51 -0
  91. package/src/stories/Canvases/Subsystem/Issues.stories.tsx +5 -229
  92. package/src/stories/Canvases/Subsystem/IssuesList.stories.tsx +60 -0
  93. package/src/stories/Canvases/Subsystem/LayoutDirection.stories.tsx +1 -1
  94. package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +6 -63
  95. package/src/stories/Canvases/Subsystem/ModuleBadgesNode.stories.tsx +81 -0
  96. package/src/stories/Canvases/Subsystem/ModulePathNesting.stories.tsx +1 -1
  97. package/src/stories/Canvases/Subsystem/Modules.stories.tsx +1 -1
  98. package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +1 -1
  99. package/src/stories/Canvases/Subsystem/Packages.stories.tsx +1 -1
  100. package/src/stories/Canvases/Subsystem/Presentation.stories.tsx +1 -1
  101. package/src/stories/Canvases/Subsystem/Processes.stories.tsx +3 -2
  102. package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +5 -154
  103. package/src/stories/Canvases/Subsystem/ReorderPanel.stories.tsx +75 -0
  104. package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +7 -4
  105. package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
  106. package/src/stories/Canvases/Subsystem/StepEmphasis.stories.tsx +1 -1
  107. package/src/stories/Canvases/Subsystem/StoreValueType.stories.tsx +1 -1
  108. package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +3 -2
  109. package/src/stories/Canvases/Subsystem/TrailSidebarViews.stories.tsx +1 -1
  110. package/src/stories/Canvases/Subsystem/Trails.stories.tsx +5 -3
  111. package/src/stories/Canvases/Subsystem/WorkspacePackageFrames.stories.tsx +1 -1
  112. package/src/stories/Canvases/Subsystem/issuesFixtures.ts +192 -0
  113. package/src/stories/Canvases/Subsystem/reorderFixtures.tsx +125 -0
  114. package/src/stories/Components/ConstructsCatalog.stories.tsx +2 -1
  115. package/src/subsystem/C4ContainersPanel.test.tsx +151 -0
  116. package/src/subsystem/C4ContainersPanel.tsx +315 -0
  117. package/src/subsystem/C4NodeCard.tsx +12 -4
  118. package/src/subsystem/C4ProjectionView.tsx +151 -53
  119. package/src/subsystem/C4SketchView.tsx +96 -74
  120. package/src/subsystem/ConstructsCatalog.tsx +59 -58
  121. package/src/subsystem/DescriptionOverlay.test.tsx +18 -8
  122. package/src/subsystem/DescriptionOverlay.tsx +20 -5
  123. package/src/subsystem/DescriptionPreview.tsx +96 -0
  124. package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +28 -8
  125. package/src/subsystem/SubsystemComponentGraph.tsx +46 -51
  126. package/src/subsystem/__fixtures__/c4Sketch.ts +2 -0
  127. package/src/subsystem/__fixtures__/c4SketchGallery.test.ts +65 -0
  128. package/src/subsystem/__fixtures__/c4SketchGallery.ts +361 -0
  129. package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
  130. package/src/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
  131. package/src/subsystem/c4Sketch.ts +13 -0
  132. package/src/subsystem/containerCard.tsx +4 -1
  133. package/src/subsystem/techIcons/index.tsx +11 -2
@@ -0,0 +1,315 @@
1
+ /**
2
+ * C4ContainersPanel — sidebar overview of a C4 diagram's containers.
3
+ *
4
+ * The C4 counterpart to the subsystem graph's `ContainersPanel`: one row per
5
+ * container and a bulk open/close header. A row behaves as a dropdown —
6
+ * selecting it toggles the container's internals on the canvas and frames it,
7
+ * with a chevron showing the open state. A container with no components is
8
+ * select-only: it frames the box without a dropdown.
9
+ *
10
+ * The panel is pure chrome — the view owns the open set and the camera focus,
11
+ * exactly as `SubsystemComponentGraph` owns its frame state.
12
+ */
13
+
14
+ import { useTheme } from '@principal-ade/industry-theme';
15
+ import { ChevronRight, Component, Database, AppWindow } from 'lucide-react';
16
+ import { Fragment } from 'react';
17
+ import type { CSSProperties } from 'react';
18
+ import type { C4Component, C4Container } from './c4';
19
+ import { nodeKindIcon, nodeStyle, nodeTechnology } from './C4NodeCard';
20
+ import { TechMark, technologyBrand } from './techIcons';
21
+
22
+ /** One row height for containers and their members, so the dropdown stays tabular. */
23
+ const ROW_HEIGHT = 38;
24
+
25
+ export interface C4ContainerListItem {
26
+ /** Element id — the container the canvas toggles and frames. */
27
+ container: C4Container;
28
+ /** Drawn with its internals laid out. */
29
+ open: boolean;
30
+ /** The authored C4 components inside this container, in model order. */
31
+ members: readonly C4Component[];
32
+ }
33
+
34
+ export interface C4ContainersPanelProps {
35
+ containers: readonly C4ContainerListItem[];
36
+ /** The container last activated from this list. */
37
+ activeId?: string | null;
38
+ /** Toggle a container's internals and frame it. */
39
+ onActivate: (id: string) => void;
40
+ /** Frame a container that has nothing to expand. */
41
+ onSelect: (id: string) => void;
42
+ onOpenAll: () => void;
43
+ onCloseAll: () => void;
44
+ }
45
+
46
+ export function C4ContainersPanel({
47
+ containers,
48
+ activeId,
49
+ onActivate,
50
+ onSelect,
51
+ onOpenAll,
52
+ onCloseAll,
53
+ }: C4ContainersPanelProps) {
54
+ const { theme } = useTheme();
55
+ const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
56
+ const anyOpen = containers.some((c) => c.open);
57
+ const anyClosed = containers.some((c) => !c.open);
58
+ const bulkStyle = (enabled: boolean): CSSProperties => ({
59
+ padding: '2px 8px',
60
+ border: `1px solid ${theme.colors.border}`,
61
+ borderRadius: 4,
62
+ background: 'transparent',
63
+ color: enabled ? theme.colors.textSecondary : muted,
64
+ fontFamily: theme.fonts.monospace,
65
+ fontSize: theme.fontSizes[0],
66
+ cursor: enabled ? 'pointer' : 'default',
67
+ opacity: enabled ? 1 : 0.5,
68
+ });
69
+
70
+ if (containers.length === 0) {
71
+ return (
72
+ <div style={{ padding: 16, color: theme.colors.textSecondary }}>No containers.</div>
73
+ );
74
+ }
75
+
76
+ return (
77
+ <div style={{ display: 'flex', flexDirection: 'column', minHeight: 0 }}>
78
+ <style>{`
79
+ .c4-containers-row {
80
+ background: transparent;
81
+ transition: background 120ms ease;
82
+ }
83
+ .c4-containers-row:hover {
84
+ background: color-mix(in srgb, currentColor 8%, transparent);
85
+ }
86
+ .c4-containers-row[data-active='true'] {
87
+ background: color-mix(in srgb, currentColor 12%, transparent);
88
+ }
89
+ .c4-containers-row[data-active='true']:hover {
90
+ background: color-mix(in srgb, currentColor 16%, transparent);
91
+ }
92
+ `}</style>
93
+ <div
94
+ style={{
95
+ display: 'flex',
96
+ alignItems: 'center',
97
+ gap: 6,
98
+ padding: '8px 12px',
99
+ borderBottom: `1px solid ${theme.colors.border}`,
100
+ flexShrink: 0,
101
+ }}
102
+ >
103
+ <span
104
+ style={{
105
+ flex: 1,
106
+ fontFamily: theme.fonts.monospace,
107
+ fontSize: theme.fontSizes[0],
108
+ color: muted,
109
+ textTransform: 'uppercase',
110
+ letterSpacing: 0.5,
111
+ }}
112
+ >
113
+ {containers.length} {containers.length === 1 ? 'container' : 'containers'}
114
+ </span>
115
+ <button type="button" onClick={onOpenAll} disabled={!anyClosed} style={bulkStyle(anyClosed)}>
116
+ Open all
117
+ </button>
118
+ <button type="button" onClick={onCloseAll} disabled={!anyOpen} style={bulkStyle(anyOpen)}>
119
+ Close all
120
+ </button>
121
+ </div>
122
+ <ul
123
+ role="list"
124
+ aria-label="Containers"
125
+ style={{ listStyle: 'none', margin: 0, padding: '6px 0', overflow: 'auto', minHeight: 0 }}
126
+ >
127
+ {containers.map((item) => {
128
+ const canToggle = item.members.length > 0;
129
+ return (
130
+ <Fragment key={item.container.id}>
131
+ <ContainerRow
132
+ item={item}
133
+ active={item.container.id === activeId}
134
+ canToggle={canToggle}
135
+ onActivate={() =>
136
+ canToggle
137
+ ? onActivate(item.container.id)
138
+ : onSelect(item.container.id)
139
+ }
140
+ />
141
+ {item.open &&
142
+ item.members.map((member) => (
143
+ <ContainerMemberRow key={member.id} component={member} />
144
+ ))}
145
+ </Fragment>
146
+ );
147
+ })}
148
+ </ul>
149
+ </div>
150
+ );
151
+ }
152
+
153
+ function ContainerRow({
154
+ item,
155
+ active,
156
+ canToggle,
157
+ onActivate,
158
+ }: {
159
+ item: C4ContainerListItem;
160
+ active: boolean;
161
+ canToggle: boolean;
162
+ onActivate: () => void;
163
+ }) {
164
+ const { theme } = useTheme();
165
+ const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
166
+ const { container, open } = item;
167
+ const Icon = nodeKindIcon(container) ?? (container.containerKind === 'data-store' ? Database : AppWindow);
168
+ const brand = technologyBrand(nodeTechnology(container) ?? container.containerKind);
169
+ const proposed = container.state === 'proposed';
170
+
171
+ return (
172
+ <li
173
+ className="c4-containers-row"
174
+ data-active={active || undefined}
175
+ style={
176
+ {
177
+ display: 'flex',
178
+ alignItems: 'center',
179
+ gap: 8,
180
+ height: ROW_HEIGHT,
181
+ boxSizing: 'border-box',
182
+ padding: '0 12px',
183
+ } as CSSProperties
184
+ }
185
+ >
186
+ <button
187
+ type="button"
188
+ onClick={onActivate}
189
+ aria-current={active || undefined}
190
+ aria-expanded={canToggle ? open : undefined}
191
+ style={{
192
+ flex: 1,
193
+ minWidth: 0,
194
+ display: 'grid',
195
+ gridTemplateColumns: '18px minmax(0, 1fr) 12px',
196
+ columnGap: 8,
197
+ alignItems: 'center',
198
+ padding: 0,
199
+ border: 'none',
200
+ background: 'transparent',
201
+ color: theme.colors.text,
202
+ textAlign: 'left',
203
+ cursor: 'pointer',
204
+ fontFamily: theme.fonts.body,
205
+ }}
206
+ >
207
+ <span
208
+ style={{
209
+ display: 'flex',
210
+ alignItems: 'center',
211
+ justifyContent: 'center',
212
+ gridColumn: 1,
213
+ gridRow: 1,
214
+ }}
215
+ >
216
+ {brand ? (
217
+ <span aria-hidden style={{ display: 'inline-flex', transform: 'translateY(2px)' }}>
218
+ <TechMark brand={brand} size={16} showTitle={false} />
219
+ </span>
220
+ ) : (
221
+ <Icon size={16} color={theme.colors.textSecondary} aria-hidden />
222
+ )}
223
+ </span>
224
+ <span
225
+ style={{
226
+ gridColumn: 2,
227
+ gridRow: 1,
228
+ display: 'flex',
229
+ alignItems: 'center',
230
+ gap: 6,
231
+ fontSize: theme.fontSizes[2],
232
+ fontWeight: 600,
233
+ lineHeight: 1.35,
234
+ minWidth: 0,
235
+ }}
236
+ >
237
+ <span
238
+ style={{
239
+ overflow: 'hidden',
240
+ textOverflow: 'ellipsis',
241
+ whiteSpace: 'nowrap',
242
+ }}
243
+ >
244
+ {container.label}
245
+ </span>
246
+ {proposed && (
247
+ <span
248
+ style={{
249
+ flexShrink: 0,
250
+ padding: '0 4px',
251
+ borderRadius: 3,
252
+ border: '1px solid #e3b34166',
253
+ color: '#e3b341',
254
+ fontFamily: theme.fonts.monospace,
255
+ fontSize: 9,
256
+ letterSpacing: 0.4,
257
+ textTransform: 'uppercase',
258
+ }}
259
+ >
260
+ proposed
261
+ </span>
262
+ )}
263
+ </span>
264
+ {canToggle && (
265
+ <ChevronRight
266
+ size={12}
267
+ aria-hidden
268
+ style={{
269
+ gridColumn: 3,
270
+ gridRow: 1,
271
+ justifySelf: 'center',
272
+ color: muted,
273
+ transform: open ? 'rotate(90deg)' : undefined,
274
+ transition: 'transform 120ms ease',
275
+ }}
276
+ />
277
+ )}
278
+ </button>
279
+ </li>
280
+ );
281
+ }
282
+
283
+ /** One authored component under an opened container — the dropdown's rows. */
284
+ function ContainerMemberRow({ component }: { component: C4Component }) {
285
+ const { theme } = useTheme();
286
+ const style = nodeStyle(component, theme);
287
+ return (
288
+ <li
289
+ style={{
290
+ display: 'flex',
291
+ alignItems: 'center',
292
+ gap: 7,
293
+ height: ROW_HEIGHT,
294
+ boxSizing: 'border-box',
295
+ padding: '0 12px 0 28px',
296
+ color: theme.colors.textSecondary,
297
+ }}
298
+ >
299
+ <Component size={12} color={style.color} aria-hidden />
300
+ <span
301
+ style={{
302
+ minWidth: 0,
303
+ fontSize: theme.fontSizes[1],
304
+ fontFamily: theme.fonts.body,
305
+ lineHeight: 1.4,
306
+ overflow: 'hidden',
307
+ textOverflow: 'ellipsis',
308
+ whiteSpace: 'nowrap',
309
+ }}
310
+ >
311
+ {component.label}
312
+ </span>
313
+ </li>
314
+ );
315
+ }
@@ -379,6 +379,13 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
379
379
  const shape = nodeShape(node);
380
380
  const Icon = nodeKindIcon(node);
381
381
  const brand = technologyBrand(nodeTechnology(node));
382
+ // An unbranded container's border is the muted theme border — fine for a
383
+ // hairline, too dark for the glyph and the box accent. Keep a selected card's
384
+ // accent, and otherwise give the whole card a legible neutral.
385
+ const accentColor =
386
+ node.kind === 'container' && !brand && !selected
387
+ ? theme.colors.textSecondary
388
+ : style.color;
382
389
  const topLabel = nodeTopLabel(node);
383
390
  const subtitle = nodeSubtitle(node);
384
391
 
@@ -432,7 +439,7 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
432
439
  padding: pillInset ? '10px 30px' : '10px 12px',
433
440
  borderRadius: shape.radius,
434
441
  background: theme.colors.backgroundSecondary ?? theme.colors.background,
435
- border: `${style.width}px ${style.dash} ${style.color}`,
442
+ border: `${style.width}px ${style.dash} ${accentColor}`,
436
443
  boxShadow: '0 1px 4px rgba(0,0,0,0.25)',
437
444
  cursor: onClick ? 'pointer' : 'default',
438
445
  fontFamily: theme.fonts.body,
@@ -442,7 +449,8 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
442
449
  label={node.label}
443
450
  Icon={Icon}
444
451
  iconLabel={node.kind === 'container' ? node.containerKind : node.kind}
445
- color={style.color}
452
+ color={accentColor}
453
+ iconColor={accentColor}
446
454
  topLabel={topLabel}
447
455
  brand={brand}
448
456
  hasTechRow={hasTechRow}
@@ -494,9 +502,9 @@ export function C4NodeCard({ node, selected = false, handles, onClick, component
494
502
  height: TOGGLE_SIZE,
495
503
  padding: 0,
496
504
  borderRadius: 4,
497
- border: `1px solid ${style.color}`,
505
+ border: `1px solid ${accentColor}`,
498
506
  background: theme.colors.backgroundSecondary ?? theme.colors.background,
499
- color: style.color,
507
+ color: accentColor,
500
508
  cursor: 'pointer',
501
509
  lineHeight: 1,
502
510
  }}
@@ -14,9 +14,12 @@
14
14
  import { useCallback, useMemo, useRef, useState } from 'react';
15
15
  import type { CSSProperties, ReactNode } from 'react';
16
16
  import { useTheme } from '@principal-ade/industry-theme';
17
- import { IndustryMarkdownSlide } from 'themed-markdown';
17
+ import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
18
18
  import { C4Graph } from './C4Graph';
19
19
  import type { C4ConstructGraph, C4GraphProps } from './C4Graph';
20
+ import { C4ContainersPanel } from './C4ContainersPanel';
21
+ import { DescriptionOverlay } from './DescriptionOverlay';
22
+ import { DescriptionPreview } from './DescriptionPreview';
20
23
  import { GraphWithSidebar } from './GraphWithSidebar';
21
24
  import { TrailStepsNav } from './TrailStepsNav';
22
25
  import {
@@ -24,7 +27,7 @@ import {
24
27
  deriveTrailPlayerElements,
25
28
  } from './c4TrailFocus';
26
29
  import { deriveGraphEdges, trailStepGraphEdgeId } from './model';
27
- import type { C4Element, C4Model } from './c4';
30
+ import type { C4Component, C4Container, C4Element, C4Model } from './c4';
28
31
  import type { SubsystemComponent, SubsystemTrail } from './model';
29
32
  import type { TrailComponentLabels } from './trailStepDisplay';
30
33
 
@@ -39,8 +42,18 @@ export interface C4ProjectionViewProps {
39
42
  memberships: Readonly<Record<string, readonly string[]>>;
40
43
  /** Sidebar heading. Falls back to the system label. */
41
44
  title?: string;
42
- /** Optional Markdown description under the heading. */
45
+ /**
46
+ * Short description shown under the heading. At most 200 characters;
47
+ * extended detail belongs in `notes`.
48
+ */
43
49
  description?: string;
50
+ /**
51
+ * Extended Markdown notes about the model. When set, the description's
52
+ * `Show more` link opens the full document in an Overview overlay. Omit
53
+ * `description` and the sidebar falls back to a clamped preview of these
54
+ * notes.
55
+ */
56
+ notes?: string;
44
57
  /** Extra controls in the sidebar header (source badge, refresh, …). */
45
58
  headerActions?: ReactNode;
46
59
  /**
@@ -198,6 +211,7 @@ export function C4ProjectionView({
198
211
  memberships,
199
212
  title,
200
213
  description,
214
+ notes,
201
215
  headerActions,
202
216
  openContainerIds,
203
217
  onOpenContainerIdsChange,
@@ -210,6 +224,18 @@ export function C4ProjectionView({
210
224
  style,
211
225
  }: C4ProjectionViewProps) {
212
226
  const { theme } = useTheme();
227
+ const [notesOpen, setNotesOpen] = useState(false);
228
+ const rawDescription = description?.trim();
229
+ // The host caps the authored description; trim defensively for other hosts.
230
+ const shortDescription =
231
+ rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
232
+ ? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
233
+ : rawDescription;
234
+ const extendedNotes = notes?.trim();
235
+ // The short description owns the header; a legacy model with only notes
236
+ // falls back to a clamped preview of them.
237
+ const descriptionPreview = shortDescription || extendedNotes;
238
+ const hasNotes = Boolean(extendedNotes);
213
239
  const [internalOpenIds, setInternalOpenIds] = useState<string[]>(() =>
214
240
  [...(openContainerIds ?? model.openContainerIds ?? [])].sort(),
215
241
  );
@@ -235,6 +261,27 @@ export function C4ProjectionView({
235
261
  } | null>(null);
236
262
  const trailOpenedRef = useRef<Set<string>>(new Set());
237
263
 
264
+ /** Sidebar section: the container overview or the trails. */
265
+ const [sidebarTab, setSidebarTab] = useState<'containers' | 'trails'>('containers');
266
+ /** Container last activated from the sidebar — the camera target. */
267
+ const [containerFocus, setContainerFocus] = useState<{ id: string } | null>(null);
268
+
269
+ const containerItems = useMemo(() => {
270
+ const components = model.nodes.filter(
271
+ (node): node is C4Component => node.kind === 'component',
272
+ );
273
+ return model.nodes
274
+ .filter((node): node is C4Container => node.kind === 'container')
275
+ .map((container) => ({
276
+ container,
277
+ open: resolvedOpenIds.includes(container.id),
278
+ members: components.filter(
279
+ (component) =>
280
+ (component.container ?? component.parentId) === container.id,
281
+ ),
282
+ }));
283
+ }, [model.nodes, resolvedOpenIds]);
284
+
238
285
  const parents = useMemo(() => parentIdsOf(model), [model]);
239
286
  const allElementIds = useMemo(
240
287
  () => model.nodes.map((node) => node.id),
@@ -297,6 +344,7 @@ export function C4ProjectionView({
297
344
  setFocusedTrailId(trailId);
298
345
  setHoveredStep(null);
299
346
  setOpenIds(next);
347
+ setContainerFocus(null);
300
348
  onTrailSelect?.({ trailId });
301
349
  },
302
350
  [containers, onTrailSelect, resolvedOpenIds, setOpenIds],
@@ -315,15 +363,69 @@ export function C4ProjectionView({
315
363
 
316
364
  const toggleContainer = useCallback(
317
365
  (id: string) => {
318
- setOpenIds(
319
- resolvedOpenIds.includes(id)
320
- ? resolvedOpenIds.filter((openId) => openId !== id)
321
- : [...resolvedOpenIds, id].sort(),
322
- );
366
+ if (resolvedOpenIds.includes(id)) {
367
+ setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
368
+ setContainerFocus((prev) => (prev?.id === id ? null : prev));
369
+ } else {
370
+ setOpenIds([...resolvedOpenIds, id].sort());
371
+ }
323
372
  },
324
373
  [resolvedOpenIds, setOpenIds],
325
374
  );
326
375
 
376
+ /**
377
+ * Sidebar row click: drop any trail focus (whose opened containers were a
378
+ * previous frame), then toggle the picked container (dropdown) and frame it.
379
+ */
380
+ const activateContainer = useCallback(
381
+ (id: string) => {
382
+ const opened = trailOpenedRef.current;
383
+ const clearing = focusedTrailId != null;
384
+ const base = clearing
385
+ ? resolvedOpenIds.filter((openId) => !opened.has(openId))
386
+ : resolvedOpenIds;
387
+ if (clearing) {
388
+ trailOpenedRef.current = new Set();
389
+ setFocusedTrailId(null);
390
+ setHoveredStep(null);
391
+ setFocusedStep(null);
392
+ onTrailSelect?.(null);
393
+ }
394
+ if (base.includes(id)) {
395
+ setOpenIds(base.filter((openId) => openId !== id));
396
+ setContainerFocus((prev) => (prev?.id === id ? null : prev));
397
+ } else {
398
+ setContainerFocus({ id });
399
+ setOpenIds([...base, id].sort());
400
+ }
401
+ },
402
+ [focusedTrailId, onTrailSelect, resolvedOpenIds, setOpenIds],
403
+ );
404
+
405
+ /**
406
+ * Select-only row (no components to expand): drop any trail focus, keep the
407
+ * open set as it is, and frame the container.
408
+ */
409
+ const selectContainer = useCallback(
410
+ (id: string) => {
411
+ const opened = trailOpenedRef.current;
412
+ const clearing = focusedTrailId != null;
413
+ const base = clearing
414
+ ? resolvedOpenIds.filter((openId) => !opened.has(openId))
415
+ : resolvedOpenIds;
416
+ if (clearing) {
417
+ trailOpenedRef.current = new Set();
418
+ setFocusedTrailId(null);
419
+ setHoveredStep(null);
420
+ setFocusedStep(null);
421
+ onTrailSelect?.(null);
422
+ if (base.length !== resolvedOpenIds.length) setOpenIds(base);
423
+ }
424
+ setContainerFocus({ id });
425
+ },
426
+ [focusedTrailId, onTrailSelect, resolvedOpenIds, setOpenIds],
427
+ );
428
+
327
429
  const activeStep = focusedStep ?? hoveredStep;
328
430
  const emphasis = useMemo(() => {
329
431
  let hiddenElementIds: ReadonlySet<string> | null = null;
@@ -408,6 +510,7 @@ export function C4ProjectionView({
408
510
  );
409
511
 
410
512
  const openAll = useCallback(() => {
513
+ setContainerFocus(null);
411
514
  setOpenIds(
412
515
  model.nodes
413
516
  .filter((node) => node.kind === 'container')
@@ -417,23 +520,19 @@ export function C4ProjectionView({
417
520
  }, [model, setOpenIds]);
418
521
 
419
522
  const collapseAll = useCallback(() => {
523
+ setContainerFocus(null);
420
524
  setOpenIds([]);
421
525
  }, [setOpenIds]);
422
526
 
423
- const sidebarHeader = description ? (
424
- <div style={{ fontSize: theme.fontSizes[0], lineHeight: 1.5 }}>
425
- <IndustryMarkdownSlide
426
- content={description}
427
- slideIdPrefix="c4-projection-desc"
428
- slideIndex={0}
429
- isVisible={true}
430
- theme={theme}
431
- disableScroll={true}
432
- disableBasePadding
433
- enableKeyboardScrolling={false}
434
- autoFocusOnVisible={false}
435
- />
436
- </div>
527
+ const sidebarHeader = descriptionPreview ? (
528
+ <DescriptionPreview
529
+ content={descriptionPreview}
530
+ clamp={!shortDescription}
531
+ open={hasNotes && notesOpen}
532
+ onOpen={hasNotes ? () => setNotesOpen(true) : undefined}
533
+ onClose={hasNotes ? () => setNotesOpen(false) : undefined}
534
+ slideIdPrefix="c4-projection-desc"
535
+ />
437
536
  ) : null;
438
537
 
439
538
  return (
@@ -482,16 +581,6 @@ export function C4ProjectionView({
482
581
  }}
483
582
  >
484
583
  {headerActions}
485
- <button type="button" onClick={openAll} style={smallButton(theme)}>
486
- Open all
487
- </button>
488
- <button
489
- type="button"
490
- onClick={collapseAll}
491
- style={smallButton(theme)}
492
- >
493
- Collapse all
494
- </button>
495
584
  </div>
496
585
  </header>
497
586
  <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
@@ -502,7 +591,18 @@ export function C4ProjectionView({
502
591
  maxWidth={480}
503
592
  headerMaxHeight="30%"
504
593
  header={sidebarHeader}
594
+ tabs={
595
+ trails.length > 0
596
+ ? [
597
+ { id: 'containers', label: 'Containers' },
598
+ { id: 'trails', label: 'Trails' },
599
+ ]
600
+ : undefined
601
+ }
602
+ activeTab={trails.length > 0 ? sidebarTab : undefined}
603
+ onTabChange={(id) => setSidebarTab(id as 'containers' | 'trails')}
505
604
  sidebarBody={
605
+ trails.length > 0 && sidebarTab === 'trails' ? (
506
606
  <TrailStepsNav
507
607
  trails={[...trails]}
508
608
  focusedTrailId={focusedTrailId}
@@ -544,8 +644,26 @@ export function C4ProjectionView({
544
644
  onTrailStepHover?.(null);
545
645
  }}
546
646
  />
647
+ ) : (
648
+ <C4ContainersPanel
649
+ containers={containerItems}
650
+ activeId={containerFocus?.id ?? null}
651
+ onActivate={activateContainer}
652
+ onSelect={selectContainer}
653
+ onOpenAll={openAll}
654
+ onCloseAll={collapseAll}
655
+ />
656
+ )
547
657
  }
548
658
  >
659
+ {hasNotes && notesOpen && (
660
+ <DescriptionOverlay
661
+ description={extendedNotes ?? ''}
662
+ ariaLabel="Subsystem notes"
663
+ slideIdPrefix="c4-projection-notes-overlay"
664
+ onClose={() => setNotesOpen(false)}
665
+ />
666
+ )}
549
667
  <C4Graph
550
668
  model={renderedModel}
551
669
  onSelectEdge={(edge) => {
@@ -554,6 +672,7 @@ export function C4ProjectionView({
554
672
  }}
555
673
  onTrailClick={(ref) => focusTrail(ref.trailId)}
556
674
  onToggleContainer={toggleContainer}
675
+ containerFocus={focusedTrailId ? undefined : containerFocus}
557
676
  hiddenElementIds={emphasis.hiddenElementIds}
558
677
  hiddenEdgeIds={emphasis.hiddenEdgeIds}
559
678
  dimmedElementIds={emphasis.dimmedElementIds}
@@ -572,24 +691,3 @@ export function C4ProjectionView({
572
691
  </div>
573
692
  );
574
693
  }
575
-
576
- function smallButton(theme: ReturnType<typeof useTheme>['theme']) {
577
- return {
578
- flexShrink: 0,
579
- display: 'inline-flex',
580
- alignItems: 'center',
581
- justifyContent: 'center',
582
- width: 132,
583
- height: 34,
584
- padding: '0 12px',
585
- boxSizing: 'border-box',
586
- whiteSpace: 'nowrap',
587
- borderRadius: 6,
588
- border: `1px solid ${theme.colors.border}`,
589
- background: 'transparent',
590
- color: theme.colors.textSecondary,
591
- fontFamily: theme.fonts.body,
592
- fontSize: theme.fontSizes[1],
593
- cursor: 'pointer',
594
- } as const;
595
- }