@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.
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts +4 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js +189 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts +8 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js +103 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js.map +1 -0
- package/dist/subsystem/C4ContainersPanel.d.ts +35 -0
- package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -0
- package/dist/subsystem/C4ContainersPanel.js +165 -0
- package/dist/subsystem/C4ContainersPanel.js.map +1 -0
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +10 -4
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/C4ProjectionView.d.ts +12 -2
- package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
- package/dist/subsystem/C4ProjectionView.js +100 -33
- package/dist/subsystem/C4ProjectionView.js.map +1 -1
- package/dist/subsystem/C4SketchView.d.ts.map +1 -1
- package/dist/subsystem/C4SketchView.js +53 -34
- package/dist/subsystem/C4SketchView.js.map +1 -1
- package/dist/subsystem/ConstructsCatalog.d.ts +18 -11
- package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
- package/dist/subsystem/ConstructsCatalog.js +25 -27
- package/dist/subsystem/ConstructsCatalog.js.map +1 -1
- package/dist/subsystem/DescriptionOverlay.d.ts +10 -2
- package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -1
- package/dist/subsystem/DescriptionOverlay.js +4 -4
- package/dist/subsystem/DescriptionOverlay.js.map +1 -1
- package/dist/subsystem/DescriptionPreview.d.ts +31 -0
- package/dist/subsystem/DescriptionPreview.d.ts.map +1 -0
- package/dist/subsystem/DescriptionPreview.js +31 -0
- package/dist/subsystem/DescriptionPreview.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -3
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +18 -23
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.js +1 -0
- package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +29 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js +320 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -0
- package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
- package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
- package/dist/subsystem/c4Sketch.d.ts +12 -0
- package/dist/subsystem/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/c4Sketch.js +2 -1
- package/dist/subsystem/c4Sketch.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +3 -1
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +2 -2
- package/dist/subsystem/containerCard.js.map +1 -1
- package/dist/subsystem/techIcons/index.d.ts +3 -1
- package/dist/subsystem/techIcons/index.d.ts.map +1 -1
- package/dist/subsystem/techIcons/index.js +2 -2
- package/dist/subsystem/techIcons/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/stories/Canvases/C4/C4CardGrow.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Component.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Container.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Draft.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4NodeGallery.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Sketch.stories.tsx +62 -4
- package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Transition.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/AnimatedProgression.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Appearance.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Basics.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Captures.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Constructs.stories.tsx +3 -7
- package/src/stories/Canvases/Subsystem/ConstructsEmbed.stories.tsx +27 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +7 -4
- package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +3 -2
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +2 -100
- package/src/stories/Canvases/Subsystem/DeprecatedGraph.stories.tsx +124 -0
- package/src/stories/Canvases/Subsystem/DetailPanel.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Diagnostics.stories.tsx +1 -43
- package/src/stories/Canvases/Subsystem/DiagnosticsStates.stories.tsx +63 -0
- package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +3 -2
- package/src/stories/Canvases/Subsystem/FrameworkStereotype.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/GraphTitle.stories.tsx +1 -19
- package/src/stories/Canvases/Subsystem/GraphTitleGraph.stories.tsx +51 -0
- package/src/stories/Canvases/Subsystem/Issues.stories.tsx +5 -229
- package/src/stories/Canvases/Subsystem/IssuesList.stories.tsx +60 -0
- package/src/stories/Canvases/Subsystem/LayoutDirection.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +6 -63
- package/src/stories/Canvases/Subsystem/ModuleBadgesNode.stories.tsx +81 -0
- package/src/stories/Canvases/Subsystem/ModulePathNesting.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Modules.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Packages.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Presentation.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Processes.stories.tsx +3 -2
- package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +5 -154
- package/src/stories/Canvases/Subsystem/ReorderPanel.stories.tsx +75 -0
- package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +7 -4
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StepEmphasis.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StoreValueType.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +3 -2
- package/src/stories/Canvases/Subsystem/TrailSidebarViews.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Trails.stories.tsx +5 -3
- package/src/stories/Canvases/Subsystem/WorkspacePackageFrames.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/issuesFixtures.ts +192 -0
- package/src/stories/Canvases/Subsystem/reorderFixtures.tsx +125 -0
- package/src/stories/Components/ConstructsCatalog.stories.tsx +2 -1
- package/src/subsystem/C4ContainersPanel.test.tsx +151 -0
- package/src/subsystem/C4ContainersPanel.tsx +315 -0
- package/src/subsystem/C4NodeCard.tsx +12 -4
- package/src/subsystem/C4ProjectionView.tsx +151 -53
- package/src/subsystem/C4SketchView.tsx +96 -74
- package/src/subsystem/ConstructsCatalog.tsx +59 -58
- package/src/subsystem/DescriptionOverlay.test.tsx +18 -8
- package/src/subsystem/DescriptionOverlay.tsx +20 -5
- package/src/subsystem/DescriptionPreview.tsx +96 -0
- package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +28 -8
- package/src/subsystem/SubsystemComponentGraph.tsx +46 -51
- package/src/subsystem/__fixtures__/c4Sketch.ts +2 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.test.ts +65 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.ts +361 -0
- package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +778 -0
- package/src/subsystem/__fixtures__/c4Sketches/openbot.json +887 -0
- package/src/subsystem/c4Sketch.ts +13 -0
- package/src/subsystem/containerCard.tsx +4 -1
- package/src/subsystem/techIcons/index.tsx +11 -2
|
@@ -10,9 +10,13 @@ import { useCallback, useMemo, useState } from 'react';
|
|
|
10
10
|
import type { CSSProperties, ReactNode } from 'react';
|
|
11
11
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
12
12
|
import { PencilRuler } from 'lucide-react';
|
|
13
|
-
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
14
13
|
import { C4Graph } from './C4Graph';
|
|
14
|
+
import { C4ContainersPanel } from './C4ContainersPanel';
|
|
15
|
+
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
16
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
15
17
|
import { GraphWithSidebar } from './GraphWithSidebar';
|
|
18
|
+
import type { C4Component, C4Container } from './c4';
|
|
19
|
+
import { C4_SKETCH_DESCRIPTION_MAX } from './c4Sketch';
|
|
16
20
|
import type { C4Sketch } from './c4Sketch';
|
|
17
21
|
|
|
18
22
|
export interface C4SketchViewProps {
|
|
@@ -51,6 +55,25 @@ export function C4SketchView({
|
|
|
51
55
|
[onOpenContainerIdsChange, openContainerIds],
|
|
52
56
|
);
|
|
53
57
|
|
|
58
|
+
/** The container last activated from the sidebar — the camera target. */
|
|
59
|
+
const [focus, setFocus] = useState<{ id: string } | null>(null);
|
|
60
|
+
|
|
61
|
+
const containers = useMemo(() => {
|
|
62
|
+
const components = sketch.model.nodes.filter(
|
|
63
|
+
(node): node is C4Component => node.kind === 'component',
|
|
64
|
+
);
|
|
65
|
+
return sketch.model.nodes
|
|
66
|
+
.filter((node): node is C4Container => node.kind === 'container')
|
|
67
|
+
.map((container) => ({
|
|
68
|
+
container,
|
|
69
|
+
open: resolvedOpenIds.includes(container.id),
|
|
70
|
+
members: components.filter(
|
|
71
|
+
(component) =>
|
|
72
|
+
(component.container ?? component.parentId) === container.id,
|
|
73
|
+
),
|
|
74
|
+
}));
|
|
75
|
+
}, [sketch.model.nodes, resolvedOpenIds]);
|
|
76
|
+
|
|
54
77
|
const model = useMemo(
|
|
55
78
|
() => ({ ...sketch.model, openContainerIds: resolvedOpenIds }),
|
|
56
79
|
[resolvedOpenIds, sketch.model],
|
|
@@ -58,16 +81,18 @@ export function C4SketchView({
|
|
|
58
81
|
|
|
59
82
|
const toggleContainer = useCallback(
|
|
60
83
|
(id: string) => {
|
|
61
|
-
|
|
62
|
-
resolvedOpenIds.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
84
|
+
if (resolvedOpenIds.includes(id)) {
|
|
85
|
+
setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
|
|
86
|
+
setFocus((prev) => (prev?.id === id ? null : prev));
|
|
87
|
+
} else {
|
|
88
|
+
setOpenIds([...resolvedOpenIds, id].sort());
|
|
89
|
+
}
|
|
66
90
|
},
|
|
67
91
|
[resolvedOpenIds, setOpenIds],
|
|
68
92
|
);
|
|
69
93
|
|
|
70
94
|
const openAll = useCallback(() => {
|
|
95
|
+
setFocus(null);
|
|
71
96
|
setOpenIds(
|
|
72
97
|
sketch.model.nodes
|
|
73
98
|
.filter((node) => node.kind === 'container')
|
|
@@ -76,33 +101,48 @@ export function C4SketchView({
|
|
|
76
101
|
);
|
|
77
102
|
}, [setOpenIds, sketch.model.nodes]);
|
|
78
103
|
|
|
79
|
-
const collapseAll = useCallback(() =>
|
|
104
|
+
const collapseAll = useCallback(() => {
|
|
105
|
+
setFocus(null);
|
|
106
|
+
setOpenIds([]);
|
|
107
|
+
}, [setOpenIds]);
|
|
108
|
+
|
|
109
|
+
/** Row click: toggle the container's internals and frame it (dropdown). */
|
|
110
|
+
const activateContainer = useCallback(
|
|
111
|
+
(id: string) => {
|
|
112
|
+
if (resolvedOpenIds.includes(id)) {
|
|
113
|
+
setOpenIds(resolvedOpenIds.filter((openId) => openId !== id));
|
|
114
|
+
setFocus((prev) => (prev?.id === id ? null : prev));
|
|
115
|
+
} else {
|
|
116
|
+
setFocus({ id });
|
|
117
|
+
setOpenIds([...resolvedOpenIds, id].sort());
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
[resolvedOpenIds, setOpenIds],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
/** Select-only row (no components to expand): just frame the container. */
|
|
124
|
+
const selectContainer = useCallback((id: string) => setFocus({ id }), []);
|
|
80
125
|
|
|
126
|
+
const [notesOpen, setNotesOpen] = useState(false);
|
|
127
|
+
const rawDescription = sketch.description?.trim();
|
|
128
|
+
// The store caps the authored description; trim defensively for other hosts.
|
|
129
|
+
const description =
|
|
130
|
+
rawDescription && rawDescription.length > C4_SKETCH_DESCRIPTION_MAX
|
|
131
|
+
? `${rawDescription.slice(0, C4_SKETCH_DESCRIPTION_MAX - 1)}…`
|
|
132
|
+
: rawDescription;
|
|
81
133
|
const notes = sketch.notes?.trim();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<IndustryMarkdownSlide
|
|
95
|
-
content={notes}
|
|
96
|
-
slideIdPrefix={`c4-sketch-notes-${sketch.id}`}
|
|
97
|
-
slideIndex={0}
|
|
98
|
-
isVisible={true}
|
|
99
|
-
theme={theme}
|
|
100
|
-
disableScroll={true}
|
|
101
|
-
disableBasePadding
|
|
102
|
-
enableKeyboardScrolling={false}
|
|
103
|
-
autoFocusOnVisible={false}
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
134
|
+
// The short description owns the top-left slot; a legacy sketch with only
|
|
135
|
+
// notes falls back to a clamped preview of them.
|
|
136
|
+
const preview = description || notes;
|
|
137
|
+
const descriptionPanel = preview ? (
|
|
138
|
+
<DescriptionPreview
|
|
139
|
+
content={preview}
|
|
140
|
+
clamp={!description}
|
|
141
|
+
open={notesOpen}
|
|
142
|
+
onOpen={notes ? () => setNotesOpen(true) : undefined}
|
|
143
|
+
onClose={notes ? () => setNotesOpen(false) : undefined}
|
|
144
|
+
slideIdPrefix={`c4-sketch-description-${sketch.id}`}
|
|
145
|
+
/>
|
|
106
146
|
) : null;
|
|
107
147
|
|
|
108
148
|
return (
|
|
@@ -181,61 +221,43 @@ export function C4SketchView({
|
|
|
181
221
|
}}
|
|
182
222
|
>
|
|
183
223
|
{headerActions}
|
|
184
|
-
<button
|
|
185
|
-
type="button"
|
|
186
|
-
onClick={openAll}
|
|
187
|
-
style={smallButton(theme, { width: 132 })}
|
|
188
|
-
>
|
|
189
|
-
Open all
|
|
190
|
-
</button>
|
|
191
|
-
<button
|
|
192
|
-
type="button"
|
|
193
|
-
onClick={collapseAll}
|
|
194
|
-
style={smallButton(theme, { width: 132 })}
|
|
195
|
-
>
|
|
196
|
-
Collapse all
|
|
197
|
-
</button>
|
|
198
224
|
</div>
|
|
199
225
|
</header>
|
|
200
226
|
|
|
201
227
|
<div style={{ flex: 1, minHeight: 0 }}>
|
|
202
228
|
<GraphWithSidebar
|
|
203
|
-
hidden={!notes}
|
|
204
|
-
stretchHeader
|
|
205
229
|
defaultWidth={320}
|
|
206
230
|
minWidth={240}
|
|
207
231
|
maxWidth={480}
|
|
208
232
|
persistKey={persistKey ?? `c4-sketch-notes-${sketch.id}`}
|
|
209
|
-
header={
|
|
233
|
+
header={descriptionPanel}
|
|
234
|
+
sidebarBody={
|
|
235
|
+
<C4ContainersPanel
|
|
236
|
+
containers={containers}
|
|
237
|
+
activeId={focus?.id ?? null}
|
|
238
|
+
onActivate={activateContainer}
|
|
239
|
+
onSelect={selectContainer}
|
|
240
|
+
onOpenAll={openAll}
|
|
241
|
+
onCloseAll={collapseAll}
|
|
242
|
+
/>
|
|
243
|
+
}
|
|
210
244
|
>
|
|
211
|
-
|
|
245
|
+
{notes && notesOpen && (
|
|
246
|
+
<DescriptionOverlay
|
|
247
|
+
description={notes}
|
|
248
|
+
title="Overview"
|
|
249
|
+
ariaLabel="Sketch notes"
|
|
250
|
+
slideIdPrefix={`c4-sketch-notes-overlay-${sketch.id}`}
|
|
251
|
+
onClose={() => setNotesOpen(false)}
|
|
252
|
+
/>
|
|
253
|
+
)}
|
|
254
|
+
<C4Graph
|
|
255
|
+
model={model}
|
|
256
|
+
onToggleContainer={toggleContainer}
|
|
257
|
+
containerFocus={focus}
|
|
258
|
+
/>
|
|
212
259
|
</GraphWithSidebar>
|
|
213
260
|
</div>
|
|
214
261
|
</div>
|
|
215
262
|
);
|
|
216
263
|
}
|
|
217
|
-
|
|
218
|
-
function smallButton(
|
|
219
|
-
theme: ReturnType<typeof useTheme>['theme'],
|
|
220
|
-
opts: { width?: number } = {},
|
|
221
|
-
) {
|
|
222
|
-
return {
|
|
223
|
-
flexShrink: 0,
|
|
224
|
-
display: 'inline-flex',
|
|
225
|
-
alignItems: 'center',
|
|
226
|
-
justifyContent: 'center',
|
|
227
|
-
gap: 5,
|
|
228
|
-
...(opts.width ? { width: opts.width } : {}),
|
|
229
|
-
height: 34,
|
|
230
|
-
padding: '0 10px',
|
|
231
|
-
boxSizing: 'border-box',
|
|
232
|
-
whiteSpace: 'nowrap',
|
|
233
|
-
borderRadius: 6,
|
|
234
|
-
border: `1px solid ${theme.colors.border}`,
|
|
235
|
-
background: 'transparent',
|
|
236
|
-
color: theme.colors.textSecondary,
|
|
237
|
-
fontFamily: theme.fonts.body,
|
|
238
|
-
fontSize: theme.fontSizes[1],
|
|
239
|
-
cursor: 'pointer',
|
|
240
|
-
} as const;
|
|
241
|
-
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Left: the model's files as a tree; clicking a file toggles its
|
|
6
6
|
* constructs. Right: signatures grouped by repo, and within a repo stacked
|
|
7
|
-
* per file under one combined file header carrying the path
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* per file under one combined file header carrying the path; a declaration
|
|
8
|
+
* with a known line labels just that construct's line in a file-like gutter,
|
|
9
|
+
* and `external` constructs get a header naming their kind with the body
|
|
10
|
+
* naming the construct. The short model description sits in the left chrome;
|
|
11
|
+
* when `notes` is set, its `Show more` link opens the extended Markdown as an
|
|
12
12
|
* overlay over the construct area. File opens still use the bottom FileDrawer
|
|
13
13
|
* when the host injects a viewer.
|
|
14
14
|
*/
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import type { ReactNode } from 'react';
|
|
18
18
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
19
|
+
import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
|
|
19
20
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
20
21
|
import {
|
|
21
22
|
AlignLeft,
|
|
@@ -35,6 +36,7 @@ import { ComponentDeclaration } from './ComponentDeclaration';
|
|
|
35
36
|
import type { ComponentVerificationState } from './ComponentDeclaration';
|
|
36
37
|
import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
|
|
37
38
|
import { SubsystemDiagnosticToggle, type SubsystemDiagnostic } from './DiagnosticToggle';
|
|
39
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
38
40
|
import { FileDrawer } from './FileDrawer';
|
|
39
41
|
import { componentColor } from '../pierre/constructColors';
|
|
40
42
|
import { resolvePierreSyntaxThemeName } from '../pierre/pierreSyntaxTheme';
|
|
@@ -45,14 +47,21 @@ export interface ConstructsCatalogProps {
|
|
|
45
47
|
title?: string;
|
|
46
48
|
hideSidebar?: boolean;
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* Short model description shown in the left chrome. At most 200 characters;
|
|
51
|
+
* extended detail belongs in `notes`.
|
|
50
52
|
*/
|
|
51
53
|
description?: string;
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* Extended Markdown notes about the model. When set, the description's
|
|
56
|
+
* `Show more` link opens the full document in an Overview overlay over the
|
|
57
|
+
* construct area. Omit `description` and the chrome falls back to a clamped
|
|
58
|
+
* preview of these notes.
|
|
59
|
+
*/
|
|
60
|
+
notes?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Controlled open state for the notes overlay. When provided the host owns
|
|
63
|
+
* it (e.g. a button in its own header); otherwise the built-in link drives
|
|
64
|
+
* the state.
|
|
56
65
|
*/
|
|
57
66
|
descriptionOpen?: boolean;
|
|
58
67
|
onDescriptionOpenChange?: (open: boolean) => void;
|
|
@@ -196,6 +205,7 @@ export function ConstructsCatalog({
|
|
|
196
205
|
title,
|
|
197
206
|
hideSidebar,
|
|
198
207
|
description,
|
|
208
|
+
notes,
|
|
199
209
|
descriptionOpen: descriptionOpenProp,
|
|
200
210
|
onDescriptionOpenChange,
|
|
201
211
|
diagnostic,
|
|
@@ -237,7 +247,17 @@ export function ConstructsCatalog({
|
|
|
237
247
|
setDescriptionVisible(open);
|
|
238
248
|
onDescriptionOpenChange?.(open);
|
|
239
249
|
};
|
|
240
|
-
const
|
|
250
|
+
const rawDescription = description?.trim();
|
|
251
|
+
// The host caps the authored description; trim defensively for other hosts.
|
|
252
|
+
const shortDescription =
|
|
253
|
+
rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
|
|
254
|
+
? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
|
|
255
|
+
: rawDescription;
|
|
256
|
+
const extendedNotes = notes?.trim();
|
|
257
|
+
// The short description owns the chrome; a legacy model with only notes
|
|
258
|
+
// falls back to a clamped preview of them.
|
|
259
|
+
const descriptionPreview = shortDescription || extendedNotes;
|
|
260
|
+
const hasNotes = Boolean(extendedNotes);
|
|
241
261
|
const [hoveredRow, setHoveredRow] = useState<string | null>(null);
|
|
242
262
|
const [collapsedFolders, setCollapsedFolders] = useState<Set<string>>(
|
|
243
263
|
new Set(),
|
|
@@ -571,7 +591,7 @@ export function ConstructsCatalog({
|
|
|
571
591
|
!hideSidebar &&
|
|
572
592
|
!!(
|
|
573
593
|
title ||
|
|
574
|
-
|
|
594
|
+
descriptionPreview ||
|
|
575
595
|
diagnostic ||
|
|
576
596
|
sidebarExtra ||
|
|
577
597
|
sidebarAfterDescription
|
|
@@ -612,7 +632,7 @@ export function ConstructsCatalog({
|
|
|
612
632
|
}}
|
|
613
633
|
>
|
|
614
634
|
{sidebarExtra}
|
|
615
|
-
{(title ||
|
|
635
|
+
{(title || diagnostic) && (
|
|
616
636
|
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 8 }}>
|
|
617
637
|
{title && (
|
|
618
638
|
<h2
|
|
@@ -629,50 +649,31 @@ export function ConstructsCatalog({
|
|
|
629
649
|
{title}
|
|
630
650
|
</h2>
|
|
631
651
|
)}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
aria-expanded={descriptionOpen}
|
|
646
|
-
aria-label={
|
|
647
|
-
descriptionOpen ? 'Hide description' : 'Show description'
|
|
648
|
-
}
|
|
649
|
-
title={
|
|
650
|
-
descriptionOpen ? 'Hide description' : 'Show description'
|
|
651
|
-
}
|
|
652
|
-
onMouseEnter={() => setDescToggleHover(true)}
|
|
653
|
-
onMouseLeave={() => setDescToggleHover(false)}
|
|
654
|
-
onClick={() => setDescriptionOpen(!descriptionOpen)}
|
|
655
|
-
style={{
|
|
656
|
-
display: 'inline-flex',
|
|
657
|
-
alignItems: 'center',
|
|
658
|
-
justifyContent: 'center',
|
|
659
|
-
flexShrink: 0,
|
|
660
|
-
width: 22,
|
|
661
|
-
height: 22,
|
|
662
|
-
padding: 0,
|
|
663
|
-
border: 'none',
|
|
664
|
-
borderRadius: 4,
|
|
665
|
-
background: descriptionOpen || descToggleHover ? theme.colors.border : 'transparent',
|
|
666
|
-
color: descriptionOpen || descToggleHover ? theme.colors.text : muted,
|
|
667
|
-
cursor: 'pointer',
|
|
668
|
-
}}
|
|
669
|
-
>
|
|
670
|
-
<FileText size={14} />
|
|
671
|
-
</button>
|
|
672
|
-
)}
|
|
673
|
-
</div>
|
|
652
|
+
{diagnostic && (
|
|
653
|
+
<div
|
|
654
|
+
style={{
|
|
655
|
+
display: 'flex',
|
|
656
|
+
alignItems: 'center',
|
|
657
|
+
gap: 4,
|
|
658
|
+
flexShrink: 0,
|
|
659
|
+
marginLeft: title ? undefined : 'auto',
|
|
660
|
+
}}
|
|
661
|
+
>
|
|
662
|
+
<SubsystemDiagnosticToggle {...diagnostic} />
|
|
663
|
+
</div>
|
|
664
|
+
)}
|
|
674
665
|
</div>
|
|
675
666
|
)}
|
|
667
|
+
{descriptionPreview && (
|
|
668
|
+
<DescriptionPreview
|
|
669
|
+
content={descriptionPreview}
|
|
670
|
+
clamp={!shortDescription}
|
|
671
|
+
open={hasNotes && descriptionOpen}
|
|
672
|
+
onOpen={hasNotes ? () => setDescriptionOpen(true) : undefined}
|
|
673
|
+
onClose={hasNotes ? () => setDescriptionOpen(false) : undefined}
|
|
674
|
+
slideIdPrefix="constructs-desc"
|
|
675
|
+
/>
|
|
676
|
+
)}
|
|
676
677
|
{sidebarAfterDescription}
|
|
677
678
|
</div>
|
|
678
679
|
)}
|
|
@@ -715,7 +716,7 @@ export function ConstructsCatalog({
|
|
|
715
716
|
flexDirection: 'column',
|
|
716
717
|
}}
|
|
717
718
|
>
|
|
718
|
-
{
|
|
719
|
+
{hasNotes && descriptionOpen && (
|
|
719
720
|
<div
|
|
720
721
|
style={{
|
|
721
722
|
position: 'absolute',
|
|
@@ -753,7 +754,7 @@ export function ConstructsCatalog({
|
|
|
753
754
|
</h3>
|
|
754
755
|
<button
|
|
755
756
|
type="button"
|
|
756
|
-
aria-label="Close
|
|
757
|
+
aria-label="Close notes"
|
|
757
758
|
title="Close"
|
|
758
759
|
onClick={() => setDescriptionOpen(false)}
|
|
759
760
|
style={{
|
|
@@ -792,7 +793,7 @@ export function ConstructsCatalog({
|
|
|
792
793
|
}}
|
|
793
794
|
>
|
|
794
795
|
<IndustryMarkdownSlide
|
|
795
|
-
content={
|
|
796
|
+
content={extendedNotes ?? ''}
|
|
796
797
|
slideIdPrefix="constructs-desc-overlay"
|
|
797
798
|
slideIndex={0}
|
|
798
799
|
isVisible
|
|
@@ -24,7 +24,7 @@ globals.matchMedia = dom.matchMedia.bind(dom);
|
|
|
24
24
|
|
|
25
25
|
afterEach(cleanup);
|
|
26
26
|
|
|
27
|
-
function renderGraph(description: string | undefined) {
|
|
27
|
+
function renderGraph(description: string | undefined, notes?: string) {
|
|
28
28
|
return render(createElement(
|
|
29
29
|
ThemeProvider,
|
|
30
30
|
{ theme: defaultEditorTheme },
|
|
@@ -39,38 +39,48 @@ function renderGraph(description: string | undefined) {
|
|
|
39
39
|
steps: [{ from: 'entry', to: 'store', mechanism: 'calls' }],
|
|
40
40
|
}],
|
|
41
41
|
description,
|
|
42
|
+
notes,
|
|
42
43
|
}),
|
|
43
44
|
));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
describe('subsystem description overlay', () => {
|
|
47
48
|
for (const closeWithEscape of [false, true]) {
|
|
48
|
-
test(`More opens the full
|
|
49
|
-
const
|
|
50
|
-
const view = renderGraph(description);
|
|
49
|
+
test(`More opens the full notes over the graph and closes with ${closeWithEscape ? 'Escape' : 'the close button'}`, () => {
|
|
50
|
+
const notes = `${'A long note. '.repeat(50)}\n\n**Final detail**`;
|
|
51
|
+
const view = renderGraph('Short description.', notes);
|
|
51
52
|
const more = view.getByRole('button', { name: 'Read full description' });
|
|
52
53
|
more.focus();
|
|
53
54
|
fireEvent.click(more);
|
|
54
|
-
const overlay = view.getByRole('dialog', { name: 'Subsystem
|
|
55
|
-
expect(overlay.textContent).toContain('A long
|
|
55
|
+
const overlay = view.getByRole('dialog', { name: 'Subsystem notes' });
|
|
56
|
+
expect(overlay.textContent).toContain('A long note. '.repeat(50).trim());
|
|
56
57
|
expect(overlay.querySelector('strong')?.textContent).toBe('Final detail');
|
|
58
|
+
expect(overlay.textContent).not.toContain('Short description.');
|
|
57
59
|
expect(overlay.style.position).toBe('absolute');
|
|
58
60
|
expect(overlay.parentElement?.contains(view.getByLabelText('Resize sidebar'))).toBe(false);
|
|
59
61
|
expect(more.getAttribute('aria-expanded')).toBe('true');
|
|
62
|
+
expect(more.textContent).toBe('Close');
|
|
60
63
|
const close = view.getByRole('button', { name: 'Close description' });
|
|
61
64
|
expect(document.activeElement).toBe(close);
|
|
62
65
|
if (closeWithEscape) fireEvent.keyDown(close, { key: 'Escape' });
|
|
63
66
|
else fireEvent.click(close);
|
|
64
67
|
expect(view.queryByRole('dialog')).toBeNull();
|
|
65
68
|
expect(more.getAttribute('aria-expanded')).toBe('false');
|
|
69
|
+
expect(more.textContent).toBe('Show more');
|
|
66
70
|
expect(document.activeElement).toBe(more);
|
|
67
71
|
expect(view.getByText('Request flow')).toBeTruthy();
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
test('does not offer More when there
|
|
72
|
-
const view = renderGraph(
|
|
75
|
+
test('does not offer More when there are no notes', () => {
|
|
76
|
+
const view = renderGraph('Short description only.');
|
|
73
77
|
expect(view.queryByRole('button', { name: 'Read full description' })).toBeNull();
|
|
74
78
|
expect(view.queryByRole('dialog')).toBeNull();
|
|
75
79
|
});
|
|
80
|
+
|
|
81
|
+
test('falls back to a clamped notes preview when there is no description', () => {
|
|
82
|
+
const view = renderGraph(undefined, `${'A long note. '.repeat(50)}\n\n**Final detail**`);
|
|
83
|
+
expect(view.getByRole('button', { name: 'Read full description' })).toBeTruthy();
|
|
84
|
+
expect(view.queryByRole('dialog')).toBeNull();
|
|
85
|
+
});
|
|
76
86
|
});
|
|
@@ -3,10 +3,25 @@ import { useTheme } from '@principal-ade/industry-theme';
|
|
|
3
3
|
import { X } from 'lucide-react';
|
|
4
4
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export interface DescriptionOverlayProps {
|
|
7
|
+
/** Full Markdown shown in the dialog. */
|
|
7
8
|
description: string;
|
|
8
9
|
onClose: () => void;
|
|
9
|
-
|
|
10
|
+
/** Dialog heading. Defaults to `Overview`. */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Accessible name for the dialog. */
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
/** Prefix for the Markdown slide ids (keeps duplicate headings unique). */
|
|
15
|
+
slideIdPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function DescriptionOverlay({
|
|
19
|
+
description,
|
|
20
|
+
onClose,
|
|
21
|
+
title = 'Overview',
|
|
22
|
+
ariaLabel = 'Description',
|
|
23
|
+
slideIdPrefix = 'description-desc-overlay',
|
|
24
|
+
}: DescriptionOverlayProps) {
|
|
10
25
|
const { theme } = useTheme();
|
|
11
26
|
const closeRef = useRef<HTMLButtonElement>(null);
|
|
12
27
|
|
|
@@ -21,7 +36,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
21
36
|
return (
|
|
22
37
|
<div
|
|
23
38
|
role="dialog"
|
|
24
|
-
aria-label=
|
|
39
|
+
aria-label={ariaLabel}
|
|
25
40
|
onKeyDown={(event) => {
|
|
26
41
|
if (event.key === 'Escape') {
|
|
27
42
|
event.stopPropagation();
|
|
@@ -54,7 +69,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
54
69
|
textTransform: 'uppercase',
|
|
55
70
|
color: theme.colors.textSecondary,
|
|
56
71
|
}}>
|
|
57
|
-
|
|
72
|
+
{title}
|
|
58
73
|
</h3>
|
|
59
74
|
<button
|
|
60
75
|
ref={closeRef}
|
|
@@ -82,7 +97,7 @@ export function DescriptionOverlay({ description, onClose }: {
|
|
|
82
97
|
<div style={{ lineHeight: 1.7 }}>
|
|
83
98
|
<IndustryMarkdownSlide
|
|
84
99
|
content={description}
|
|
85
|
-
slideIdPrefix=
|
|
100
|
+
slideIdPrefix={slideIdPrefix}
|
|
86
101
|
slideIndex={0}
|
|
87
102
|
isVisible
|
|
88
103
|
theme={theme}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
2
|
+
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
3
|
+
|
|
4
|
+
export interface DescriptionPreviewProps {
|
|
5
|
+
/** The full Markdown document. */
|
|
6
|
+
content: string;
|
|
7
|
+
/** Open the full description overlay. Omit to hide the toggle. */
|
|
8
|
+
onOpen?: () => void;
|
|
9
|
+
/** Close the full description overlay. */
|
|
10
|
+
onClose?: () => void;
|
|
11
|
+
/** Whether the overlay is currently open (for `aria-expanded` and the label). */
|
|
12
|
+
open?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Clamp the preview to `clampLines`. Pass `false` when the content is
|
|
15
|
+
* already length-capped and should size the header by its own height.
|
|
16
|
+
*/
|
|
17
|
+
clamp?: boolean;
|
|
18
|
+
/** Visible lines before the clamp (only when `clamp` is true). */
|
|
19
|
+
clampLines?: number;
|
|
20
|
+
/** Prefix for the Markdown slide ids (keeps duplicate headings unique). */
|
|
21
|
+
slideIdPrefix?: string;
|
|
22
|
+
/** Link text while the overlay is closed. */
|
|
23
|
+
moreLabel?: string;
|
|
24
|
+
/** Link text while the overlay is open. */
|
|
25
|
+
lessLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The top-of-sidebar description shared by the subsystem and C4 views:
|
|
30
|
+
* Markdown plus an optional `Show more` link that opens the full document in
|
|
31
|
+
* a `DescriptionOverlay` (and turns into `Close` while it is open).
|
|
32
|
+
*/
|
|
33
|
+
export function DescriptionPreview({
|
|
34
|
+
content,
|
|
35
|
+
onOpen,
|
|
36
|
+
onClose,
|
|
37
|
+
open = false,
|
|
38
|
+
clamp = true,
|
|
39
|
+
clampLines = 6,
|
|
40
|
+
slideIdPrefix = 'description-preview',
|
|
41
|
+
moreLabel = 'Show more',
|
|
42
|
+
lessLabel = 'Close',
|
|
43
|
+
}: DescriptionPreviewProps) {
|
|
44
|
+
const { theme } = useTheme();
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ fontSize: theme.fontSizes[0], lineHeight: 1.5 }}>
|
|
47
|
+
<div
|
|
48
|
+
style={
|
|
49
|
+
clamp
|
|
50
|
+
? {
|
|
51
|
+
display: '-webkit-box',
|
|
52
|
+
WebkitBoxOrient: 'vertical',
|
|
53
|
+
WebkitLineClamp: clampLines,
|
|
54
|
+
maxHeight: `${clampLines * 1.5}em`,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
}
|
|
57
|
+
: undefined
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<IndustryMarkdownSlide
|
|
61
|
+
content={content}
|
|
62
|
+
slideIdPrefix={slideIdPrefix}
|
|
63
|
+
slideIndex={0}
|
|
64
|
+
isVisible={true}
|
|
65
|
+
theme={theme}
|
|
66
|
+
disableScroll={true}
|
|
67
|
+
disableBasePadding
|
|
68
|
+
enableKeyboardScrolling={false}
|
|
69
|
+
autoFocusOnVisible={false}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
{(onOpen || onClose) && (
|
|
73
|
+
<button
|
|
74
|
+
type="button"
|
|
75
|
+
aria-label={open ? 'Close description preview' : 'Read full description'}
|
|
76
|
+
aria-haspopup="dialog"
|
|
77
|
+
aria-expanded={open}
|
|
78
|
+
onClick={() => (open ? onClose?.() : onOpen?.())}
|
|
79
|
+
style={{
|
|
80
|
+
marginTop: 6,
|
|
81
|
+
padding: 0,
|
|
82
|
+
border: 'none',
|
|
83
|
+
background: 'transparent',
|
|
84
|
+
color: theme.colors.textSecondary,
|
|
85
|
+
fontFamily: theme.fonts.body,
|
|
86
|
+
fontSize: theme.fontSizes[0],
|
|
87
|
+
textDecoration: 'underline',
|
|
88
|
+
cursor: 'pointer',
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
{open ? lessLabel : moreLabel}
|
|
92
|
+
</button>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|