@principal-ai/principal-view-react 0.6.6

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 (96) hide show
  1. package/README.md +111 -0
  2. package/dist/components/ConfigurationSelector.d.ts +37 -0
  3. package/dist/components/ConfigurationSelector.d.ts.map +1 -0
  4. package/dist/components/ConfigurationSelector.js +67 -0
  5. package/dist/components/ConfigurationSelector.js.map +1 -0
  6. package/dist/components/EdgeInfoPanel.d.ts +16 -0
  7. package/dist/components/EdgeInfoPanel.d.ts.map +1 -0
  8. package/dist/components/EdgeInfoPanel.js +85 -0
  9. package/dist/components/EdgeInfoPanel.js.map +1 -0
  10. package/dist/components/EventLog.d.ts +20 -0
  11. package/dist/components/EventLog.d.ts.map +1 -0
  12. package/dist/components/EventLog.js +13 -0
  13. package/dist/components/EventLog.js.map +1 -0
  14. package/dist/components/EventLog.test.d.ts +2 -0
  15. package/dist/components/EventLog.test.d.ts.map +1 -0
  16. package/dist/components/EventLog.test.js +73 -0
  17. package/dist/components/EventLog.test.js.map +1 -0
  18. package/dist/components/GraphRenderer.d.ts +121 -0
  19. package/dist/components/GraphRenderer.d.ts.map +1 -0
  20. package/dist/components/GraphRenderer.js +809 -0
  21. package/dist/components/GraphRenderer.js.map +1 -0
  22. package/dist/components/GraphRenderer.test.d.ts +2 -0
  23. package/dist/components/GraphRenderer.test.d.ts.map +1 -0
  24. package/dist/components/GraphRenderer.test.js +88 -0
  25. package/dist/components/GraphRenderer.test.js.map +1 -0
  26. package/dist/components/MetricsDashboard.d.ts +14 -0
  27. package/dist/components/MetricsDashboard.d.ts.map +1 -0
  28. package/dist/components/MetricsDashboard.js +13 -0
  29. package/dist/components/MetricsDashboard.js.map +1 -0
  30. package/dist/components/NodeInfoPanel.d.ts +21 -0
  31. package/dist/components/NodeInfoPanel.d.ts.map +1 -0
  32. package/dist/components/NodeInfoPanel.js +217 -0
  33. package/dist/components/NodeInfoPanel.js.map +1 -0
  34. package/dist/edges/CustomEdge.d.ts +16 -0
  35. package/dist/edges/CustomEdge.d.ts.map +1 -0
  36. package/dist/edges/CustomEdge.js +200 -0
  37. package/dist/edges/CustomEdge.js.map +1 -0
  38. package/dist/edges/GenericEdge.d.ts +18 -0
  39. package/dist/edges/GenericEdge.d.ts.map +1 -0
  40. package/dist/edges/GenericEdge.js +14 -0
  41. package/dist/edges/GenericEdge.js.map +1 -0
  42. package/dist/hooks/usePathBasedEvents.d.ts +42 -0
  43. package/dist/hooks/usePathBasedEvents.d.ts.map +1 -0
  44. package/dist/hooks/usePathBasedEvents.js +122 -0
  45. package/dist/hooks/usePathBasedEvents.js.map +1 -0
  46. package/dist/index.d.ts +33 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +41 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/nodes/CustomNode.d.ts +18 -0
  51. package/dist/nodes/CustomNode.d.ts.map +1 -0
  52. package/dist/nodes/CustomNode.js +298 -0
  53. package/dist/nodes/CustomNode.js.map +1 -0
  54. package/dist/nodes/GenericNode.d.ts +20 -0
  55. package/dist/nodes/GenericNode.d.ts.map +1 -0
  56. package/dist/nodes/GenericNode.js +24 -0
  57. package/dist/nodes/GenericNode.js.map +1 -0
  58. package/dist/utils/animationMapping.d.ts +53 -0
  59. package/dist/utils/animationMapping.d.ts.map +1 -0
  60. package/dist/utils/animationMapping.js +133 -0
  61. package/dist/utils/animationMapping.js.map +1 -0
  62. package/dist/utils/graphConverter.d.ts +22 -0
  63. package/dist/utils/graphConverter.d.ts.map +1 -0
  64. package/dist/utils/graphConverter.js +176 -0
  65. package/dist/utils/graphConverter.js.map +1 -0
  66. package/dist/utils/iconResolver.d.ts +29 -0
  67. package/dist/utils/iconResolver.d.ts.map +1 -0
  68. package/dist/utils/iconResolver.js +68 -0
  69. package/dist/utils/iconResolver.js.map +1 -0
  70. package/package.json +61 -0
  71. package/src/components/ConfigurationSelector.tsx +147 -0
  72. package/src/components/EdgeInfoPanel.tsx +198 -0
  73. package/src/components/EventLog.test.tsx +85 -0
  74. package/src/components/EventLog.tsx +51 -0
  75. package/src/components/GraphRenderer.test.tsx +118 -0
  76. package/src/components/GraphRenderer.tsx +1222 -0
  77. package/src/components/MetricsDashboard.tsx +40 -0
  78. package/src/components/NodeInfoPanel.tsx +425 -0
  79. package/src/edges/CustomEdge.tsx +344 -0
  80. package/src/edges/GenericEdge.tsx +40 -0
  81. package/src/hooks/usePathBasedEvents.ts +182 -0
  82. package/src/index.ts +67 -0
  83. package/src/nodes/CustomNode.tsx +432 -0
  84. package/src/nodes/GenericNode.tsx +54 -0
  85. package/src/stories/AnimationWorkshop.stories.tsx +608 -0
  86. package/src/stories/EventDrivenAnimations.stories.tsx +499 -0
  87. package/src/stories/EventLog.stories.tsx +161 -0
  88. package/src/stories/GraphRenderer.stories.tsx +628 -0
  89. package/src/stories/Introduction.mdx +51 -0
  90. package/src/stories/MetricsDashboard.stories.tsx +227 -0
  91. package/src/stories/MultiConfig.stories.tsx +531 -0
  92. package/src/stories/MultiDirectionalConnections.stories.tsx +345 -0
  93. package/src/stories/NodeShapes.stories.tsx +769 -0
  94. package/src/utils/animationMapping.ts +170 -0
  95. package/src/utils/graphConverter.ts +218 -0
  96. package/src/utils/iconResolver.tsx +49 -0
@@ -0,0 +1,345 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { GraphRenderer } from '../components/GraphRenderer';
3
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
4
+
5
+ const meta = {
6
+ title: 'Features/Multi-Directional Connections',
7
+ component: GraphRenderer,
8
+ parameters: {
9
+ layout: 'fullscreen',
10
+ docs: {
11
+ description: {
12
+ component:
13
+ 'Demonstrates multi-directional edge connections (top, bottom, left, right) and clickable edges with information panels.',
14
+ },
15
+ },
16
+ },
17
+ tags: ['autodocs'],
18
+ } satisfies Meta<typeof GraphRenderer>;
19
+
20
+ export default meta;
21
+ type Story = StoryObj<typeof meta>;
22
+
23
+ // Canvas with multi-directional connections and rich metadata
24
+ const multiDirectionalCanvas: ExtendedCanvas = {
25
+ nodes: [
26
+ {
27
+ id: 'gateway-1',
28
+ type: 'text',
29
+ x: 400,
30
+ y: 50,
31
+ width: 100,
32
+ height: 100,
33
+ text: 'API Gateway',
34
+ color: '#06B6D4',
35
+ vv: {
36
+ nodeType: 'gateway',
37
+ shape: 'diamond',
38
+ icon: 'Network',
39
+ },
40
+ },
41
+ {
42
+ id: 'service-1',
43
+ type: 'text',
44
+ x: 200,
45
+ y: 200,
46
+ width: 140,
47
+ height: 80,
48
+ text: 'Auth Service',
49
+ color: '#4A90E2',
50
+ vv: {
51
+ nodeType: 'service',
52
+ shape: 'rectangle',
53
+ icon: 'Server',
54
+ states: {
55
+ active: { color: '#22C55E', label: 'Active' },
56
+ idle: { color: '#EAB308', label: 'Idle' },
57
+ error: { color: '#EF4444', label: 'Error' },
58
+ },
59
+ },
60
+ },
61
+ {
62
+ id: 'service-2',
63
+ type: 'text',
64
+ x: 600,
65
+ y: 200,
66
+ width: 140,
67
+ height: 80,
68
+ text: 'API Service',
69
+ color: '#4A90E2',
70
+ vv: {
71
+ nodeType: 'service',
72
+ shape: 'rectangle',
73
+ icon: 'Server',
74
+ states: {
75
+ active: { color: '#22C55E', label: 'Active' },
76
+ idle: { color: '#EAB308', label: 'Idle' },
77
+ error: { color: '#EF4444', label: 'Error' },
78
+ },
79
+ },
80
+ },
81
+ {
82
+ id: 'cache-1',
83
+ type: 'text',
84
+ x: 100,
85
+ y: 400,
86
+ width: 120,
87
+ height: 100,
88
+ text: 'Redis Cache',
89
+ color: '#F59E0B',
90
+ vv: {
91
+ nodeType: 'cache',
92
+ shape: 'hexagon',
93
+ icon: 'Zap',
94
+ },
95
+ },
96
+ {
97
+ id: 'database-1',
98
+ type: 'text',
99
+ x: 400,
100
+ y: 400,
101
+ width: 100,
102
+ height: 100,
103
+ text: 'PostgreSQL',
104
+ color: '#7B68EE',
105
+ vv: {
106
+ nodeType: 'database',
107
+ shape: 'circle',
108
+ icon: 'Database',
109
+ },
110
+ },
111
+ {
112
+ id: 'service-3',
113
+ type: 'text',
114
+ x: 700,
115
+ y: 400,
116
+ width: 140,
117
+ height: 80,
118
+ text: 'Notification Service',
119
+ color: '#4A90E2',
120
+ vv: {
121
+ nodeType: 'service',
122
+ shape: 'rectangle',
123
+ icon: 'Bell',
124
+ states: {
125
+ active: { color: '#22C55E', label: 'Active' },
126
+ idle: { color: '#EAB308', label: 'Idle' },
127
+ error: { color: '#EF4444', label: 'Error' },
128
+ },
129
+ },
130
+ },
131
+ ],
132
+ edges: [
133
+ // From top to services (top -> bottom connections)
134
+ {
135
+ id: 'edge-1',
136
+ fromNode: 'gateway-1',
137
+ toNode: 'service-1',
138
+ fromSide: 'bottom',
139
+ toSide: 'top',
140
+ label: 'POST /auth/login',
141
+ vv: { edgeType: 'http' },
142
+ },
143
+ {
144
+ id: 'edge-2',
145
+ fromNode: 'gateway-1',
146
+ toNode: 'service-2',
147
+ fromSide: 'bottom',
148
+ toSide: 'top',
149
+ label: 'GET /api/users',
150
+ vv: { edgeType: 'http' },
151
+ },
152
+ // Horizontal connections (left <-> right)
153
+ {
154
+ id: 'edge-3',
155
+ fromNode: 'service-1',
156
+ toNode: 'service-2',
157
+ fromSide: 'right',
158
+ toSide: 'left',
159
+ label: '/internal/validate',
160
+ vv: { edgeType: 'http' },
161
+ },
162
+ // Services to data layer
163
+ {
164
+ id: 'edge-4',
165
+ fromNode: 'service-1',
166
+ toNode: 'cache-1',
167
+ fromSide: 'bottom',
168
+ toSide: 'top',
169
+ label: 'GET',
170
+ vv: { edgeType: 'cache_access' },
171
+ },
172
+ {
173
+ id: 'edge-5',
174
+ fromNode: 'service-1',
175
+ toNode: 'database-1',
176
+ fromSide: 'bottom',
177
+ toSide: 'top',
178
+ label: 'SELECT users',
179
+ vv: { edgeType: 'database_query' },
180
+ },
181
+ {
182
+ id: 'edge-6',
183
+ fromNode: 'service-2',
184
+ toNode: 'database-1',
185
+ fromSide: 'bottom',
186
+ toSide: 'top',
187
+ label: 'UPDATE sessions',
188
+ vv: { edgeType: 'database_query' },
189
+ },
190
+ {
191
+ id: 'edge-7',
192
+ fromNode: 'service-2',
193
+ toNode: 'service-3',
194
+ fromSide: 'right',
195
+ toSide: 'left',
196
+ label: 'POST /notify',
197
+ vv: { edgeType: 'http' },
198
+ },
199
+ // Cache to database (horizontal)
200
+ {
201
+ id: 'edge-8',
202
+ fromNode: 'cache-1',
203
+ toNode: 'database-1',
204
+ fromSide: 'right',
205
+ toSide: 'left',
206
+ label: 'cache miss',
207
+ vv: { edgeType: 'database_query' },
208
+ },
209
+ ],
210
+ vv: {
211
+ version: '1.0.0',
212
+ name: 'Multi-Directional Connection Demo',
213
+ description: 'Showcasing edges connecting from all sides with rich metadata',
214
+ edgeTypes: {
215
+ http: {
216
+ style: 'solid',
217
+ color: '#22C55E',
218
+ width: 2,
219
+ directed: true,
220
+ },
221
+ database_query: {
222
+ style: 'dashed',
223
+ color: '#7B68EE',
224
+ width: 2,
225
+ directed: true,
226
+ },
227
+ cache_access: {
228
+ style: 'dotted',
229
+ color: '#F59E0B',
230
+ width: 2,
231
+ directed: true,
232
+ },
233
+ websocket: {
234
+ style: 'animated',
235
+ color: '#06B6D4',
236
+ width: 3,
237
+ directed: false,
238
+ },
239
+ },
240
+ },
241
+ };
242
+
243
+ // Canvas with violation highlighting
244
+ const canvasWithViolations: ExtendedCanvas = {
245
+ ...multiDirectionalCanvas,
246
+ vv: {
247
+ ...multiDirectionalCanvas.vv!,
248
+ name: 'Connection Demo with Violations',
249
+ },
250
+ };
251
+
252
+ // Minimal view canvas
253
+ const minimalCanvas: ExtendedCanvas = {
254
+ nodes: multiDirectionalCanvas.nodes!.slice(0, 4),
255
+ edges: multiDirectionalCanvas.edges!.slice(0, 4),
256
+ vv: {
257
+ ...multiDirectionalCanvas.vv!,
258
+ name: 'Minimal View',
259
+ },
260
+ };
261
+
262
+ // Complex mesh with additional gateway
263
+ const complexMeshCanvas: ExtendedCanvas = {
264
+ nodes: [
265
+ ...multiDirectionalCanvas.nodes!,
266
+ {
267
+ id: 'gateway-2',
268
+ type: 'text',
269
+ x: 400,
270
+ y: 600,
271
+ width: 100,
272
+ height: 100,
273
+ text: 'Internal Gateway',
274
+ color: '#06B6D4',
275
+ vv: {
276
+ nodeType: 'gateway',
277
+ shape: 'diamond',
278
+ icon: 'Network',
279
+ },
280
+ },
281
+ ],
282
+ edges: [
283
+ ...multiDirectionalCanvas.edges!,
284
+ {
285
+ id: 'edge-9',
286
+ fromNode: 'database-1',
287
+ toNode: 'gateway-2',
288
+ fromSide: 'bottom',
289
+ toSide: 'top',
290
+ label: 'wss',
291
+ vv: { edgeType: 'websocket' },
292
+ },
293
+ ],
294
+ vv: {
295
+ ...multiDirectionalCanvas.vv!,
296
+ name: 'Complex Mesh',
297
+ },
298
+ };
299
+
300
+ export const Default: Story = {
301
+ args: {
302
+ canvas: multiDirectionalCanvas,
303
+ width: '100%',
304
+ height: '800px',
305
+ showMinimap: true,
306
+ showControls: true,
307
+ showBackground: true,
308
+ },
309
+ };
310
+
311
+ export const WithViolations: Story = {
312
+ args: {
313
+ canvas: canvasWithViolations,
314
+ violations: [
315
+ {
316
+ id: 'v1',
317
+ severity: 'error',
318
+ type: 'connection',
319
+ description: 'Unauthorized connection detected',
320
+ context: { edgeId: 'edge-3' },
321
+ },
322
+ ],
323
+ width: '100%',
324
+ height: '800px',
325
+ },
326
+ };
327
+
328
+ export const MinimalView: Story = {
329
+ args: {
330
+ canvas: minimalCanvas,
331
+ width: '100%',
332
+ height: '600px',
333
+ showMinimap: false,
334
+ showControls: true,
335
+ showBackground: true,
336
+ },
337
+ };
338
+
339
+ export const ComplexMesh: Story = {
340
+ args: {
341
+ canvas: complexMeshCanvas,
342
+ width: '100%',
343
+ height: '900px',
344
+ },
345
+ };