@principal-ai/subsystems-react 0.17.0 → 0.18.0
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 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +9 -199
- package/src/components/ConfigurationSelector.tsx +0 -133
- package/src/components/GraphRenderer.tsx +0 -3195
- package/src/components/MultiCanvasRenderer.tsx +0 -295
- package/src/components/NodeTooltip.tsx +0 -279
- package/src/components/PendingChanges.test.tsx +0 -375
- package/src/components/SelectionSidebar.tsx +0 -352
- package/src/components/SequenceDiagramRenderer.tsx +0 -1156
- package/src/components/WorkflowSequenceDiagram.tsx +0 -270
- package/src/components/dashboard/DashboardRenderer.tsx +0 -317
- package/src/components/dashboard/MetricPanel.tsx +0 -254
- package/src/components/dashboard/MockDataProvider.ts +0 -330
- package/src/components/dashboard/components/BarChart.tsx +0 -299
- package/src/components/dashboard/components/LineChart.tsx +0 -279
- package/src/components/dashboard/components/MetricCard.tsx +0 -270
- package/src/components/dashboard/components/SourceLink.tsx +0 -63
- package/src/components/dashboard/components/TimeRangeSelector.tsx +0 -280
- package/src/components/dashboard/components/index.ts +0 -5
- package/src/components/dashboard/index.ts +0 -47
- package/src/components/dashboard/types.ts +0 -126
- package/src/components/state-view/PipelineView.tsx +0 -347
- package/src/components/state-view/index.ts +0 -14
- package/src/components/state-view/types.ts +0 -261
- package/src/components/state-view/useStateView.ts +0 -205
- package/src/contexts/GraphEditContext.tsx +0 -27
- package/src/contexts/TooltipPortalContext.ts +0 -8
- package/src/edges/CustomEdge.tsx +0 -402
- package/src/edges/GenericEdge.tsx +0 -36
- package/src/hooks/usePathBasedEvents.ts +0 -192
- package/src/hooks/useSequenceLayout.ts +0 -543
- package/src/hooks/useUndoRedo.ts +0 -144
- package/src/nodes/CustomNode.tsx +0 -1231
- package/src/nodes/GenericNode.tsx +0 -55
- package/src/nodes/otel/OtelBoundaryNode.tsx +0 -224
- package/src/nodes/otel/OtelEventNode.tsx +0 -225
- package/src/nodes/otel/OtelResourceNode.tsx +0 -251
- package/src/nodes/otel/OtelScopeNode.tsx +0 -221
- package/src/nodes/otel/OtelSpanConventionNode.tsx +0 -295
- package/src/nodes/otel/index.ts +0 -23
- package/src/nodes/otel/shared/NodeBadges.tsx +0 -295
- package/src/nodes/otel/shared/NodeContent.tsx +0 -204
- package/src/nodes/otel/shared/index.ts +0 -8
- package/src/nodes/otel/shared/types.ts +0 -138
- package/src/nodes/otel/shared/useNodeBehavior.ts +0 -114
- package/src/stories/Audit/BoundaryNodes.stories.tsx +0 -385
- package/src/stories/Audit/CanvasEdgeTypes.stories.tsx +0 -1448
- package/src/stories/Audit/CanvasNodeTypes.stories.tsx +0 -1049
- package/src/stories/Audit/ColorPriority.stories.tsx +0 -895
- package/src/stories/Audit/DiamondBadges.stories.tsx +0 -629
- package/src/stories/Audit/NodeDimensionsTesting.stories.tsx +0 -724
- package/src/stories/Audit/NodeFieldsAudit.stories.tsx +0 -996
- package/src/stories/Audit/NodeFontSizeTesting.stories.tsx +0 -715
- package/src/stories/Audit/NodeShapes.stories.tsx +0 -1208
- package/src/stories/Audit/WideNodesTesting.stories.tsx +0 -1045
- package/src/stories/Components/DashboardRenderer.stories.tsx +0 -263
- package/src/stories/Components/GraphRenderer.stories.tsx +0 -3236
- package/src/stories/Components/MultiCanvasRenderer.stories.tsx +0 -370
- package/src/stories/Components/SequenceDiagram.stories.tsx +0 -255
- package/src/stories/Components/StateView.stories.tsx +0 -417
- package/src/stories/Components/TraceViewer.stories.tsx +0 -442
- package/src/stories/Components/WorkflowSequenceDiagram.stories.tsx +0 -802
- package/src/stories/Features/AnimationWorkshop.stories.tsx +0 -727
- package/src/stories/Features/ChangeTypeVisual.stories.tsx +0 -67
- package/src/stories/Features/EventDrivenAnimations.stories.tsx +0 -513
- package/src/stories/Features/MultiConfig.stories.tsx +0 -539
- package/src/stories/Layout/ElkEdgeRouting.stories.tsx +0 -539
- package/src/stories/Layout/GraphOrientation.stories.tsx +0 -500
- package/src/stories/Layout/MultiDirectionalConnections.stories.tsx +0 -352
- package/src/stories/Nodes/NodeDefinitionComparison.stories.tsx +0 -560
- package/src/stories/Nodes/NodeNameFallbacks.stories.tsx +0 -491
- package/src/stories/Nodes/NumericColors.stories.tsx +0 -440
- package/src/stories/OTEL/EventNameDisplay.stories.tsx +0 -694
- package/src/stories/OTEL/EventNameFallback.stories.tsx +0 -578
- package/src/stories/OTEL/OtelComponents.stories.tsx +0 -422
- package/src/stories/OTEL/OtelNodeTypesPrototype.stories.tsx +0 -806
- package/src/stories/OTEL/RawEventCards.stories.tsx +0 -57
- package/src/stories/OTEL/SpanBadges.stories.tsx +0 -840
- package/src/stories/OTEL/ValidationEventsCanvas.stories.tsx +0 -209
- package/src/stories/RealWorld/BacklogMdCanvases.stories.tsx +0 -721
- package/src/stories/RealWorld/FileCitySequence.stories.tsx +0 -516
- package/src/stories/RealWorld/RealCanvasFiles.stories.tsx +0 -336
- package/src/stories/__traces__/test-run.canvas.json +0 -241
- package/src/stories/data/activity-feed-analytics.dashboard.json +0 -300
- package/src/stories/data/file-city-images-transformed.otel.canvas.json +0 -295
- package/src/stories/data/file-city-workflows.json +0 -269
- package/src/stories/data/graph-converter-test-execution.json +0 -443
- package/src/stories/data/graph-converter-test.workflow.json +0 -105
- package/src/stories/data/graph-converter-validated-execution.json +0 -58
- package/src/utils/animationMapping.ts +0 -166
- package/src/utils/canvasBounds.ts +0 -146
- package/src/utils/graphConverter.ts +0 -148
- package/src/utils/iconResolver.tsx +0 -53
- package/src/utils/orientationUtils.ts +0 -73
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { MultiCanvasRenderer } from '../../components/MultiCanvasRenderer';
|
|
4
|
-
import type { MultiCanvasLayout } from '../../components/MultiCanvasRenderer';
|
|
5
|
-
import type { ExtendedCanvas } from '@principal-ai/subsystems-core';
|
|
6
|
-
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
7
|
-
|
|
8
|
-
const meta = {
|
|
9
|
-
title: 'Components/MultiCanvasRenderer',
|
|
10
|
-
component: MultiCanvasRenderer,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'fullscreen',
|
|
13
|
-
},
|
|
14
|
-
tags: ['autodocs'],
|
|
15
|
-
decorators: [
|
|
16
|
-
(Story) => (
|
|
17
|
-
<ThemeProvider theme={defaultEditorTheme}>
|
|
18
|
-
<div style={{ width: '100vw', height: '100vh' }}>
|
|
19
|
-
<Story />
|
|
20
|
-
</div>
|
|
21
|
-
</ThemeProvider>
|
|
22
|
-
),
|
|
23
|
-
],
|
|
24
|
-
} satisfies Meta<typeof MultiCanvasRenderer>;
|
|
25
|
-
|
|
26
|
-
export default meta;
|
|
27
|
-
type Story = StoryObj<typeof meta>;
|
|
28
|
-
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// Sample Canvases
|
|
31
|
-
// ============================================================================
|
|
32
|
-
|
|
33
|
-
const authFlowCanvas: ExtendedCanvas = {
|
|
34
|
-
nodes: [
|
|
35
|
-
{
|
|
36
|
-
id: 'login',
|
|
37
|
-
type: 'text',
|
|
38
|
-
x: 0,
|
|
39
|
-
y: 0,
|
|
40
|
-
width: 120,
|
|
41
|
-
height: 60,
|
|
42
|
-
text: 'Login',
|
|
43
|
-
color: '#4A90E2',
|
|
44
|
-
pv: { nodeType: 'process', shape: 'rectangle', icon: 'User' },
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: 'validate',
|
|
48
|
-
type: 'text',
|
|
49
|
-
x: 170,
|
|
50
|
-
y: 0,
|
|
51
|
-
width: 120,
|
|
52
|
-
height: 60,
|
|
53
|
-
text: 'Validate',
|
|
54
|
-
color: '#F5A623',
|
|
55
|
-
pv: { nodeType: 'process', shape: 'rectangle', icon: 'Shield' },
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: 'session',
|
|
59
|
-
type: 'text',
|
|
60
|
-
x: 340,
|
|
61
|
-
y: 0,
|
|
62
|
-
width: 120,
|
|
63
|
-
height: 60,
|
|
64
|
-
text: 'Session',
|
|
65
|
-
color: '#7ED321',
|
|
66
|
-
pv: { nodeType: 'data', shape: 'rectangle', icon: 'Key' },
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
edges: [
|
|
70
|
-
{ id: 'e1', fromNode: 'login', toNode: 'validate', pv: { edgeType: 'flow' } },
|
|
71
|
-
{ id: 'e2', fromNode: 'validate', toNode: 'session', pv: { edgeType: 'flow' } },
|
|
72
|
-
],
|
|
73
|
-
pv: {
|
|
74
|
-
version: '1.0.0',
|
|
75
|
-
name: 'Authentication Flow',
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const dataProcessingCanvas: ExtendedCanvas = {
|
|
80
|
-
nodes: [
|
|
81
|
-
{
|
|
82
|
-
id: 'input',
|
|
83
|
-
type: 'text',
|
|
84
|
-
x: 0,
|
|
85
|
-
y: 0,
|
|
86
|
-
width: 100,
|
|
87
|
-
height: 100,
|
|
88
|
-
text: 'Input',
|
|
89
|
-
color: '#7B68EE',
|
|
90
|
-
pv: { nodeType: 'data', shape: 'circle', icon: 'Download' },
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'transform',
|
|
94
|
-
type: 'text',
|
|
95
|
-
x: 150,
|
|
96
|
-
y: 15,
|
|
97
|
-
width: 140,
|
|
98
|
-
height: 70,
|
|
99
|
-
text: 'Transform',
|
|
100
|
-
color: '#4A90E2',
|
|
101
|
-
pv: { nodeType: 'process', shape: 'rectangle', icon: 'Settings' },
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'output',
|
|
105
|
-
type: 'text',
|
|
106
|
-
x: 340,
|
|
107
|
-
y: 0,
|
|
108
|
-
width: 100,
|
|
109
|
-
height: 100,
|
|
110
|
-
text: 'Output',
|
|
111
|
-
color: '#7B68EE',
|
|
112
|
-
pv: { nodeType: 'data', shape: 'circle', icon: 'Upload' },
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
edges: [
|
|
116
|
-
{ id: 'e1', fromNode: 'input', toNode: 'transform', pv: { edgeType: 'dataflow' } },
|
|
117
|
-
{ id: 'e2', fromNode: 'transform', toNode: 'output', pv: { edgeType: 'dataflow' } },
|
|
118
|
-
],
|
|
119
|
-
pv: {
|
|
120
|
-
version: '1.0.0',
|
|
121
|
-
name: 'Data Processing Pipeline',
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const notificationCanvas: ExtendedCanvas = {
|
|
126
|
-
nodes: [
|
|
127
|
-
{
|
|
128
|
-
id: 'event',
|
|
129
|
-
type: 'text',
|
|
130
|
-
x: 0,
|
|
131
|
-
y: 30,
|
|
132
|
-
width: 100,
|
|
133
|
-
height: 60,
|
|
134
|
-
text: 'Event',
|
|
135
|
-
color: '#F5A623',
|
|
136
|
-
pv: { nodeType: 'trigger', shape: 'rectangle', icon: 'Zap' },
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: 'router',
|
|
140
|
-
type: 'text',
|
|
141
|
-
x: 150,
|
|
142
|
-
y: 0,
|
|
143
|
-
width: 100,
|
|
144
|
-
height: 100,
|
|
145
|
-
text: 'Router',
|
|
146
|
-
color: '#4A90E2',
|
|
147
|
-
pv: { nodeType: 'process', shape: 'diamond', icon: 'GitBranch' },
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
id: 'email',
|
|
151
|
-
type: 'text',
|
|
152
|
-
x: 300,
|
|
153
|
-
y: -30,
|
|
154
|
-
width: 100,
|
|
155
|
-
height: 50,
|
|
156
|
-
text: 'Email',
|
|
157
|
-
color: '#7ED321',
|
|
158
|
-
pv: { nodeType: 'action', shape: 'rectangle', icon: 'Mail' },
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
id: 'sms',
|
|
162
|
-
type: 'text',
|
|
163
|
-
x: 300,
|
|
164
|
-
y: 40,
|
|
165
|
-
width: 100,
|
|
166
|
-
height: 50,
|
|
167
|
-
text: 'SMS',
|
|
168
|
-
color: '#7ED321',
|
|
169
|
-
pv: { nodeType: 'action', shape: 'rectangle', icon: 'MessageSquare' },
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
id: 'push',
|
|
173
|
-
type: 'text',
|
|
174
|
-
x: 300,
|
|
175
|
-
y: 110,
|
|
176
|
-
width: 100,
|
|
177
|
-
height: 50,
|
|
178
|
-
text: 'Push',
|
|
179
|
-
color: '#7ED321',
|
|
180
|
-
pv: { nodeType: 'action', shape: 'rectangle', icon: 'Bell' },
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
edges: [
|
|
184
|
-
{ id: 'e1', fromNode: 'event', toNode: 'router', pv: { edgeType: 'flow' } },
|
|
185
|
-
{ id: 'e2', fromNode: 'router', toNode: 'email', pv: { edgeType: 'flow' } },
|
|
186
|
-
{ id: 'e3', fromNode: 'router', toNode: 'sms', pv: { edgeType: 'flow' } },
|
|
187
|
-
{ id: 'e4', fromNode: 'router', toNode: 'push', pv: { edgeType: 'flow' } },
|
|
188
|
-
],
|
|
189
|
-
pv: {
|
|
190
|
-
version: '1.0.0',
|
|
191
|
-
name: 'Notification System',
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const monitoringCanvas: ExtendedCanvas = {
|
|
196
|
-
nodes: [
|
|
197
|
-
{
|
|
198
|
-
id: 'metrics',
|
|
199
|
-
type: 'text',
|
|
200
|
-
x: 0,
|
|
201
|
-
y: 0,
|
|
202
|
-
width: 100,
|
|
203
|
-
height: 60,
|
|
204
|
-
text: 'Metrics',
|
|
205
|
-
color: '#4A90E2',
|
|
206
|
-
pv: { nodeType: 'data', shape: 'rectangle', icon: 'BarChart2' },
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
id: 'alert',
|
|
210
|
-
type: 'text',
|
|
211
|
-
x: 150,
|
|
212
|
-
y: 0,
|
|
213
|
-
width: 100,
|
|
214
|
-
height: 60,
|
|
215
|
-
text: 'Alert',
|
|
216
|
-
color: '#D0021B',
|
|
217
|
-
pv: { nodeType: 'process', shape: 'rectangle', icon: 'AlertTriangle' },
|
|
218
|
-
},
|
|
219
|
-
],
|
|
220
|
-
edges: [
|
|
221
|
-
{ id: 'e1', fromNode: 'metrics', toNode: 'alert', pv: { edgeType: 'flow' } },
|
|
222
|
-
],
|
|
223
|
-
pv: {
|
|
224
|
-
version: '1.0.0',
|
|
225
|
-
name: 'Monitoring',
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// ============================================================================
|
|
230
|
-
// Stories
|
|
231
|
-
// ============================================================================
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Two canvases side by side on the same graph
|
|
235
|
-
*/
|
|
236
|
-
const twoCanvasLayout: MultiCanvasLayout = {
|
|
237
|
-
placements: [
|
|
238
|
-
{ canvasId: 'auth', canvas: authFlowCanvas, position: { x: 0, y: 0 } },
|
|
239
|
-
{ canvasId: 'data', canvas: dataProcessingCanvas, position: { x: 600, y: 0 } },
|
|
240
|
-
],
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
export const TwoCanvasesSideBySide: Story = {
|
|
244
|
-
args: {
|
|
245
|
-
layout: twoCanvasLayout,
|
|
246
|
-
showControls: true,
|
|
247
|
-
showBackground: true,
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Four canvases arranged in a 2x2 grid pattern
|
|
253
|
-
*/
|
|
254
|
-
const fourCanvasLayout: MultiCanvasLayout = {
|
|
255
|
-
placements: [
|
|
256
|
-
{ canvasId: 'auth', canvas: authFlowCanvas, position: { x: 0, y: 0 } },
|
|
257
|
-
{ canvasId: 'data', canvas: dataProcessingCanvas, position: { x: 600, y: 0 } },
|
|
258
|
-
{ canvasId: 'notify', canvas: notificationCanvas, position: { x: 0, y: 200 } },
|
|
259
|
-
{ canvasId: 'monitor', canvas: monitoringCanvas, position: { x: 600, y: 200 } },
|
|
260
|
-
],
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export const FourCanvasesGrid: Story = {
|
|
264
|
-
args: {
|
|
265
|
-
layout: fourCanvasLayout,
|
|
266
|
-
showControls: true,
|
|
267
|
-
showBackground: true,
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Canvases stacked vertically
|
|
273
|
-
*/
|
|
274
|
-
const verticalLayout: MultiCanvasLayout = {
|
|
275
|
-
placements: [
|
|
276
|
-
{ canvasId: 'auth', canvas: authFlowCanvas, position: { x: 0, y: 0 } },
|
|
277
|
-
{ canvasId: 'data', canvas: dataProcessingCanvas, position: { x: 0, y: 150 } },
|
|
278
|
-
{ canvasId: 'notify', canvas: notificationCanvas, position: { x: 0, y: 300 } },
|
|
279
|
-
],
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export const VerticalStack: Story = {
|
|
283
|
-
args: {
|
|
284
|
-
layout: verticalLayout,
|
|
285
|
-
showControls: true,
|
|
286
|
-
showBackground: true,
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Single canvas (baseline comparison)
|
|
292
|
-
*/
|
|
293
|
-
const singleCanvasLayout: MultiCanvasLayout = {
|
|
294
|
-
placements: [
|
|
295
|
-
{ canvasId: 'notify', canvas: notificationCanvas, position: { x: 0, y: 0 } },
|
|
296
|
-
],
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
export const SingleCanvas: Story = {
|
|
300
|
-
args: {
|
|
301
|
-
layout: singleCanvasLayout,
|
|
302
|
-
showControls: true,
|
|
303
|
-
showBackground: true,
|
|
304
|
-
},
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* With minimap enabled to navigate the combined view
|
|
309
|
-
*/
|
|
310
|
-
export const WithMinimap: Story = {
|
|
311
|
-
args: {
|
|
312
|
-
layout: fourCanvasLayout,
|
|
313
|
-
showControls: true,
|
|
314
|
-
showMinimap: true,
|
|
315
|
-
showBackground: true,
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Without group borders - just the nodes merged together
|
|
321
|
-
*/
|
|
322
|
-
export const WithoutGroups: Story = {
|
|
323
|
-
args: {
|
|
324
|
-
layout: fourCanvasLayout,
|
|
325
|
-
showControls: true,
|
|
326
|
-
showBackground: true,
|
|
327
|
-
showGroups: false,
|
|
328
|
-
},
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Draggable groups - drag the group borders to rearrange canvases
|
|
333
|
-
*/
|
|
334
|
-
export const DraggableGroups: Story = {
|
|
335
|
-
render: () => {
|
|
336
|
-
const [layout, setLayout] = React.useState<MultiCanvasLayout>(fourCanvasLayout);
|
|
337
|
-
|
|
338
|
-
const handleLayoutChange = React.useCallback((newLayout: MultiCanvasLayout) => {
|
|
339
|
-
console.log('Layout changed:', newLayout.placements.map(p => ({
|
|
340
|
-
canvasId: p.canvasId,
|
|
341
|
-
position: p.position,
|
|
342
|
-
})));
|
|
343
|
-
setLayout(newLayout);
|
|
344
|
-
}, []);
|
|
345
|
-
|
|
346
|
-
return (
|
|
347
|
-
<div style={{ width: '100%', height: '100%' }}>
|
|
348
|
-
<div style={{
|
|
349
|
-
position: 'absolute',
|
|
350
|
-
top: 10,
|
|
351
|
-
left: 10,
|
|
352
|
-
zIndex: 100,
|
|
353
|
-
background: 'rgba(0,0,0,0.7)',
|
|
354
|
-
color: 'white',
|
|
355
|
-
padding: '8px 12px',
|
|
356
|
-
borderRadius: 4,
|
|
357
|
-
fontSize: 12,
|
|
358
|
-
}}>
|
|
359
|
-
Drag the group borders to move entire canvases
|
|
360
|
-
</div>
|
|
361
|
-
<MultiCanvasRenderer
|
|
362
|
-
layout={layout}
|
|
363
|
-
onLayoutChange={handleLayoutChange}
|
|
364
|
-
showControls
|
|
365
|
-
showBackground
|
|
366
|
-
/>
|
|
367
|
-
</div>
|
|
368
|
-
);
|
|
369
|
-
},
|
|
370
|
-
};
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { SequenceDiagramRenderer } from '../../components/SequenceDiagramRenderer';
|
|
4
|
-
import type { SequenceEvent, SequenceEdge } from '../../hooks/useSequenceLayout';
|
|
5
|
-
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
6
|
-
|
|
7
|
-
const meta = {
|
|
8
|
-
title: 'Components/SequenceDiagram',
|
|
9
|
-
component: SequenceDiagramRenderer,
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: 'fullscreen',
|
|
12
|
-
},
|
|
13
|
-
tags: ['autodocs'],
|
|
14
|
-
decorators: [
|
|
15
|
-
(Story) => (
|
|
16
|
-
<ThemeProvider theme={defaultEditorTheme}>
|
|
17
|
-
<div style={{ padding: 20, height: '100vh', boxSizing: 'border-box' }}>
|
|
18
|
-
<Story />
|
|
19
|
-
</div>
|
|
20
|
-
</ThemeProvider>
|
|
21
|
-
),
|
|
22
|
-
],
|
|
23
|
-
} satisfies Meta<typeof SequenceDiagramRenderer>;
|
|
24
|
-
|
|
25
|
-
export default meta;
|
|
26
|
-
type Story = StoryObj<typeof meta>;
|
|
27
|
-
|
|
28
|
-
// ============================================================================
|
|
29
|
-
// Sample Data
|
|
30
|
-
// ============================================================================
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Simple authentication flow across two namespaces
|
|
34
|
-
*/
|
|
35
|
-
const simpleAuthFlow: { events: SequenceEvent[]; edges: SequenceEdge[] } = {
|
|
36
|
-
events: [
|
|
37
|
-
{ id: '1', name: 'auth.validation.started', label: 'Validation Started' },
|
|
38
|
-
{ id: '2', name: 'database.query.findUser', label: 'Find User' },
|
|
39
|
-
{ id: '3', name: 'auth.validation.completed', label: 'Validation Completed' },
|
|
40
|
-
{ id: '4', name: 'auth.token.generated', label: 'Token Generated' },
|
|
41
|
-
],
|
|
42
|
-
edges: [
|
|
43
|
-
{ id: 'e1', fromEvent: '1', toEvent: '2' },
|
|
44
|
-
{ id: 'e2', fromEvent: '2', toEvent: '3' },
|
|
45
|
-
{ id: 'e3', fromEvent: '3', toEvent: '4' },
|
|
46
|
-
],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* More complex flow with multiple actors
|
|
51
|
-
*/
|
|
52
|
-
const complexOrderFlow: { events: SequenceEvent[]; edges: SequenceEdge[] } = {
|
|
53
|
-
events: [
|
|
54
|
-
{ id: '1', name: 'api.request.received', label: 'Request Received' },
|
|
55
|
-
{ id: '2', name: 'auth.session.validate', label: 'Validate Session' },
|
|
56
|
-
{ id: '3', name: 'order.validation.started', label: 'Validate Order' },
|
|
57
|
-
{ id: '4', name: 'inventory.check.availability', label: 'Check Stock' },
|
|
58
|
-
{ id: '5', name: 'order.validation.completed', label: 'Order Valid' },
|
|
59
|
-
{ id: '6', name: 'payment.charge.initiated', label: 'Initiate Charge' },
|
|
60
|
-
{ id: '7', name: 'payment.charge.completed', label: 'Charge Complete' },
|
|
61
|
-
{ id: '8', name: 'order.fulfillment.started', label: 'Start Fulfillment' },
|
|
62
|
-
{ id: '9', name: 'inventory.reserve.items', label: 'Reserve Items' },
|
|
63
|
-
{ id: '10', name: 'notification.email.sent', label: 'Confirmation Email' },
|
|
64
|
-
{ id: '11', name: 'api.response.sent', label: 'Response Sent' },
|
|
65
|
-
],
|
|
66
|
-
edges: [
|
|
67
|
-
{ id: 'e1', fromEvent: '1', toEvent: '2' },
|
|
68
|
-
{ id: 'e2', fromEvent: '2', toEvent: '3' },
|
|
69
|
-
{ id: 'e3', fromEvent: '3', toEvent: '4' },
|
|
70
|
-
{ id: 'e4', fromEvent: '4', toEvent: '5' },
|
|
71
|
-
{ id: 'e5', fromEvent: '5', toEvent: '6' },
|
|
72
|
-
{ id: 'e6', fromEvent: '6', toEvent: '7' },
|
|
73
|
-
{ id: 'e7', fromEvent: '7', toEvent: '8' },
|
|
74
|
-
{ id: 'e8', fromEvent: '8', toEvent: '9' },
|
|
75
|
-
{ id: 'e9', fromEvent: '9', toEvent: '10' },
|
|
76
|
-
{ id: 'e10', fromEvent: '10', toEvent: '11' },
|
|
77
|
-
],
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Flow with hierarchical namespaces (sub-namespaces)
|
|
82
|
-
*/
|
|
83
|
-
const hierarchicalFlow: { events: SequenceEvent[]; edges: SequenceEdge[] } = {
|
|
84
|
-
events: [
|
|
85
|
-
{ id: '1', name: 'auth.login.started', label: 'Login Started' },
|
|
86
|
-
{ id: '2', name: 'auth.login.validation.credentials', label: 'Check Credentials' },
|
|
87
|
-
{ id: '3', name: 'auth.login.validation.mfa', label: 'Check MFA' },
|
|
88
|
-
{ id: '4', name: 'auth.login.session.create', label: 'Create Session' },
|
|
89
|
-
{ id: '5', name: 'auth.login.completed', label: 'Login Completed' },
|
|
90
|
-
],
|
|
91
|
-
edges: [
|
|
92
|
-
{ id: 'e1', fromEvent: '1', toEvent: '2' },
|
|
93
|
-
{ id: 'e2', fromEvent: '2', toEvent: '3' },
|
|
94
|
-
{ id: 'e3', fromEvent: '3', toEvent: '4' },
|
|
95
|
-
{ id: 'e4', fromEvent: '4', toEvent: '5' },
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Flow with same-namespace sequential events
|
|
101
|
-
*/
|
|
102
|
-
const sameNamespaceFlow: { events: SequenceEvent[]; edges: SequenceEdge[] } = {
|
|
103
|
-
events: [
|
|
104
|
-
{ id: '1', name: 'processor.step1', label: 'Step 1' },
|
|
105
|
-
{ id: '2', name: 'processor.step2', label: 'Step 2' },
|
|
106
|
-
{ id: '3', name: 'processor.step3', label: 'Step 3' },
|
|
107
|
-
{ id: '4', name: 'external.callback', label: 'External Callback' },
|
|
108
|
-
{ id: '5', name: 'processor.step4', label: 'Step 4' },
|
|
109
|
-
],
|
|
110
|
-
edges: [
|
|
111
|
-
{ id: 'e1', fromEvent: '1', toEvent: '2' },
|
|
112
|
-
{ id: 'e2', fromEvent: '2', toEvent: '3' },
|
|
113
|
-
{ id: 'e3', fromEvent: '3', toEvent: '4' },
|
|
114
|
-
{ id: 'e4', fromEvent: '4', toEvent: '5' },
|
|
115
|
-
],
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// ============================================================================
|
|
119
|
-
// Stories
|
|
120
|
-
// ============================================================================
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Basic two-namespace flow showing authentication
|
|
124
|
-
*/
|
|
125
|
-
export const SimpleFlow: Story = {
|
|
126
|
-
args: {
|
|
127
|
-
events: simpleAuthFlow.events,
|
|
128
|
-
edges: simpleAuthFlow.edges,
|
|
129
|
-
height: 500,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Complex multi-actor e-commerce order flow
|
|
135
|
-
*/
|
|
136
|
-
export const ComplexFlow: Story = {
|
|
137
|
-
args: {
|
|
138
|
-
events: complexOrderFlow.events,
|
|
139
|
-
edges: complexOrderFlow.edges,
|
|
140
|
-
height: 700,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Flow with hierarchical namespaces. By default, lanes group at the first
|
|
146
|
-
* dotted segment — drill in via `openedNamespaces` (see `WithDrillDown`).
|
|
147
|
-
*/
|
|
148
|
-
export const HierarchicalNamespaces: Story = {
|
|
149
|
-
args: {
|
|
150
|
-
events: hierarchicalFlow.events,
|
|
151
|
-
edges: hierarchicalFlow.edges,
|
|
152
|
-
height: 500,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Flow testing same-namespace edge rendering
|
|
158
|
-
*/
|
|
159
|
-
export const SameNamespaceEdges: Story = {
|
|
160
|
-
args: {
|
|
161
|
-
events: sameNamespaceFlow.events,
|
|
162
|
-
edges: sameNamespaceFlow.edges,
|
|
163
|
-
height: 500,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Interactive drill-down. Click ▶ on a lane header to split it into
|
|
169
|
-
* its sub-namespaces; click ‹ on a child lane to step back out.
|
|
170
|
-
*/
|
|
171
|
-
export const WithDrillDown: Story = {
|
|
172
|
-
render: () => {
|
|
173
|
-
const [opened, setOpened] = useState<string[]>([]);
|
|
174
|
-
|
|
175
|
-
const handleToggle = (namespace: string) => {
|
|
176
|
-
setOpened((prev) =>
|
|
177
|
-
prev.includes(namespace)
|
|
178
|
-
? prev.filter((n) => n !== namespace)
|
|
179
|
-
: [...prev, namespace]
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
<div>
|
|
185
|
-
<div style={{ marginBottom: 16 }}>
|
|
186
|
-
<strong>Opened namespaces:</strong>{' '}
|
|
187
|
-
{opened.length ? opened.join(', ') : 'none'}
|
|
188
|
-
<br />
|
|
189
|
-
<small>▶ on a lane header drills in. ‹ on a child lane steps back out.</small>
|
|
190
|
-
</div>
|
|
191
|
-
<SequenceDiagramRenderer
|
|
192
|
-
events={hierarchicalFlow.events}
|
|
193
|
-
edges={hierarchicalFlow.edges}
|
|
194
|
-
height={500}
|
|
195
|
-
layoutOptions={{ openedNamespaces: opened }}
|
|
196
|
-
onToggleNamespace={handleToggle}
|
|
197
|
-
/>
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Custom layout options - wider lanes and more spacing
|
|
205
|
-
*/
|
|
206
|
-
export const CustomLayout: Story = {
|
|
207
|
-
args: {
|
|
208
|
-
events: simpleAuthFlow.events,
|
|
209
|
-
edges: simpleAuthFlow.edges,
|
|
210
|
-
height: 500,
|
|
211
|
-
layoutOptions: {
|
|
212
|
-
laneWidth: 250,
|
|
213
|
-
laneGap: 80,
|
|
214
|
-
eventSpacing: 100,
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Compact layout for smaller diagrams
|
|
221
|
-
*/
|
|
222
|
-
export const CompactLayout: Story = {
|
|
223
|
-
args: {
|
|
224
|
-
events: simpleAuthFlow.events,
|
|
225
|
-
edges: simpleAuthFlow.edges,
|
|
226
|
-
height: 400,
|
|
227
|
-
layoutOptions: {
|
|
228
|
-
laneWidth: 150,
|
|
229
|
-
laneGap: 30,
|
|
230
|
-
eventSpacing: 50,
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Empty state
|
|
237
|
-
*/
|
|
238
|
-
export const EmptyDiagram: Story = {
|
|
239
|
-
args: {
|
|
240
|
-
events: [],
|
|
241
|
-
edges: [],
|
|
242
|
-
height: 300,
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Single event (edge case)
|
|
248
|
-
*/
|
|
249
|
-
export const SingleEvent: Story = {
|
|
250
|
-
args: {
|
|
251
|
-
events: [{ id: '1', name: 'system.startup', label: 'System Startup' }],
|
|
252
|
-
edges: [],
|
|
253
|
-
height: 300,
|
|
254
|
-
},
|
|
255
|
-
};
|