@principal-ai/principal-view-react 0.7.14 → 0.7.16

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 (138) hide show
  1. package/README.md +9 -24
  2. package/dist/components/ConfigurationSelector.d.ts +1 -1
  3. package/dist/components/ConfigurationSelector.d.ts.map +1 -1
  4. package/dist/components/ConfigurationSelector.js +6 -10
  5. package/dist/components/ConfigurationSelector.js.map +1 -1
  6. package/dist/components/EdgeInfoPanel.d.ts +1 -1
  7. package/dist/components/EdgeInfoPanel.d.ts.map +1 -1
  8. package/dist/components/EdgeInfoPanel.js +14 -18
  9. package/dist/components/EdgeInfoPanel.js.map +1 -1
  10. package/dist/components/GraphRenderer.d.ts +1 -1
  11. package/dist/components/GraphRenderer.d.ts.map +1 -1
  12. package/dist/components/GraphRenderer.js +89 -92
  13. package/dist/components/GraphRenderer.js.map +1 -1
  14. package/dist/components/NarrativeRenderer.d.ts +19 -0
  15. package/dist/components/NarrativeRenderer.d.ts.map +1 -0
  16. package/dist/components/NarrativeRenderer.js +103 -0
  17. package/dist/components/NarrativeRenderer.js.map +1 -0
  18. package/dist/components/NodeInfoPanel.d.ts +1 -1
  19. package/dist/components/NodeInfoPanel.d.ts.map +1 -1
  20. package/dist/components/NodeInfoPanel.js +33 -37
  21. package/dist/components/NodeInfoPanel.js.map +1 -1
  22. package/dist/components/NodeTooltip.js +15 -19
  23. package/dist/components/NodeTooltip.js.map +1 -1
  24. package/dist/components/SelectionSidebar.d.ts +1 -1
  25. package/dist/components/SelectionSidebar.d.ts.map +1 -1
  26. package/dist/components/SelectionSidebar.js +26 -30
  27. package/dist/components/SelectionSidebar.js.map +1 -1
  28. package/dist/components/TestEventPanel.d.ts +6 -0
  29. package/dist/components/TestEventPanel.d.ts.map +1 -1
  30. package/dist/components/TestEventPanel.js +157 -160
  31. package/dist/components/TestEventPanel.js.map +1 -1
  32. package/dist/edges/CustomEdge.d.ts +1 -1
  33. package/dist/edges/CustomEdge.d.ts.map +1 -1
  34. package/dist/edges/CustomEdge.js +18 -22
  35. package/dist/edges/CustomEdge.js.map +1 -1
  36. package/dist/edges/GenericEdge.d.ts +1 -1
  37. package/dist/edges/GenericEdge.d.ts.map +1 -1
  38. package/dist/edges/GenericEdge.js +3 -7
  39. package/dist/edges/GenericEdge.js.map +1 -1
  40. package/dist/hooks/usePathBasedEvents.d.ts +1 -1
  41. package/dist/hooks/usePathBasedEvents.d.ts.map +1 -1
  42. package/dist/hooks/usePathBasedEvents.js +14 -18
  43. package/dist/hooks/usePathBasedEvents.js.map +1 -1
  44. package/dist/index.d.ts +1 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +12 -33
  47. package/dist/index.js.map +1 -1
  48. package/dist/nodes/CustomNode.d.ts +1 -1
  49. package/dist/nodes/CustomNode.d.ts.map +1 -1
  50. package/dist/nodes/CustomNode.js +22 -26
  51. package/dist/nodes/CustomNode.js.map +1 -1
  52. package/dist/nodes/GenericNode.d.ts +1 -1
  53. package/dist/nodes/GenericNode.d.ts.map +1 -1
  54. package/dist/nodes/GenericNode.js +4 -8
  55. package/dist/nodes/GenericNode.js.map +1 -1
  56. package/dist/utils/animationMapping.d.ts +1 -1
  57. package/dist/utils/animationMapping.d.ts.map +1 -1
  58. package/dist/utils/animationMapping.js +6 -13
  59. package/dist/utils/animationMapping.js.map +1 -1
  60. package/dist/utils/graphConverter.d.ts +1 -1
  61. package/dist/utils/graphConverter.d.ts.map +1 -1
  62. package/dist/utils/graphConverter.js +4 -8
  63. package/dist/utils/graphConverter.js.map +1 -1
  64. package/dist/utils/iconResolver.js +7 -45
  65. package/dist/utils/iconResolver.js.map +1 -1
  66. package/dist/utils/narrative-converter.d.ts +45 -0
  67. package/dist/utils/narrative-converter.d.ts.map +1 -0
  68. package/dist/utils/narrative-converter.js +113 -0
  69. package/dist/utils/narrative-converter.js.map +1 -0
  70. package/dist/utils/narrative-loader.d.ts +53 -0
  71. package/dist/utils/narrative-loader.d.ts.map +1 -0
  72. package/dist/utils/narrative-loader.js +163 -0
  73. package/dist/utils/narrative-loader.js.map +1 -0
  74. package/package.json +22 -25
  75. package/src/components/ConfigurationSelector.tsx +1 -1
  76. package/src/components/EdgeInfoPanel.tsx +1 -1
  77. package/src/components/GraphRenderer.test.tsx +1 -1
  78. package/src/components/GraphRenderer.tsx +2 -2
  79. package/src/components/NarrativeRenderer.tsx +171 -0
  80. package/src/components/NodeInfoPanel.tsx +1 -1
  81. package/src/components/NodeTooltip.tsx +3 -3
  82. package/src/components/PendingChanges.test.tsx +1 -1
  83. package/src/components/SelectionSidebar.tsx +1 -1
  84. package/src/components/TestEventPanel.tsx +145 -121
  85. package/src/edges/CustomEdge.tsx +1 -1
  86. package/src/edges/GenericEdge.tsx +1 -1
  87. package/src/hooks/usePathBasedEvents.ts +1 -1
  88. package/src/index.ts +1 -7
  89. package/src/nodes/CustomNode.tsx +1 -1
  90. package/src/nodes/GenericNode.tsx +1 -1
  91. package/src/stories/AnimationWorkshop.stories.tsx +1 -1
  92. package/src/stories/CanvasEdgeTypes.stories.tsx +1 -1
  93. package/src/stories/CanvasNodeTypes.stories.tsx +1 -1
  94. package/src/stories/ColorPriority.stories.tsx +1 -1
  95. package/src/stories/EventDrivenAnimations.stories.tsx +1 -1
  96. package/src/stories/GraphRenderer.stories.tsx +1 -1
  97. package/src/stories/Introduction.mdx +4 -21
  98. package/src/stories/MultiConfig.stories.tsx +1 -1
  99. package/src/stories/MultiDirectionalConnections.stories.tsx +1 -1
  100. package/src/stories/NodeFieldsAudit.stories.tsx +1 -1
  101. package/src/stories/NodeShapes.stories.tsx +1 -1
  102. package/src/stories/OtelComponents.stories.tsx +1 -1
  103. package/src/stories/RealTestExecution.stories.tsx +111 -1
  104. package/src/stories/TraceViewer.stories.tsx +1 -1
  105. package/src/stories/ValidatedExecution.stories.tsx +1 -1
  106. package/src/stories/data/graph-converter-test-execution.json +204 -326
  107. package/src/stories/data/graph-converter-test.narrative.json +106 -0
  108. package/src/stories/data/graph-converter-validated-execution.json +6 -6
  109. package/src/utils/animationMapping.ts +1 -1
  110. package/src/utils/graphConverter.ts +1 -1
  111. package/src/utils/narrative-converter.ts +147 -0
  112. package/src/utils/narrative-loader.ts +172 -0
  113. package/dist/components/EventLog.d.ts +0 -20
  114. package/dist/components/EventLog.d.ts.map +0 -1
  115. package/dist/components/EventLog.js +0 -13
  116. package/dist/components/EventLog.js.map +0 -1
  117. package/dist/components/EventLog.test.d.ts +0 -2
  118. package/dist/components/EventLog.test.d.ts.map +0 -1
  119. package/dist/components/EventLog.test.js +0 -73
  120. package/dist/components/EventLog.test.js.map +0 -1
  121. package/dist/components/GraphRenderer.test.d.ts +0 -2
  122. package/dist/components/GraphRenderer.test.d.ts.map +0 -1
  123. package/dist/components/GraphRenderer.test.js +0 -88
  124. package/dist/components/GraphRenderer.test.js.map +0 -1
  125. package/dist/components/LayerPanel.d.ts +0 -31
  126. package/dist/components/LayerPanel.d.ts.map +0 -1
  127. package/dist/components/LayerPanel.js +0 -207
  128. package/dist/components/LayerPanel.js.map +0 -1
  129. package/dist/components/MetricsDashboard.d.ts +0 -14
  130. package/dist/components/MetricsDashboard.d.ts.map +0 -1
  131. package/dist/components/MetricsDashboard.js +0 -13
  132. package/dist/components/MetricsDashboard.js.map +0 -1
  133. package/src/components/EventLog.test.tsx +0 -85
  134. package/src/components/EventLog.tsx +0 -51
  135. package/src/components/MetricsDashboard.tsx +0 -40
  136. package/src/stories/EventLog.stories.tsx +0 -161
  137. package/src/stories/IndustryThemes.stories.tsx +0 -483
  138. package/src/stories/MetricsDashboard.stories.tsx +0 -227
@@ -0,0 +1 @@
1
+ {"version":3,"file":"narrative-loader.js","sourceRoot":"","sources":["../../src/utils/narrative-loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAY;IACtD,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,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I,CAAC,CAAC;iBAChB;aACF;iBAAM;gBACL,QAAQ,CAAC,oBAAoB,CAAC,CAAC;gBAC/B,WAAW,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YAC/D,WAAW,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC;AAED,sEAAsE;AACtE,yEAAyE;AACzE,OAAO,KAAK,MAAM,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/principal-view-react",
3
- "version": "0.7.14",
3
+ "version": "0.7.16",
4
4
  "description": "React components for graph-based principal view framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,36 +14,33 @@
14
14
  "build-storybook": "storybook build"
15
15
  },
16
16
  "dependencies": {
17
- "@principal-ade/industry-theme": "^0.1.4",
18
- "@principal-ai/principal-view-core": "^0.5.16",
19
- "@xyflow/react": "^12.0.0",
20
- "elkjs": "^0.9.0",
21
- "framer-motion": "^11.0.0",
22
- "js-yaml": "^4.1.1",
23
- "lucide-react": "^0.554.0",
24
- "zustand": "^4.5.0"
17
+ "@principal-ade/industry-theme": "0.1.7",
18
+ "@principal-ai/principal-view-core": "^0.7.6",
19
+ "@xyflow/react": "12.0.0",
20
+ "elkjs": "0.9.0",
21
+ "js-yaml": "4.1.1",
22
+ "lucide-react": "0.554.0",
23
+ "zustand": "4.5.0"
25
24
  },
26
25
  "peerDependencies": {
27
26
  "react": "^18.0.0 || ^19.0.0",
28
27
  "react-dom": "^18.0.0 || ^19.0.0"
29
28
  },
30
29
  "devDependencies": {
31
- "@storybook/addon-essentials": "^8.5.0",
32
- "@storybook/addon-interactions": "^8.5.0",
33
- "@storybook/addon-links": "^8.5.0",
34
- "@storybook/blocks": "^8.5.0",
35
- "@storybook/react": "^8.5.0",
36
- "@storybook/react-vite": "^8.5.0",
37
- "@storybook/test": "^8.5.0",
38
- "@testing-library/react": "^14.0.0",
39
- "@types/js-yaml": "^4.0.9",
40
- "@types/react": "^18.0.0",
41
- "happy-dom": "^12.10.3",
42
- "react": "^19.0.0",
43
- "react-dom": "^19.0.0",
44
- "storybook": "^8.5.0",
45
- "typescript": "^5.0.0",
46
- "vite": "^5.0.0"
30
+ "@storybook/addon-docs": "10.1.2",
31
+ "@storybook/addon-links": "10.1.2",
32
+ "@storybook/addon-onboarding": "10.1.2",
33
+ "@storybook/react-vite": "10.1.2",
34
+ "@testing-library/react": "^16.0.0",
35
+ "@types/js-yaml": "4.0.9",
36
+ "@types/react": "^18.3.0",
37
+ "@types/react-dom": "^18.3.0",
38
+ "happy-dom": "12.10.3",
39
+ "react": "19.0.0",
40
+ "react-dom": "19.0.0",
41
+ "storybook": "10.1.2",
42
+ "typescript": "5.0.4",
43
+ "vite": "^6.0.7"
47
44
  },
48
45
  "files": [
49
46
  "dist",
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ConfigurationFile } from '@principal-ai/principal-view-core';
2
+ import type { ConfigurationFile } from '@principal-ai/principal-view-core/browser';
3
3
 
4
4
  export interface ConfigurationSelectorProps {
5
5
  /** Available configurations */
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { EdgeState, EdgeTypeDefinition } from '@principal-ai/principal-view-core';
2
+ import type { EdgeState, EdgeTypeDefinition } from '@principal-ai/principal-view-core/browser';
3
3
  import { useTheme } from '@principal-ade/industry-theme';
4
4
 
5
5
  export interface EdgeInfoPanelProps {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { GraphRenderer } from './GraphRenderer';
4
- import type { GraphConfiguration, NodeState, EdgeState } from '@principal-ai/principal-view-core';
4
+ import type { GraphConfiguration, NodeState, EdgeState } from '@principal-ai/principal-view-core/browser';
5
5
 
6
6
  describe('GraphRenderer', () => {
7
7
  const testConfig: GraphConfiguration = {
@@ -31,8 +31,8 @@ import type {
31
31
  GraphEvent,
32
32
  ExtendedCanvas,
33
33
  ComponentLibrary,
34
- } from '@principal-ai/principal-view-core';
35
- import { CanvasConverter } from '@principal-ai/principal-view-core';
34
+ } from '@principal-ai/principal-view-core/browser';
35
+ import { CanvasConverter } from '@principal-ai/principal-view-core/browser';
36
36
  import { useTheme } from '@principal-ade/industry-theme';
37
37
  import { CustomNode } from '../nodes/CustomNode';
38
38
  import type { CustomNodeData } from '../nodes/CustomNode';
@@ -0,0 +1,171 @@
1
+ import React, { useMemo } from 'react';
2
+ import { renderNarrative } from '@principal-ai/principal-view-core/browser';
3
+ import type { NarrativeTemplate, OtelEvent } from '@principal-ai/principal-view-core/browser';
4
+ import { useTheme } from '@principal-ade/industry-theme';
5
+
6
+ export interface NarrativeRendererProps {
7
+ /** Narrative template to use for rendering */
8
+ template: NarrativeTemplate;
9
+
10
+ /** OTEL events to render */
11
+ events: OtelEvent[];
12
+
13
+ /** Optional CSS class name */
14
+ className?: string;
15
+
16
+ /** Optional custom style */
17
+ style?: React.CSSProperties;
18
+
19
+ /** Show metadata panel */
20
+ showMetadata?: boolean;
21
+ }
22
+
23
+ /**
24
+ * Renders OTEL events as a human-readable narrative using a template
25
+ */
26
+ export const NarrativeRenderer: React.FC<NarrativeRendererProps> = ({
27
+ template,
28
+ events,
29
+ className,
30
+ style,
31
+ showMetadata = false,
32
+ }) => {
33
+ const { theme } = useTheme();
34
+
35
+ // Render the narrative
36
+ const result = useMemo(() => {
37
+ try {
38
+ return renderNarrative(template, events);
39
+ } catch (error) {
40
+ return {
41
+ text: `Error rendering narrative: ${error instanceof Error ? error.message : 'Unknown error'}`,
42
+ scenarioId: 'error',
43
+ metadata: {
44
+ eventCount: events.length,
45
+ spanCount: 0,
46
+ logCount: 0,
47
+ },
48
+ };
49
+ }
50
+ }, [template, events]);
51
+
52
+ // Parse narrative text to add syntax highlighting
53
+ const renderHighlightedText = (text: string) => {
54
+ const lines = text.split('\n');
55
+
56
+ return lines.map((line, idx) => {
57
+ // Determine line style based on content
58
+ let lineStyle: React.CSSProperties = {};
59
+ let content = line;
60
+
61
+ // Status indicators (✅ ❌ ⚠️ 📋)
62
+ if (/^[✅❌⚠️📋]/.test(line)) {
63
+ lineStyle = {
64
+ fontWeight: 'bold',
65
+ fontSize: '16px',
66
+ marginTop: idx > 0 ? '8px' : '0',
67
+ marginBottom: '4px',
68
+ };
69
+ }
70
+ // Separators (━━━━)
71
+ else if (/^━+/.test(line)) {
72
+ lineStyle = {
73
+ color: theme.colors.border,
74
+ opacity: 0.6,
75
+ };
76
+ }
77
+ // Arrow items (→)
78
+ else if (/^(\s*)→/.test(line)) {
79
+ const indent = line.match(/^(\s*)/)?.[1] || '';
80
+ lineStyle = {
81
+ color: theme.colors.text,
82
+ fontWeight: indent.length === 0 ? 'bold' : 'normal',
83
+ marginTop: indent.length === 0 ? '12px' : '4px',
84
+ };
85
+ }
86
+ // Bullet items (•)
87
+ else if (/^\s+•/.test(line)) {
88
+ lineStyle = {
89
+ color: theme.colors.textMuted,
90
+ paddingLeft: '8px',
91
+ };
92
+ }
93
+ // Section headers (UPPERCASE at start)
94
+ else if (/^[A-Z\s]+:/.test(line)) {
95
+ lineStyle = {
96
+ fontWeight: 'bold',
97
+ marginTop: '8px',
98
+ color: theme.colors.text,
99
+ };
100
+ }
101
+
102
+ return (
103
+ <div key={idx} style={lineStyle}>
104
+ {content}
105
+ </div>
106
+ );
107
+ });
108
+ };
109
+
110
+ return (
111
+ <div
112
+ className={className}
113
+ style={{
114
+ width: '100%',
115
+ height: '100%',
116
+ display: 'flex',
117
+ flexDirection: 'column',
118
+ ...style,
119
+ }}
120
+ >
121
+ {/* Narrative Text */}
122
+ <div
123
+ style={{
124
+ flex: 1,
125
+ overflow: 'auto',
126
+ padding: '20px',
127
+ fontFamily: theme.fonts.monospace,
128
+ fontSize: '14px',
129
+ lineHeight: '1.6',
130
+ color: theme.colors.text,
131
+ backgroundColor: theme.colors.background,
132
+ whiteSpace: 'pre-wrap',
133
+ wordWrap: 'break-word',
134
+ }}
135
+ >
136
+ {renderHighlightedText(result.text)}
137
+ </div>
138
+
139
+ {/* Metadata Panel (optional) */}
140
+ {showMetadata && (
141
+ <div
142
+ style={{
143
+ borderTop: `1px solid ${theme.colors.border}`,
144
+ padding: '12px 20px',
145
+ backgroundColor: theme.colors.surface,
146
+ fontSize: '12px',
147
+ color: theme.colors.textMuted,
148
+ fontFamily: theme.fonts.monospace,
149
+ }}
150
+ >
151
+ <div style={{ marginBottom: '4px' }}>
152
+ <strong style={{ color: theme.colors.text }}>Template:</strong> {template.name}
153
+ </div>
154
+ <div style={{ marginBottom: '4px' }}>
155
+ <strong style={{ color: theme.colors.text }}>Scenario:</strong> {result.scenarioId}
156
+ </div>
157
+ <div>
158
+ <strong style={{ color: theme.colors.text }}>Events:</strong> {result.metadata.eventCount} total
159
+ ({result.metadata.spanCount} spans, {result.metadata.logCount} logs)
160
+ </div>
161
+ {result.metadata.timeRange && (
162
+ <div style={{ marginTop: '4px' }}>
163
+ <strong style={{ color: theme.colors.text }}>Duration:</strong>{' '}
164
+ {Number(result.metadata.timeRange.end) - Number(result.metadata.timeRange.start)}ms
165
+ </div>
166
+ )}
167
+ </div>
168
+ )}
169
+ </div>
170
+ );
171
+ };
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core';
2
+ import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core/browser';
3
3
  import { useTheme } from '@principal-ade/industry-theme';
4
4
  import { resolveIcon } from '../utils/iconResolver';
5
5
 
@@ -74,7 +74,7 @@ export const NodeTooltip: React.FC<NodeTooltipProps> = ({
74
74
  }
75
75
  };
76
76
 
77
- const tooltipContent = (
77
+ const renderTooltipContent = (): React.JSX.Element => (
78
78
  <div
79
79
  style={{
80
80
  position: usePortal ? 'fixed' : 'absolute',
@@ -164,7 +164,7 @@ export const NodeTooltip: React.FC<NodeTooltipProps> = ({
164
164
 
165
165
  // Use portal to render at body level when nodeRef is provided, otherwise render inline
166
166
  if (usePortal) {
167
- return createPortal(tooltipContent, document.body);
167
+ return createPortal(renderTooltipContent(), document.body);
168
168
  }
169
- return tooltipContent;
169
+ return renderTooltipContent();
170
170
  };
@@ -2,7 +2,7 @@ import { describe, expect, test, beforeEach, beforeAll, mock } from 'bun:test';
2
2
  import React, { createRef } from 'react';
3
3
  import { render, fireEvent, act } from '@testing-library/react';
4
4
  import { GraphRenderer, type GraphRendererHandle, type PendingChanges } from './GraphRenderer';
5
- import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
5
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core/browser';
6
6
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
7
7
  import { Window } from 'happy-dom';
8
8
 
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core';
2
+ import type { NodeState, NodeTypeDefinition } from '@principal-ai/principal-view-core/browser';
3
3
  import { useTheme } from '@principal-ade/industry-theme';
4
4
  import { resolveIcon } from '../utils/iconResolver';
5
5