@principal-ai/principal-view-react 0.8.0 → 0.8.2

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 (73) hide show
  1. package/dist/components/ConfigurationSelector.d.ts +1 -1
  2. package/dist/components/ConfigurationSelector.d.ts.map +1 -1
  3. package/dist/components/EdgeInfoPanel.d.ts +1 -1
  4. package/dist/components/EdgeInfoPanel.d.ts.map +1 -1
  5. package/dist/components/EdgeInfoPanel.js +77 -86
  6. package/dist/components/EdgeInfoPanel.js.map +1 -1
  7. package/dist/components/GraphRenderer.d.ts +1 -1
  8. package/dist/components/GraphRenderer.d.ts.map +1 -1
  9. package/dist/components/GraphRenderer.js +1 -1
  10. package/dist/components/GraphRenderer.js.map +1 -1
  11. package/dist/components/NodeInfoPanel.d.ts +1 -1
  12. package/dist/components/NodeInfoPanel.d.ts.map +1 -1
  13. package/dist/components/NodeInfoPanel.js +88 -67
  14. package/dist/components/NodeInfoPanel.js.map +1 -1
  15. package/dist/components/NodeTooltip.d.ts +1 -0
  16. package/dist/components/NodeTooltip.d.ts.map +1 -1
  17. package/dist/components/NodeTooltip.js +12 -2
  18. package/dist/components/NodeTooltip.js.map +1 -1
  19. package/dist/components/SelectionSidebar.d.ts +1 -1
  20. package/dist/components/SelectionSidebar.d.ts.map +1 -1
  21. package/dist/edges/CustomEdge.d.ts +1 -1
  22. package/dist/edges/CustomEdge.d.ts.map +1 -1
  23. package/dist/edges/GenericEdge.d.ts +1 -1
  24. package/dist/edges/GenericEdge.d.ts.map +1 -1
  25. package/dist/hooks/usePathBasedEvents.d.ts +1 -1
  26. package/dist/hooks/usePathBasedEvents.d.ts.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/nodes/CustomNode.d.ts +1 -1
  30. package/dist/nodes/CustomNode.d.ts.map +1 -1
  31. package/dist/nodes/CustomNode.js +5 -4
  32. package/dist/nodes/CustomNode.js.map +1 -1
  33. package/dist/nodes/GenericNode.d.ts +1 -1
  34. package/dist/nodes/GenericNode.d.ts.map +1 -1
  35. package/dist/utils/animationMapping.d.ts +1 -1
  36. package/dist/utils/animationMapping.d.ts.map +1 -1
  37. package/dist/utils/graphConverter.d.ts +1 -1
  38. package/dist/utils/graphConverter.d.ts.map +1 -1
  39. package/dist/utils/orientationUtils.d.ts +1 -1
  40. package/dist/utils/orientationUtils.d.ts.map +1 -1
  41. package/package.json +2 -2
  42. package/src/components/ConfigurationSelector.tsx +1 -1
  43. package/src/components/EdgeInfoPanel.tsx +161 -167
  44. package/src/components/GraphRenderer.test.tsx +1 -1
  45. package/src/components/GraphRenderer.tsx +2 -2
  46. package/src/components/NodeInfoPanel.tsx +178 -139
  47. package/src/components/NodeTooltip.tsx +28 -0
  48. package/src/components/PendingChanges.test.tsx +1 -1
  49. package/src/components/SelectionSidebar.tsx +1 -1
  50. package/src/edges/CustomEdge.tsx +1 -1
  51. package/src/edges/GenericEdge.tsx +1 -1
  52. package/src/hooks/usePathBasedEvents.ts +1 -1
  53. package/src/index.ts +1 -1
  54. package/src/nodes/CustomNode.tsx +6 -2
  55. package/src/nodes/GenericNode.tsx +1 -1
  56. package/src/stories/AnimationWorkshop.stories.tsx +1 -1
  57. package/src/stories/CanvasEdgeTypes.stories.tsx +1 -1
  58. package/src/stories/CanvasNodeTypes.stories.tsx +1 -1
  59. package/src/stories/ColorPriority.stories.tsx +1 -1
  60. package/src/stories/EventDrivenAnimations.stories.tsx +1 -1
  61. package/src/stories/GraphOrientation.stories.tsx +2 -2
  62. package/src/stories/GraphRenderer.stories.tsx +253 -1
  63. package/src/stories/MultiConfig.stories.tsx +1 -1
  64. package/src/stories/MultiDirectionalConnections.stories.tsx +1 -1
  65. package/src/stories/NodeFieldsAudit.stories.tsx +1 -1
  66. package/src/stories/NodeShapes.stories.tsx +1 -1
  67. package/src/stories/OtelComponents.stories.tsx +1 -1
  68. package/src/stories/TraceViewer.stories.tsx +1 -1
  69. package/src/stories/data/graph-converter-test-execution.json +256 -38
  70. package/src/stories/data/graph-converter-validated-execution.json +6 -6
  71. package/src/utils/animationMapping.ts +1 -1
  72. package/src/utils/graphConverter.ts +1 -1
  73. package/src/utils/orientationUtils.ts +1 -1
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { GraphRenderer } from '../components/GraphRenderer';
4
4
  import type { GraphRendererHandle, PendingChanges } from '../components/GraphRenderer';
5
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
5
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
6
6
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
7
7
 
8
8
  const meta = {
@@ -1076,6 +1076,258 @@ Color coding:
1076
1076
  },
1077
1077
  };
1078
1078
 
1079
+ // ============================================================================
1080
+ // Sources Tooltip Canvas
1081
+ // ============================================================================
1082
+
1083
+ /**
1084
+ * Canvas demonstrating source file associations in tooltips
1085
+ */
1086
+ const sourcesTooltipCanvas: ExtendedCanvas = {
1087
+ nodes: [
1088
+ {
1089
+ id: 'auth-service',
1090
+ type: 'text',
1091
+ x: 100,
1092
+ y: 150,
1093
+ width: 160,
1094
+ height: 100,
1095
+ text: '# Auth Service\n\nHandles user authentication',
1096
+ color: '#3b82f6',
1097
+ pv: {
1098
+ nodeType: 'service',
1099
+ shape: 'rectangle',
1100
+ icon: 'Lock',
1101
+ sources: [
1102
+ 'src/services/auth/AuthService.ts',
1103
+ 'src/services/auth/TokenManager.ts',
1104
+ ],
1105
+ },
1106
+ },
1107
+ {
1108
+ id: 'user-controller',
1109
+ type: 'text',
1110
+ x: 350,
1111
+ y: 150,
1112
+ width: 160,
1113
+ height: 100,
1114
+ text: '# User Controller\n\nManages user CRUD operations',
1115
+ color: '#8b5cf6',
1116
+ pv: {
1117
+ nodeType: 'controller',
1118
+ shape: 'rectangle',
1119
+ icon: 'User',
1120
+ sources: [
1121
+ 'src/controllers/UserController.ts',
1122
+ ],
1123
+ },
1124
+ },
1125
+ {
1126
+ id: 'database',
1127
+ type: 'text',
1128
+ x: 600,
1129
+ y: 150,
1130
+ width: 140,
1131
+ height: 100,
1132
+ text: '# Database\n\nPostgreSQL instance',
1133
+ color: '#22c55e',
1134
+ pv: {
1135
+ nodeType: 'database',
1136
+ shape: 'hexagon',
1137
+ icon: 'Database',
1138
+ sources: [
1139
+ 'src/db/connection.ts',
1140
+ 'src/db/migrations/001_init.sql',
1141
+ 'src/db/queries/users.ts',
1142
+ ],
1143
+ },
1144
+ },
1145
+ {
1146
+ id: 'cache-layer',
1147
+ type: 'text',
1148
+ x: 225,
1149
+ y: 320,
1150
+ width: 150,
1151
+ height: 90,
1152
+ text: '# Cache Layer\n\nRedis caching',
1153
+ color: '#f59e0b',
1154
+ pv: {
1155
+ nodeType: 'cache',
1156
+ shape: 'diamond',
1157
+ icon: 'Zap',
1158
+ sources: [
1159
+ 'src/cache/RedisCache.ts',
1160
+ 'src/cache/CacheManager.ts',
1161
+ ],
1162
+ },
1163
+ },
1164
+ {
1165
+ id: 'logger',
1166
+ type: 'text',
1167
+ x: 450,
1168
+ y: 320,
1169
+ width: 140,
1170
+ height: 90,
1171
+ text: '# Logger\n\nCentralized logging',
1172
+ color: '#6366f1',
1173
+ pv: {
1174
+ nodeType: 'utility',
1175
+ shape: 'circle',
1176
+ icon: 'FileText',
1177
+ sources: [
1178
+ 'src/utils/logger.ts',
1179
+ ],
1180
+ },
1181
+ },
1182
+ ],
1183
+ edges: [
1184
+ {
1185
+ id: 'auth-to-user',
1186
+ fromNode: 'auth-service',
1187
+ toNode: 'user-controller',
1188
+ fromSide: 'right',
1189
+ toSide: 'left',
1190
+ label: 'validates',
1191
+ pv: { edgeType: 'dataflow' },
1192
+ },
1193
+ {
1194
+ id: 'user-to-db',
1195
+ fromNode: 'user-controller',
1196
+ toNode: 'database',
1197
+ fromSide: 'right',
1198
+ toSide: 'left',
1199
+ label: 'queries',
1200
+ pv: { edgeType: 'dataflow' },
1201
+ },
1202
+ {
1203
+ id: 'auth-to-cache',
1204
+ fromNode: 'auth-service',
1205
+ toNode: 'cache-layer',
1206
+ fromSide: 'bottom',
1207
+ toSide: 'top',
1208
+ label: 'stores tokens',
1209
+ pv: { edgeType: 'dataflow' },
1210
+ },
1211
+ {
1212
+ id: 'user-to-cache',
1213
+ fromNode: 'user-controller',
1214
+ toNode: 'cache-layer',
1215
+ fromSide: 'bottom',
1216
+ toSide: 'top',
1217
+ label: 'caches',
1218
+ pv: { edgeType: 'dataflow' },
1219
+ },
1220
+ {
1221
+ id: 'auth-to-logger',
1222
+ fromNode: 'auth-service',
1223
+ toNode: 'logger',
1224
+ fromSide: 'bottom',
1225
+ toSide: 'top',
1226
+ label: 'logs',
1227
+ pv: { edgeType: 'logging' },
1228
+ },
1229
+ {
1230
+ id: 'user-to-logger',
1231
+ fromNode: 'user-controller',
1232
+ toNode: 'logger',
1233
+ fromSide: 'bottom',
1234
+ toSide: 'top',
1235
+ label: 'logs',
1236
+ pv: { edgeType: 'logging' },
1237
+ },
1238
+ ],
1239
+ pv: {
1240
+ version: '1.0.0',
1241
+ name: 'Service Architecture with Sources',
1242
+ description: 'Demonstrates source file associations in shift-hover tooltips',
1243
+ edgeTypes: {
1244
+ dataflow: {
1245
+ style: 'solid',
1246
+ color: '#3b82f6',
1247
+ width: 2,
1248
+ directed: true,
1249
+ },
1250
+ logging: {
1251
+ style: 'dashed',
1252
+ color: '#94a3b8',
1253
+ width: 2,
1254
+ directed: true,
1255
+ },
1256
+ },
1257
+ },
1258
+ };
1259
+
1260
+ const SourcesInTooltipTemplate = () => {
1261
+ const [lastClickedSource, setLastClickedSource] = React.useState<{ nodeId: string; source: string } | null>(null);
1262
+
1263
+ const handleSourceClick = (nodeId: string, source: string) => {
1264
+ console.log('Source clicked:', source, 'from node:', nodeId);
1265
+ setLastClickedSource({ nodeId, source });
1266
+ alert(`Source clicked!\n\nNode: ${nodeId}\nFile: ${source}`);
1267
+ };
1268
+
1269
+ return (
1270
+ <div>
1271
+ {lastClickedSource && (
1272
+ <div
1273
+ style={{
1274
+ marginBottom: 16,
1275
+ padding: 12,
1276
+ backgroundColor: '#f0f9ff',
1277
+ borderRadius: 4,
1278
+ border: '1px solid #3b82f6',
1279
+ }}
1280
+ >
1281
+ <strong style={{ color: '#1e40af' }}>Last Clicked Source:</strong>
1282
+ <div style={{ marginTop: 4, fontSize: 12, color: '#1e40af', fontFamily: 'monospace' }}>
1283
+ Node: {lastClickedSource.nodeId}
1284
+ </div>
1285
+ <div style={{ fontSize: 12, color: '#1e40af', fontFamily: 'monospace' }}>
1286
+ File: {lastClickedSource.source}
1287
+ </div>
1288
+ </div>
1289
+ )}
1290
+ <GraphRenderer
1291
+ canvas={sourcesTooltipCanvas}
1292
+ width={900}
1293
+ height={550}
1294
+ onSourceClick={handleSourceClick}
1295
+ />
1296
+ </div>
1297
+ );
1298
+ };
1299
+
1300
+ export const SourcesInTooltip: Story = {
1301
+ render: () => <SourcesInTooltipTemplate />,
1302
+ parameters: {
1303
+ docs: {
1304
+ description: {
1305
+ story: `
1306
+ **Sources in Tooltips and Info Panel** - Demonstrates source file associations:
1307
+
1308
+ **How to view sources:**
1309
+ 1. Hold the **Shift** key and hover over any node to see sources in the tooltip
1310
+ 2. Click on a node to open the info panel at the bottom
1311
+ 3. Click on any source file path to trigger the \`onSourceClick\` callback
1312
+
1313
+ **Features:**
1314
+ - **Green "S" Badge**: Nodes with sources show a green badge in the top-left corner
1315
+ - **Tooltip Sources**: Source files appear below the description in shift-hover tooltips
1316
+ - **Clickable Sources**: In the info panel, sources are clickable buttons with dotted underlines
1317
+ - **Callback Integration**: \`onSourceClick(nodeId, source)\` fires when a source is clicked
1318
+ - **Visual Feedback**: Sources show hover effects and are clearly interactive
1319
+
1320
+ **Try it:**
1321
+ 1. Click on "Auth Service" to open the info panel
1322
+ 2. Click on any of its 2 source files in the panel
1323
+ 3. An alert will show the clicked source information
1324
+ 4. Also try: Database (3 sources), Cache Layer (2 sources), Logger (1 source)
1325
+ `,
1326
+ },
1327
+ },
1328
+ },
1329
+ };
1330
+
1079
1331
  const EditModeToggleTemplate = () => {
1080
1332
  const [isEditMode, setIsEditMode] = React.useState(false);
1081
1333
  const graphRef = React.useRef<GraphRendererHandle>(null);
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { useState } from 'react';
3
3
  import { GraphRenderer } from '../components/GraphRenderer';
4
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
4
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
5
5
  import React from 'react';
6
6
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { GraphRenderer } from '../components/GraphRenderer';
3
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
3
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
4
4
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
5
5
 
6
6
  const meta = {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { GraphRenderer } from '../components/GraphRenderer';
4
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
4
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
5
5
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
6
 
7
7
  const meta = {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { GraphRenderer } from '../components/GraphRenderer';
4
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
4
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
5
5
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
6
 
7
7
  const meta = {
@@ -4,7 +4,7 @@ import { ThemeProvider } from '@principal-ade/industry-theme';
4
4
  import { GraphRenderer } from '../components/GraphRenderer';
5
5
  import { NodeInfoPanel } from '../components/NodeInfoPanel';
6
6
  import { NodeTooltip } from '../components/NodeTooltip';
7
- import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core/browser';
7
+ import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core';
8
8
 
9
9
  // OTEL Log Association canvas data
10
10
  const otelCanvas = {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { GraphRenderer } from '../components/GraphRenderer';
4
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
4
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
5
5
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
6
 
7
7
  // Import captured trace canvas data