@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.
- package/README.md +111 -0
- package/dist/components/ConfigurationSelector.d.ts +37 -0
- package/dist/components/ConfigurationSelector.d.ts.map +1 -0
- package/dist/components/ConfigurationSelector.js +67 -0
- package/dist/components/ConfigurationSelector.js.map +1 -0
- package/dist/components/EdgeInfoPanel.d.ts +16 -0
- package/dist/components/EdgeInfoPanel.d.ts.map +1 -0
- package/dist/components/EdgeInfoPanel.js +85 -0
- package/dist/components/EdgeInfoPanel.js.map +1 -0
- package/dist/components/EventLog.d.ts +20 -0
- package/dist/components/EventLog.d.ts.map +1 -0
- package/dist/components/EventLog.js +13 -0
- package/dist/components/EventLog.js.map +1 -0
- package/dist/components/EventLog.test.d.ts +2 -0
- package/dist/components/EventLog.test.d.ts.map +1 -0
- package/dist/components/EventLog.test.js +73 -0
- package/dist/components/EventLog.test.js.map +1 -0
- package/dist/components/GraphRenderer.d.ts +121 -0
- package/dist/components/GraphRenderer.d.ts.map +1 -0
- package/dist/components/GraphRenderer.js +809 -0
- package/dist/components/GraphRenderer.js.map +1 -0
- package/dist/components/GraphRenderer.test.d.ts +2 -0
- package/dist/components/GraphRenderer.test.d.ts.map +1 -0
- package/dist/components/GraphRenderer.test.js +88 -0
- package/dist/components/GraphRenderer.test.js.map +1 -0
- package/dist/components/MetricsDashboard.d.ts +14 -0
- package/dist/components/MetricsDashboard.d.ts.map +1 -0
- package/dist/components/MetricsDashboard.js +13 -0
- package/dist/components/MetricsDashboard.js.map +1 -0
- package/dist/components/NodeInfoPanel.d.ts +21 -0
- package/dist/components/NodeInfoPanel.d.ts.map +1 -0
- package/dist/components/NodeInfoPanel.js +217 -0
- package/dist/components/NodeInfoPanel.js.map +1 -0
- package/dist/edges/CustomEdge.d.ts +16 -0
- package/dist/edges/CustomEdge.d.ts.map +1 -0
- package/dist/edges/CustomEdge.js +200 -0
- package/dist/edges/CustomEdge.js.map +1 -0
- package/dist/edges/GenericEdge.d.ts +18 -0
- package/dist/edges/GenericEdge.d.ts.map +1 -0
- package/dist/edges/GenericEdge.js +14 -0
- package/dist/edges/GenericEdge.js.map +1 -0
- package/dist/hooks/usePathBasedEvents.d.ts +42 -0
- package/dist/hooks/usePathBasedEvents.d.ts.map +1 -0
- package/dist/hooks/usePathBasedEvents.js +122 -0
- package/dist/hooks/usePathBasedEvents.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/CustomNode.d.ts +18 -0
- package/dist/nodes/CustomNode.d.ts.map +1 -0
- package/dist/nodes/CustomNode.js +298 -0
- package/dist/nodes/CustomNode.js.map +1 -0
- package/dist/nodes/GenericNode.d.ts +20 -0
- package/dist/nodes/GenericNode.d.ts.map +1 -0
- package/dist/nodes/GenericNode.js +24 -0
- package/dist/nodes/GenericNode.js.map +1 -0
- package/dist/utils/animationMapping.d.ts +53 -0
- package/dist/utils/animationMapping.d.ts.map +1 -0
- package/dist/utils/animationMapping.js +133 -0
- package/dist/utils/animationMapping.js.map +1 -0
- package/dist/utils/graphConverter.d.ts +22 -0
- package/dist/utils/graphConverter.d.ts.map +1 -0
- package/dist/utils/graphConverter.js +176 -0
- package/dist/utils/graphConverter.js.map +1 -0
- package/dist/utils/iconResolver.d.ts +29 -0
- package/dist/utils/iconResolver.d.ts.map +1 -0
- package/dist/utils/iconResolver.js +68 -0
- package/dist/utils/iconResolver.js.map +1 -0
- package/package.json +61 -0
- package/src/components/ConfigurationSelector.tsx +147 -0
- package/src/components/EdgeInfoPanel.tsx +198 -0
- package/src/components/EventLog.test.tsx +85 -0
- package/src/components/EventLog.tsx +51 -0
- package/src/components/GraphRenderer.test.tsx +118 -0
- package/src/components/GraphRenderer.tsx +1222 -0
- package/src/components/MetricsDashboard.tsx +40 -0
- package/src/components/NodeInfoPanel.tsx +425 -0
- package/src/edges/CustomEdge.tsx +344 -0
- package/src/edges/GenericEdge.tsx +40 -0
- package/src/hooks/usePathBasedEvents.ts +182 -0
- package/src/index.ts +67 -0
- package/src/nodes/CustomNode.tsx +432 -0
- package/src/nodes/GenericNode.tsx +54 -0
- package/src/stories/AnimationWorkshop.stories.tsx +608 -0
- package/src/stories/EventDrivenAnimations.stories.tsx +499 -0
- package/src/stories/EventLog.stories.tsx +161 -0
- package/src/stories/GraphRenderer.stories.tsx +628 -0
- package/src/stories/Introduction.mdx +51 -0
- package/src/stories/MetricsDashboard.stories.tsx +227 -0
- package/src/stories/MultiConfig.stories.tsx +531 -0
- package/src/stories/MultiDirectionalConnections.stories.tsx +345 -0
- package/src/stories/NodeShapes.stories.tsx +769 -0
- package/src/utils/animationMapping.ts +170 -0
- package/src/utils/graphConverter.ts +218 -0
- package/src/utils/iconResolver.tsx +49 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { GraphRenderer } from '../components/GraphRenderer';
|
|
4
|
+
import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Audit/NodeShapes',
|
|
8
|
+
component: GraphRenderer,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof GraphRenderer>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Canvas showing all available node shapes for visual auditing
|
|
20
|
+
*/
|
|
21
|
+
const allShapesCanvas: ExtendedCanvas = {
|
|
22
|
+
nodes: [
|
|
23
|
+
// Row 1: Basic shapes
|
|
24
|
+
{
|
|
25
|
+
id: 'rectangle',
|
|
26
|
+
type: 'text',
|
|
27
|
+
x: 100,
|
|
28
|
+
y: 100,
|
|
29
|
+
width: 140,
|
|
30
|
+
height: 80,
|
|
31
|
+
text: '# Rectangle\nDefault shape',
|
|
32
|
+
color: 6, // purple
|
|
33
|
+
vv: {
|
|
34
|
+
nodeType: 'rectangle-demo',
|
|
35
|
+
shape: 'rectangle',
|
|
36
|
+
icon: 'square',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'circle',
|
|
41
|
+
type: 'text',
|
|
42
|
+
x: 300,
|
|
43
|
+
y: 100,
|
|
44
|
+
width: 100,
|
|
45
|
+
height: 100,
|
|
46
|
+
text: '# Circle',
|
|
47
|
+
color: 5, // cyan
|
|
48
|
+
vv: {
|
|
49
|
+
nodeType: 'circle-demo',
|
|
50
|
+
shape: 'circle',
|
|
51
|
+
icon: 'circle',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'hexagon',
|
|
56
|
+
type: 'text',
|
|
57
|
+
x: 480,
|
|
58
|
+
y: 100,
|
|
59
|
+
width: 120,
|
|
60
|
+
height: 120,
|
|
61
|
+
text: '# Hexagon',
|
|
62
|
+
color: 4, // green
|
|
63
|
+
vv: {
|
|
64
|
+
nodeType: 'hexagon-demo',
|
|
65
|
+
shape: 'hexagon',
|
|
66
|
+
icon: 'hexagon',
|
|
67
|
+
size: { width: 120, height: 120 },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'diamond',
|
|
72
|
+
type: 'text',
|
|
73
|
+
x: 680,
|
|
74
|
+
y: 100,
|
|
75
|
+
width: 70,
|
|
76
|
+
height: 70,
|
|
77
|
+
text: 'Diamond',
|
|
78
|
+
color: 2, // orange
|
|
79
|
+
vv: {
|
|
80
|
+
nodeType: 'diamond-demo',
|
|
81
|
+
shape: 'diamond',
|
|
82
|
+
icon: 'diamond',
|
|
83
|
+
size: { width: 70, height: 70 },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'custom',
|
|
88
|
+
type: 'text',
|
|
89
|
+
x: 860,
|
|
90
|
+
y: 100,
|
|
91
|
+
width: 140,
|
|
92
|
+
height: 80,
|
|
93
|
+
text: '# Custom\n(Falls back to rect)',
|
|
94
|
+
color: 1, // red
|
|
95
|
+
vv: {
|
|
96
|
+
nodeType: 'custom-demo',
|
|
97
|
+
shape: 'custom',
|
|
98
|
+
icon: 'settings',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
edges: [],
|
|
103
|
+
vv: {
|
|
104
|
+
version: '1.0.0',
|
|
105
|
+
name: 'Node Shapes Audit',
|
|
106
|
+
description: 'All available node shapes for visual inspection',
|
|
107
|
+
edgeTypes: {},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const AllShapes: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
canvas: allShapesCanvas,
|
|
114
|
+
width: 1100,
|
|
115
|
+
height: 350,
|
|
116
|
+
},
|
|
117
|
+
parameters: {
|
|
118
|
+
docs: {
|
|
119
|
+
description: {
|
|
120
|
+
story: `
|
|
121
|
+
**All Node Shapes**
|
|
122
|
+
|
|
123
|
+
This story displays all 5 available node shapes:
|
|
124
|
+
- **Rectangle** - Default shape with rounded corners (borderRadius: 8px)
|
|
125
|
+
- **Circle** - Circular nodes (borderRadius: 50%)
|
|
126
|
+
- **Hexagon** - Flat-top style with points on left/right sides
|
|
127
|
+
- **Diamond** - Rotated 45° square with counter-rotated content
|
|
128
|
+
- **Custom** - Placeholder that falls back to rectangle styling
|
|
129
|
+
`,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Canvas showing shapes with different sizes
|
|
137
|
+
*/
|
|
138
|
+
const shapeSizesCanvas: ExtendedCanvas = {
|
|
139
|
+
nodes: [
|
|
140
|
+
// Small shapes
|
|
141
|
+
{
|
|
142
|
+
id: 'rect-small',
|
|
143
|
+
type: 'text',
|
|
144
|
+
x: 100,
|
|
145
|
+
y: 80,
|
|
146
|
+
width: 80,
|
|
147
|
+
height: 50,
|
|
148
|
+
text: 'Small',
|
|
149
|
+
color: 6,
|
|
150
|
+
vv: {
|
|
151
|
+
nodeType: 'rect-small',
|
|
152
|
+
shape: 'rectangle',
|
|
153
|
+
size: { width: 80, height: 50 },
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'circle-small',
|
|
158
|
+
type: 'text',
|
|
159
|
+
x: 250,
|
|
160
|
+
y: 80,
|
|
161
|
+
width: 60,
|
|
162
|
+
height: 60,
|
|
163
|
+
text: 'S',
|
|
164
|
+
color: 5,
|
|
165
|
+
vv: {
|
|
166
|
+
nodeType: 'circle-small',
|
|
167
|
+
shape: 'circle',
|
|
168
|
+
size: { width: 60, height: 60 },
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 'hex-small',
|
|
173
|
+
type: 'text',
|
|
174
|
+
x: 380,
|
|
175
|
+
y: 80,
|
|
176
|
+
width: 80,
|
|
177
|
+
height: 60,
|
|
178
|
+
text: 'Small',
|
|
179
|
+
color: 4,
|
|
180
|
+
vv: {
|
|
181
|
+
nodeType: 'hex-small',
|
|
182
|
+
shape: 'hexagon',
|
|
183
|
+
size: { width: 80, height: 60 },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'diamond-small',
|
|
188
|
+
type: 'text',
|
|
189
|
+
x: 520,
|
|
190
|
+
y: 80,
|
|
191
|
+
width: 60,
|
|
192
|
+
height: 60,
|
|
193
|
+
text: 'S',
|
|
194
|
+
color: 2,
|
|
195
|
+
vv: {
|
|
196
|
+
nodeType: 'diamond-small',
|
|
197
|
+
shape: 'diamond',
|
|
198
|
+
size: { width: 60, height: 60 },
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// Medium shapes (default)
|
|
203
|
+
{
|
|
204
|
+
id: 'rect-medium',
|
|
205
|
+
type: 'text',
|
|
206
|
+
x: 100,
|
|
207
|
+
y: 200,
|
|
208
|
+
width: 120,
|
|
209
|
+
height: 70,
|
|
210
|
+
text: 'Medium',
|
|
211
|
+
color: 6,
|
|
212
|
+
vv: {
|
|
213
|
+
nodeType: 'rect-medium',
|
|
214
|
+
shape: 'rectangle',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: 'circle-medium',
|
|
219
|
+
type: 'text',
|
|
220
|
+
x: 250,
|
|
221
|
+
y: 200,
|
|
222
|
+
width: 80,
|
|
223
|
+
height: 80,
|
|
224
|
+
text: 'M',
|
|
225
|
+
color: 5,
|
|
226
|
+
vv: {
|
|
227
|
+
nodeType: 'circle-medium',
|
|
228
|
+
shape: 'circle',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 'hex-medium',
|
|
233
|
+
type: 'text',
|
|
234
|
+
x: 380,
|
|
235
|
+
y: 200,
|
|
236
|
+
width: 100,
|
|
237
|
+
height: 80,
|
|
238
|
+
text: 'Medium',
|
|
239
|
+
color: 4,
|
|
240
|
+
vv: {
|
|
241
|
+
nodeType: 'hex-medium',
|
|
242
|
+
shape: 'hexagon',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
id: 'diamond-medium',
|
|
247
|
+
type: 'text',
|
|
248
|
+
x: 520,
|
|
249
|
+
y: 200,
|
|
250
|
+
width: 80,
|
|
251
|
+
height: 80,
|
|
252
|
+
text: 'M',
|
|
253
|
+
color: 2,
|
|
254
|
+
vv: {
|
|
255
|
+
nodeType: 'diamond-medium',
|
|
256
|
+
shape: 'diamond',
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// Large shapes
|
|
261
|
+
{
|
|
262
|
+
id: 'rect-large',
|
|
263
|
+
type: 'text',
|
|
264
|
+
x: 100,
|
|
265
|
+
y: 340,
|
|
266
|
+
width: 180,
|
|
267
|
+
height: 100,
|
|
268
|
+
text: '# Large\nWith content',
|
|
269
|
+
color: 6,
|
|
270
|
+
vv: {
|
|
271
|
+
nodeType: 'rect-large',
|
|
272
|
+
shape: 'rectangle',
|
|
273
|
+
size: { width: 180, height: 100 },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: 'circle-large',
|
|
278
|
+
type: 'text',
|
|
279
|
+
x: 250,
|
|
280
|
+
y: 340,
|
|
281
|
+
width: 120,
|
|
282
|
+
height: 120,
|
|
283
|
+
text: 'Large',
|
|
284
|
+
color: 5,
|
|
285
|
+
vv: {
|
|
286
|
+
nodeType: 'circle-large',
|
|
287
|
+
shape: 'circle',
|
|
288
|
+
size: { width: 120, height: 120 },
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: 'hex-large',
|
|
293
|
+
type: 'text',
|
|
294
|
+
x: 380,
|
|
295
|
+
y: 340,
|
|
296
|
+
width: 140,
|
|
297
|
+
height: 110,
|
|
298
|
+
text: 'Large',
|
|
299
|
+
color: 4,
|
|
300
|
+
vv: {
|
|
301
|
+
nodeType: 'hex-large',
|
|
302
|
+
shape: 'hexagon',
|
|
303
|
+
size: { width: 140, height: 110 },
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: 'diamond-large',
|
|
308
|
+
type: 'text',
|
|
309
|
+
x: 520,
|
|
310
|
+
y: 340,
|
|
311
|
+
width: 110,
|
|
312
|
+
height: 110,
|
|
313
|
+
text: 'Large',
|
|
314
|
+
color: 2,
|
|
315
|
+
vv: {
|
|
316
|
+
nodeType: 'diamond-large',
|
|
317
|
+
shape: 'diamond',
|
|
318
|
+
size: { width: 110, height: 110 },
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
edges: [],
|
|
323
|
+
vv: {
|
|
324
|
+
version: '1.0.0',
|
|
325
|
+
name: 'Node Sizes Audit',
|
|
326
|
+
description: 'Node shapes at different sizes',
|
|
327
|
+
edgeTypes: {},
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export const ShapeSizes: Story = {
|
|
332
|
+
args: {
|
|
333
|
+
canvas: shapeSizesCanvas,
|
|
334
|
+
width: 700,
|
|
335
|
+
height: 550,
|
|
336
|
+
},
|
|
337
|
+
parameters: {
|
|
338
|
+
docs: {
|
|
339
|
+
description: {
|
|
340
|
+
story: `
|
|
341
|
+
**Shape Sizes**
|
|
342
|
+
|
|
343
|
+
Shows each shape at small, medium, and large sizes to verify scaling behavior.
|
|
344
|
+
`,
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Canvas showing shapes with icons
|
|
352
|
+
*/
|
|
353
|
+
const shapesWithIconsCanvas: ExtendedCanvas = {
|
|
354
|
+
nodes: [
|
|
355
|
+
{
|
|
356
|
+
id: 'rect-icon',
|
|
357
|
+
type: 'text',
|
|
358
|
+
x: 100,
|
|
359
|
+
y: 100,
|
|
360
|
+
width: 140,
|
|
361
|
+
height: 80,
|
|
362
|
+
text: 'Server',
|
|
363
|
+
color: 6,
|
|
364
|
+
vv: {
|
|
365
|
+
nodeType: 'server',
|
|
366
|
+
shape: 'rectangle',
|
|
367
|
+
icon: 'server',
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
id: 'circle-icon',
|
|
372
|
+
type: 'text',
|
|
373
|
+
x: 300,
|
|
374
|
+
y: 100,
|
|
375
|
+
width: 100,
|
|
376
|
+
height: 100,
|
|
377
|
+
text: 'User',
|
|
378
|
+
color: 5,
|
|
379
|
+
vv: {
|
|
380
|
+
nodeType: 'user',
|
|
381
|
+
shape: 'circle',
|
|
382
|
+
icon: 'user',
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
id: 'hex-icon',
|
|
387
|
+
type: 'text',
|
|
388
|
+
x: 480,
|
|
389
|
+
y: 100,
|
|
390
|
+
width: 140,
|
|
391
|
+
height: 100,
|
|
392
|
+
text: 'Database',
|
|
393
|
+
color: 4,
|
|
394
|
+
vv: {
|
|
395
|
+
nodeType: 'database',
|
|
396
|
+
shape: 'hexagon',
|
|
397
|
+
icon: 'database',
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: 'diamond-icon',
|
|
402
|
+
type: 'text',
|
|
403
|
+
x: 680,
|
|
404
|
+
y: 100,
|
|
405
|
+
width: 100,
|
|
406
|
+
height: 100,
|
|
407
|
+
text: 'Cache',
|
|
408
|
+
color: 2,
|
|
409
|
+
vv: {
|
|
410
|
+
nodeType: 'cache',
|
|
411
|
+
shape: 'diamond',
|
|
412
|
+
icon: 'zap',
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
edges: [],
|
|
417
|
+
vv: {
|
|
418
|
+
version: '1.0.0',
|
|
419
|
+
name: 'Shapes with Icons',
|
|
420
|
+
description: 'Node shapes with Lucide icons',
|
|
421
|
+
edgeTypes: {},
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export const ShapesWithIcons: Story = {
|
|
426
|
+
args: {
|
|
427
|
+
canvas: shapesWithIconsCanvas,
|
|
428
|
+
width: 900,
|
|
429
|
+
height: 300,
|
|
430
|
+
},
|
|
431
|
+
parameters: {
|
|
432
|
+
docs: {
|
|
433
|
+
description: {
|
|
434
|
+
story: `
|
|
435
|
+
**Shapes with Icons**
|
|
436
|
+
|
|
437
|
+
Shows each shape with a Lucide icon to verify icon placement and sizing within different shapes.
|
|
438
|
+
`,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Canvas showing shapes with states
|
|
446
|
+
*/
|
|
447
|
+
const shapesWithStatesCanvas: ExtendedCanvas = {
|
|
448
|
+
nodes: [
|
|
449
|
+
// Idle state
|
|
450
|
+
{
|
|
451
|
+
id: 'rect-idle',
|
|
452
|
+
type: 'text',
|
|
453
|
+
x: 100,
|
|
454
|
+
y: 80,
|
|
455
|
+
width: 120,
|
|
456
|
+
height: 70,
|
|
457
|
+
text: 'Idle',
|
|
458
|
+
color: 6,
|
|
459
|
+
vv: {
|
|
460
|
+
nodeType: 'process',
|
|
461
|
+
shape: 'rectangle',
|
|
462
|
+
icon: 'box',
|
|
463
|
+
states: {
|
|
464
|
+
idle: { color: '#94a3b8', icon: 'box' },
|
|
465
|
+
active: { color: '#3b82f6', icon: 'play' },
|
|
466
|
+
error: { color: '#ef4444', icon: 'alert-circle' },
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
id: 'circle-idle',
|
|
472
|
+
type: 'text',
|
|
473
|
+
x: 280,
|
|
474
|
+
y: 80,
|
|
475
|
+
width: 90,
|
|
476
|
+
height: 90,
|
|
477
|
+
text: 'Idle',
|
|
478
|
+
color: 5,
|
|
479
|
+
vv: {
|
|
480
|
+
nodeType: 'agent',
|
|
481
|
+
shape: 'circle',
|
|
482
|
+
icon: 'user',
|
|
483
|
+
states: {
|
|
484
|
+
idle: { color: '#94a3b8', icon: 'user' },
|
|
485
|
+
active: { color: '#22c55e', icon: 'user-check' },
|
|
486
|
+
error: { color: '#ef4444', icon: 'user-x' },
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
id: 'hex-idle',
|
|
492
|
+
type: 'text',
|
|
493
|
+
x: 430,
|
|
494
|
+
y: 80,
|
|
495
|
+
width: 120,
|
|
496
|
+
height: 90,
|
|
497
|
+
text: 'Idle',
|
|
498
|
+
color: 4,
|
|
499
|
+
vv: {
|
|
500
|
+
nodeType: 'storage',
|
|
501
|
+
shape: 'hexagon',
|
|
502
|
+
icon: 'database',
|
|
503
|
+
states: {
|
|
504
|
+
idle: { color: '#94a3b8', icon: 'database' },
|
|
505
|
+
active: { color: '#22c55e', icon: 'hard-drive' },
|
|
506
|
+
error: { color: '#ef4444', icon: 'database' },
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: 'diamond-idle',
|
|
512
|
+
type: 'text',
|
|
513
|
+
x: 600,
|
|
514
|
+
y: 80,
|
|
515
|
+
width: 90,
|
|
516
|
+
height: 90,
|
|
517
|
+
text: 'Idle',
|
|
518
|
+
color: 2,
|
|
519
|
+
vv: {
|
|
520
|
+
nodeType: 'decision',
|
|
521
|
+
shape: 'diamond',
|
|
522
|
+
icon: 'git-branch',
|
|
523
|
+
states: {
|
|
524
|
+
idle: { color: '#94a3b8', icon: 'git-branch' },
|
|
525
|
+
active: { color: '#f97316', icon: 'git-commit' },
|
|
526
|
+
error: { color: '#ef4444', icon: 'git-branch' },
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
|
|
531
|
+
// Active state
|
|
532
|
+
{
|
|
533
|
+
id: 'rect-active',
|
|
534
|
+
type: 'text',
|
|
535
|
+
x: 100,
|
|
536
|
+
y: 220,
|
|
537
|
+
width: 120,
|
|
538
|
+
height: 70,
|
|
539
|
+
text: 'Active',
|
|
540
|
+
color: 6,
|
|
541
|
+
vv: {
|
|
542
|
+
nodeType: 'process-active',
|
|
543
|
+
shape: 'rectangle',
|
|
544
|
+
icon: 'play',
|
|
545
|
+
color: '#3b82f6',
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
id: 'circle-active',
|
|
550
|
+
type: 'text',
|
|
551
|
+
x: 280,
|
|
552
|
+
y: 220,
|
|
553
|
+
width: 90,
|
|
554
|
+
height: 90,
|
|
555
|
+
text: 'Active',
|
|
556
|
+
color: 5,
|
|
557
|
+
vv: {
|
|
558
|
+
nodeType: 'agent-active',
|
|
559
|
+
shape: 'circle',
|
|
560
|
+
icon: 'user-check',
|
|
561
|
+
color: '#22c55e',
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
id: 'hex-active',
|
|
566
|
+
type: 'text',
|
|
567
|
+
x: 430,
|
|
568
|
+
y: 220,
|
|
569
|
+
width: 120,
|
|
570
|
+
height: 90,
|
|
571
|
+
text: 'Active',
|
|
572
|
+
color: 4,
|
|
573
|
+
vv: {
|
|
574
|
+
nodeType: 'storage-active',
|
|
575
|
+
shape: 'hexagon',
|
|
576
|
+
icon: 'hard-drive',
|
|
577
|
+
color: '#22c55e',
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: 'diamond-active',
|
|
582
|
+
type: 'text',
|
|
583
|
+
x: 600,
|
|
584
|
+
y: 220,
|
|
585
|
+
width: 90,
|
|
586
|
+
height: 90,
|
|
587
|
+
text: 'Active',
|
|
588
|
+
color: 2,
|
|
589
|
+
vv: {
|
|
590
|
+
nodeType: 'decision-active',
|
|
591
|
+
shape: 'diamond',
|
|
592
|
+
icon: 'git-commit',
|
|
593
|
+
color: '#f97316',
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
|
|
597
|
+
// Error state
|
|
598
|
+
{
|
|
599
|
+
id: 'rect-error',
|
|
600
|
+
type: 'text',
|
|
601
|
+
x: 100,
|
|
602
|
+
y: 360,
|
|
603
|
+
width: 120,
|
|
604
|
+
height: 70,
|
|
605
|
+
text: 'Error',
|
|
606
|
+
color: 1,
|
|
607
|
+
vv: {
|
|
608
|
+
nodeType: 'process-error',
|
|
609
|
+
shape: 'rectangle',
|
|
610
|
+
icon: 'alert-circle',
|
|
611
|
+
color: '#ef4444',
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
id: 'circle-error',
|
|
616
|
+
type: 'text',
|
|
617
|
+
x: 280,
|
|
618
|
+
y: 360,
|
|
619
|
+
width: 90,
|
|
620
|
+
height: 90,
|
|
621
|
+
text: 'Error',
|
|
622
|
+
color: 1,
|
|
623
|
+
vv: {
|
|
624
|
+
nodeType: 'agent-error',
|
|
625
|
+
shape: 'circle',
|
|
626
|
+
icon: 'user-x',
|
|
627
|
+
color: '#ef4444',
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
id: 'hex-error',
|
|
632
|
+
type: 'text',
|
|
633
|
+
x: 430,
|
|
634
|
+
y: 360,
|
|
635
|
+
width: 120,
|
|
636
|
+
height: 90,
|
|
637
|
+
text: 'Error',
|
|
638
|
+
color: 1,
|
|
639
|
+
vv: {
|
|
640
|
+
nodeType: 'storage-error',
|
|
641
|
+
shape: 'hexagon',
|
|
642
|
+
icon: 'database',
|
|
643
|
+
color: '#ef4444',
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
id: 'diamond-error',
|
|
648
|
+
type: 'text',
|
|
649
|
+
x: 600,
|
|
650
|
+
y: 360,
|
|
651
|
+
width: 90,
|
|
652
|
+
height: 90,
|
|
653
|
+
text: 'Error',
|
|
654
|
+
color: 1,
|
|
655
|
+
vv: {
|
|
656
|
+
nodeType: 'decision-error',
|
|
657
|
+
shape: 'diamond',
|
|
658
|
+
icon: 'git-branch',
|
|
659
|
+
color: '#ef4444',
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
],
|
|
663
|
+
edges: [],
|
|
664
|
+
vv: {
|
|
665
|
+
version: '1.0.0',
|
|
666
|
+
name: 'Shapes with States',
|
|
667
|
+
description: 'Node shapes in different states (idle, active, error)',
|
|
668
|
+
edgeTypes: {},
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
export const ShapesWithStates: Story = {
|
|
673
|
+
args: {
|
|
674
|
+
canvas: shapesWithStatesCanvas,
|
|
675
|
+
width: 800,
|
|
676
|
+
height: 550,
|
|
677
|
+
},
|
|
678
|
+
parameters: {
|
|
679
|
+
docs: {
|
|
680
|
+
description: {
|
|
681
|
+
story: `
|
|
682
|
+
**Shapes with States**
|
|
683
|
+
|
|
684
|
+
Shows each shape in different visual states:
|
|
685
|
+
- **Row 1**: Idle state (gray)
|
|
686
|
+
- **Row 2**: Active state (blue/green/orange)
|
|
687
|
+
- **Row 3**: Error state (red)
|
|
688
|
+
`,
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Interactive comparison of all shapes side by side
|
|
696
|
+
*/
|
|
697
|
+
const ShapeComparisonTemplate = () => {
|
|
698
|
+
return (
|
|
699
|
+
<div style={{ padding: 20 }}>
|
|
700
|
+
<h2 style={{ marginBottom: 20, fontFamily: 'system-ui' }}>Node Shape Comparison</h2>
|
|
701
|
+
|
|
702
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 20, marginBottom: 30 }}>
|
|
703
|
+
<div style={{ textAlign: 'center' }}>
|
|
704
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Rectangle</h4>
|
|
705
|
+
<code style={{ fontSize: 11 }}>shape: 'rectangle'</code>
|
|
706
|
+
<div style={{ marginTop: 10, fontSize: 12, color: '#666' }}>
|
|
707
|
+
borderRadius: 8px
|
|
708
|
+
</div>
|
|
709
|
+
</div>
|
|
710
|
+
<div style={{ textAlign: 'center' }}>
|
|
711
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Circle</h4>
|
|
712
|
+
<code style={{ fontSize: 11 }}>shape: 'circle'</code>
|
|
713
|
+
<div style={{ marginTop: 10, fontSize: 12, color: '#666' }}>
|
|
714
|
+
borderRadius: 50%
|
|
715
|
+
</div>
|
|
716
|
+
</div>
|
|
717
|
+
<div style={{ textAlign: 'center' }}>
|
|
718
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Hexagon</h4>
|
|
719
|
+
<code style={{ fontSize: 11 }}>shape: 'hexagon'</code>
|
|
720
|
+
<div style={{ marginTop: 10, fontSize: 12, color: '#666' }}>
|
|
721
|
+
CSS clip-path polygon
|
|
722
|
+
</div>
|
|
723
|
+
</div>
|
|
724
|
+
<div style={{ textAlign: 'center' }}>
|
|
725
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Diamond</h4>
|
|
726
|
+
<code style={{ fontSize: 11 }}>shape: 'diamond'</code>
|
|
727
|
+
<div style={{ marginTop: 10, fontSize: 12, color: '#666' }}>
|
|
728
|
+
rotate(45deg)
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
<div style={{ textAlign: 'center' }}>
|
|
732
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Custom</h4>
|
|
733
|
+
<code style={{ fontSize: 11 }}>shape: 'custom'</code>
|
|
734
|
+
<div style={{ marginTop: 10, fontSize: 12, color: '#666' }}>
|
|
735
|
+
Falls back to rectangle
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
</div>
|
|
739
|
+
|
|
740
|
+
<GraphRenderer
|
|
741
|
+
canvas={allShapesCanvas}
|
|
742
|
+
width={1100}
|
|
743
|
+
height={280}
|
|
744
|
+
/>
|
|
745
|
+
|
|
746
|
+
<div style={{ marginTop: 30, padding: 16, backgroundColor: '#f5f5f5', borderRadius: 8 }}>
|
|
747
|
+
<h4 style={{ marginBottom: 10, fontFamily: 'system-ui' }}>Implementation Notes</h4>
|
|
748
|
+
<ul style={{ fontSize: 13, lineHeight: 1.8, margin: 0, paddingLeft: 20 }}>
|
|
749
|
+
<li><strong>Rectangle</strong>: Standard box with 8px border radius</li>
|
|
750
|
+
<li><strong>Circle</strong>: Forces equal width/height, 50% border radius</li>
|
|
751
|
+
<li><strong>Hexagon</strong>: Flat-top style using <code>clipPath: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)</code></li>
|
|
752
|
+
<li><strong>Diamond</strong>: Fixed square rotated 45°, inner content rotated -45° to keep text upright</li>
|
|
753
|
+
<li><strong>Custom</strong>: Currently renders as rectangle (placeholder for future custom shapes)</li>
|
|
754
|
+
</ul>
|
|
755
|
+
</div>
|
|
756
|
+
</div>
|
|
757
|
+
);
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
export const ShapeComparison: Story = {
|
|
761
|
+
render: () => <ShapeComparisonTemplate />,
|
|
762
|
+
parameters: {
|
|
763
|
+
docs: {
|
|
764
|
+
description: {
|
|
765
|
+
story: 'Interactive comparison view with implementation details for each shape.',
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
};
|