@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.
Files changed (98) hide show
  1. package/dist/index.d.ts +7 -44
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -32
  4. package/dist/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/src/index.ts +9 -199
  7. package/src/components/ConfigurationSelector.tsx +0 -133
  8. package/src/components/GraphRenderer.tsx +0 -3195
  9. package/src/components/MultiCanvasRenderer.tsx +0 -295
  10. package/src/components/NodeTooltip.tsx +0 -279
  11. package/src/components/PendingChanges.test.tsx +0 -375
  12. package/src/components/SelectionSidebar.tsx +0 -352
  13. package/src/components/SequenceDiagramRenderer.tsx +0 -1156
  14. package/src/components/WorkflowSequenceDiagram.tsx +0 -270
  15. package/src/components/dashboard/DashboardRenderer.tsx +0 -317
  16. package/src/components/dashboard/MetricPanel.tsx +0 -254
  17. package/src/components/dashboard/MockDataProvider.ts +0 -330
  18. package/src/components/dashboard/components/BarChart.tsx +0 -299
  19. package/src/components/dashboard/components/LineChart.tsx +0 -279
  20. package/src/components/dashboard/components/MetricCard.tsx +0 -270
  21. package/src/components/dashboard/components/SourceLink.tsx +0 -63
  22. package/src/components/dashboard/components/TimeRangeSelector.tsx +0 -280
  23. package/src/components/dashboard/components/index.ts +0 -5
  24. package/src/components/dashboard/index.ts +0 -47
  25. package/src/components/dashboard/types.ts +0 -126
  26. package/src/components/state-view/PipelineView.tsx +0 -347
  27. package/src/components/state-view/index.ts +0 -14
  28. package/src/components/state-view/types.ts +0 -261
  29. package/src/components/state-view/useStateView.ts +0 -205
  30. package/src/contexts/GraphEditContext.tsx +0 -27
  31. package/src/contexts/TooltipPortalContext.ts +0 -8
  32. package/src/edges/CustomEdge.tsx +0 -402
  33. package/src/edges/GenericEdge.tsx +0 -36
  34. package/src/hooks/usePathBasedEvents.ts +0 -192
  35. package/src/hooks/useSequenceLayout.ts +0 -543
  36. package/src/hooks/useUndoRedo.ts +0 -144
  37. package/src/nodes/CustomNode.tsx +0 -1231
  38. package/src/nodes/GenericNode.tsx +0 -55
  39. package/src/nodes/otel/OtelBoundaryNode.tsx +0 -224
  40. package/src/nodes/otel/OtelEventNode.tsx +0 -225
  41. package/src/nodes/otel/OtelResourceNode.tsx +0 -251
  42. package/src/nodes/otel/OtelScopeNode.tsx +0 -221
  43. package/src/nodes/otel/OtelSpanConventionNode.tsx +0 -295
  44. package/src/nodes/otel/index.ts +0 -23
  45. package/src/nodes/otel/shared/NodeBadges.tsx +0 -295
  46. package/src/nodes/otel/shared/NodeContent.tsx +0 -204
  47. package/src/nodes/otel/shared/index.ts +0 -8
  48. package/src/nodes/otel/shared/types.ts +0 -138
  49. package/src/nodes/otel/shared/useNodeBehavior.ts +0 -114
  50. package/src/stories/Audit/BoundaryNodes.stories.tsx +0 -385
  51. package/src/stories/Audit/CanvasEdgeTypes.stories.tsx +0 -1448
  52. package/src/stories/Audit/CanvasNodeTypes.stories.tsx +0 -1049
  53. package/src/stories/Audit/ColorPriority.stories.tsx +0 -895
  54. package/src/stories/Audit/DiamondBadges.stories.tsx +0 -629
  55. package/src/stories/Audit/NodeDimensionsTesting.stories.tsx +0 -724
  56. package/src/stories/Audit/NodeFieldsAudit.stories.tsx +0 -996
  57. package/src/stories/Audit/NodeFontSizeTesting.stories.tsx +0 -715
  58. package/src/stories/Audit/NodeShapes.stories.tsx +0 -1208
  59. package/src/stories/Audit/WideNodesTesting.stories.tsx +0 -1045
  60. package/src/stories/Components/DashboardRenderer.stories.tsx +0 -263
  61. package/src/stories/Components/GraphRenderer.stories.tsx +0 -3236
  62. package/src/stories/Components/MultiCanvasRenderer.stories.tsx +0 -370
  63. package/src/stories/Components/SequenceDiagram.stories.tsx +0 -255
  64. package/src/stories/Components/StateView.stories.tsx +0 -417
  65. package/src/stories/Components/TraceViewer.stories.tsx +0 -442
  66. package/src/stories/Components/WorkflowSequenceDiagram.stories.tsx +0 -802
  67. package/src/stories/Features/AnimationWorkshop.stories.tsx +0 -727
  68. package/src/stories/Features/ChangeTypeVisual.stories.tsx +0 -67
  69. package/src/stories/Features/EventDrivenAnimations.stories.tsx +0 -513
  70. package/src/stories/Features/MultiConfig.stories.tsx +0 -539
  71. package/src/stories/Layout/ElkEdgeRouting.stories.tsx +0 -539
  72. package/src/stories/Layout/GraphOrientation.stories.tsx +0 -500
  73. package/src/stories/Layout/MultiDirectionalConnections.stories.tsx +0 -352
  74. package/src/stories/Nodes/NodeDefinitionComparison.stories.tsx +0 -560
  75. package/src/stories/Nodes/NodeNameFallbacks.stories.tsx +0 -491
  76. package/src/stories/Nodes/NumericColors.stories.tsx +0 -440
  77. package/src/stories/OTEL/EventNameDisplay.stories.tsx +0 -694
  78. package/src/stories/OTEL/EventNameFallback.stories.tsx +0 -578
  79. package/src/stories/OTEL/OtelComponents.stories.tsx +0 -422
  80. package/src/stories/OTEL/OtelNodeTypesPrototype.stories.tsx +0 -806
  81. package/src/stories/OTEL/RawEventCards.stories.tsx +0 -57
  82. package/src/stories/OTEL/SpanBadges.stories.tsx +0 -840
  83. package/src/stories/OTEL/ValidationEventsCanvas.stories.tsx +0 -209
  84. package/src/stories/RealWorld/BacklogMdCanvases.stories.tsx +0 -721
  85. package/src/stories/RealWorld/FileCitySequence.stories.tsx +0 -516
  86. package/src/stories/RealWorld/RealCanvasFiles.stories.tsx +0 -336
  87. package/src/stories/__traces__/test-run.canvas.json +0 -241
  88. package/src/stories/data/activity-feed-analytics.dashboard.json +0 -300
  89. package/src/stories/data/file-city-images-transformed.otel.canvas.json +0 -295
  90. package/src/stories/data/file-city-workflows.json +0 -269
  91. package/src/stories/data/graph-converter-test-execution.json +0 -443
  92. package/src/stories/data/graph-converter-test.workflow.json +0 -105
  93. package/src/stories/data/graph-converter-validated-execution.json +0 -58
  94. package/src/utils/animationMapping.ts +0 -166
  95. package/src/utils/canvasBounds.ts +0 -146
  96. package/src/utils/graphConverter.ts +0 -148
  97. package/src/utils/iconResolver.tsx +0 -53
  98. package/src/utils/orientationUtils.ts +0 -73
@@ -1,204 +0,0 @@
1
- /**
2
- * Node content component - renders icon, name, identifier, state, violations, and workflow chips
3
- */
4
-
5
- import React from 'react';
6
- import { useTheme } from '@principal-ade/industry-theme';
7
- import { resolveIcon } from '../../../utils/iconResolver';
8
- import type { NodeContentProps, WorkflowChip } from './types';
9
-
10
- /**
11
- * Helper to render text with word break opportunities after dots
12
- */
13
- function renderWithDotBreaks(text: string): React.ReactNode {
14
- const parts = text.split('.');
15
- return parts.map((part, i) => (
16
- <span key={i}>
17
- {part}
18
- {i < parts.length - 1 && (
19
- <>
20
- .<wbr />
21
- </>
22
- )}
23
- </span>
24
- ));
25
- }
26
-
27
- /**
28
- * Workflow chips component for span convention nodes
29
- */
30
- const WorkflowChips: React.FC<{
31
- chips: WorkflowChip[];
32
- onChipClick?: (chipId: string) => void;
33
- selectedChipId?: string;
34
- }> = ({ chips, onChipClick, selectedChipId }) => {
35
- const { theme } = useTheme();
36
-
37
- if (!chips || chips.length === 0) return null;
38
-
39
- // Show max 3 chips, then "+N more"
40
- const maxVisible = 3;
41
- const visibleChips = chips.slice(0, maxVisible);
42
- const remainingCount = chips.length - maxVisible;
43
-
44
- return (
45
- <div
46
- style={{
47
- display: 'flex',
48
- flexWrap: 'wrap',
49
- gap: '3px',
50
- marginTop: '4px',
51
- justifyContent: 'center',
52
- maxWidth: '100%',
53
- }}
54
- >
55
- {visibleChips.map((chip) => {
56
- const isSelected = selectedChipId === chip.id;
57
- const hasColor = !!chip.color;
58
-
59
- return (
60
- <div
61
- key={chip.id}
62
- onClick={(e) => {
63
- e.stopPropagation();
64
- onChipClick?.(chip.id);
65
- }}
66
- style={{
67
- fontSize: theme.fontSizes[0] * 0.65,
68
- padding: '1px 5px',
69
- borderRadius: '6px',
70
- backgroundColor: isSelected
71
- ? chip.color || '#3b82f6'
72
- : chip.color
73
- ? `${chip.color}33` // 20% opacity version
74
- : 'rgba(0,0,0,0.08)',
75
- color: isSelected
76
- ? '#fff'
77
- : hasColor
78
- ? chip.color
79
- : 'rgba(0,0,0,0.6)',
80
- whiteSpace: 'nowrap',
81
- maxWidth: '70px',
82
- overflow: 'hidden',
83
- textOverflow: 'ellipsis',
84
- cursor: onChipClick ? 'pointer' : 'default',
85
- fontWeight: isSelected ? theme.fontWeights.bold : theme.fontWeights.medium,
86
- transition: 'all 0.15s ease',
87
- border: isSelected ? 'none' : `1px solid ${hasColor ? `${chip.color}66` : 'rgba(0,0,0,0.1)'}`,
88
- }}
89
- title={chip.label}
90
- >
91
- {chip.label}
92
- </div>
93
- );
94
- })}
95
- {remainingCount > 0 && (
96
- <div
97
- style={{
98
- fontSize: theme.fontSizes[0] * 0.65,
99
- padding: '1px 5px',
100
- borderRadius: '6px',
101
- backgroundColor: 'rgba(0,0,0,0.05)',
102
- color: 'rgba(0,0,0,0.5)',
103
- whiteSpace: 'nowrap',
104
- }}
105
- title={`${remainingCount} more workflow${remainingCount > 1 ? 's' : ''}`}
106
- >
107
- +{remainingCount}
108
- </div>
109
- )}
110
- </div>
111
- );
112
- };
113
-
114
- /**
115
- * Node content component - renders the inner content of a node
116
- */
117
- export const NodeContent: React.FC<NodeContentProps> = ({
118
- displayName,
119
- identifier,
120
- icon,
121
- state,
122
- stateDefinitions,
123
- hasViolations,
124
- centered = true,
125
- workflowChips,
126
- onWorkflowChipClick,
127
- selectedWorkflowId,
128
- }) => {
129
- const { theme } = useTheme();
130
-
131
- // Show identifier if it differs from display name
132
- const showIdentifier = identifier && identifier !== displayName;
133
-
134
- // Get state label from definitions
135
- const stateLabel = state && stateDefinitions?.[state]?.label;
136
-
137
- return (
138
- <>
139
- {/* Icon */}
140
- {icon && (
141
- <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
142
- {resolveIcon(icon, 20)}
143
- </div>
144
- )}
145
-
146
- {/* Name with optional identifier */}
147
- <div style={{ textAlign: centered ? 'center' : 'left', wordBreak: 'break-word' }}>
148
- <div>{displayName}</div>
149
- {showIdentifier && (
150
- <div
151
- style={{
152
- fontSize: theme.fontSizes[0] * 0.75,
153
- color: 'rgba(0, 0, 0, 0.5)',
154
- marginTop: '2px',
155
- fontFamily: theme.fonts.monospace,
156
- }}
157
- >
158
- {renderWithDotBreaks(identifier)}
159
- </div>
160
- )}
161
- </div>
162
-
163
- {/* Workflow chips (for span convention nodes) */}
164
- {workflowChips && workflowChips.length > 0 && (
165
- <WorkflowChips
166
- chips={workflowChips}
167
- onChipClick={onWorkflowChipClick}
168
- selectedChipId={selectedWorkflowId}
169
- />
170
- )}
171
-
172
- {/* State badge */}
173
- {state && (
174
- <div
175
- style={{
176
- fontSize: theme.fontSizes[0],
177
- fontFamily: theme.fonts.body,
178
- backgroundColor: '#888', // Color will be passed from parent
179
- color: 'white',
180
- padding: '2px 6px',
181
- borderRadius: '4px',
182
- textAlign: 'center',
183
- }}
184
- >
185
- {stateLabel || state}
186
- </div>
187
- )}
188
-
189
- {/* Violations indicator */}
190
- {hasViolations && (
191
- <div
192
- style={{
193
- fontSize: theme.fontSizes[0],
194
- fontFamily: theme.fonts.body,
195
- color: '#D0021B',
196
- fontWeight: theme.fontWeights.bold,
197
- }}
198
- >
199
- ⚠️
200
- </div>
201
- )}
202
- </>
203
- );
204
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Shared components for OTEL node types
3
- */
4
-
5
- export * from './types';
6
- export * from './useNodeBehavior';
7
- export { NodeBadges } from './NodeBadges';
8
- export { NodeContent } from './NodeContent';
@@ -1,138 +0,0 @@
1
- /**
2
- * Shared types for OTEL node components
3
- */
4
-
5
- /**
6
- * Workflow chip displayed on span convention nodes
7
- */
8
- export interface WorkflowChip {
9
- /** Workflow ID for selection/filtering */
10
- id: string;
11
- /** Display label (may be truncated) */
12
- label: string;
13
- /** Optional color for the chip */
14
- color?: string;
15
- }
16
-
17
- /**
18
- * Common node data properties shared across all OTEL node types
19
- */
20
- export interface OtelNodeDataBase {
21
- /** Node color (hex string or preset number) */
22
- color?: string;
23
- /** Scope color for border (from library.yaml owned-scopes) */
24
- scopeColor?: string;
25
- /** Span color for fill (from .spans.canvas) */
26
- spanColor?: string;
27
- /** Explicit stroke color override */
28
- stroke?: string;
29
- /** Icon identifier (Lucide icons) */
30
- icon?: string;
31
- /** Implementation status */
32
- status?: 'draft' | 'approved' | 'implemented';
33
- /** Description for tooltip */
34
- description?: string;
35
- /** Source files where event is instrumented */
36
- sources?: string[];
37
- /** External references/documentation */
38
- references?: string[];
39
- /** Node-level state definitions */
40
- states?: Record<string, { color?: string; label?: string; icon?: string }>;
41
- /** Canvas type (e.g., 'group') */
42
- canvasType?: string;
43
- /** Node type identifier */
44
- nodeType?: string;
45
- }
46
-
47
- /**
48
- * OTEL extension data
49
- */
50
- export interface OtelExtensionData {
51
- /** Span pattern for span convention nodes */
52
- spanPattern?: string;
53
- /** Scope name for scope nodes */
54
- scope?: string;
55
- /** Resource match for resource nodes */
56
- resourceMatch?: Record<string, string | string[]>;
57
- /** Files where this is instrumented */
58
- files?: string[];
59
- }
60
-
61
- /**
62
- * Event data for event nodes
63
- */
64
- export interface EventData {
65
- /** Event name */
66
- name?: string;
67
- /** Event description */
68
- description?: string;
69
- /** Event attributes schema */
70
- attributes?: Record<string, unknown>;
71
- }
72
-
73
- /**
74
- * Boundary data for boundary nodes
75
- */
76
- export interface BoundaryData {
77
- /** Direction of boundary interaction */
78
- direction?: 'outbound' | 'inbound';
79
- /** Node query for external system */
80
- node?: Record<string, string>;
81
- }
82
-
83
- /**
84
- * Props for shared node content component
85
- */
86
- export interface NodeContentProps {
87
- /** Display name for the node */
88
- displayName: string;
89
- /** Identifier shown below the name (e.g., span pattern, event name) */
90
- identifier?: string;
91
- /** Icon identifier */
92
- icon?: string;
93
- /** Current state */
94
- state?: string;
95
- /** State definitions for label lookup */
96
- stateDefinitions?: Record<string, { label?: string }>;
97
- /** Whether node has violations */
98
- hasViolations?: boolean;
99
- /** Whether to center text (default true) */
100
- centered?: boolean;
101
- /** Workflow chips for span convention nodes */
102
- workflowChips?: WorkflowChip[];
103
- /** Callback when a workflow chip is clicked */
104
- onWorkflowChipClick?: (chipId: string) => void;
105
- /** Currently selected workflow ID */
106
- selectedWorkflowId?: string;
107
- }
108
-
109
- /**
110
- * Badge position types
111
- */
112
- export type BadgePosition =
113
- | 'top-left'
114
- | 'top-right'
115
- | 'bottom-left'
116
- | 'bottom-right'
117
- | 'left'
118
- | 'right'
119
- | 'top'
120
- | 'bottom';
121
-
122
- /**
123
- * Props for node badges component
124
- */
125
- export interface NodeBadgesProps {
126
- /** Node shape for position calculations */
127
- shape: 'rectangle' | 'circle' | 'hexagon' | 'diamond';
128
- /** Implementation status */
129
- status?: 'draft' | 'approved' | 'implemented';
130
- /** Source files */
131
- sourceFiles?: string[];
132
- /** References */
133
- references?: string[];
134
- /** Boundary data (for boundary nodes) */
135
- boundary?: BoundaryData;
136
- /** Node opacity for badge visibility */
137
- opacity?: number;
138
- }
@@ -1,114 +0,0 @@
1
- /**
2
- * Hook for shared node behavior (resize, hide, hover, tooltip)
3
- */
4
-
5
- import { useState, useRef, useCallback } from 'react';
6
- import { useNodeId } from '@xyflow/react';
7
- import { useGraphEdit } from '../../../contexts/GraphEditContext';
8
-
9
- export interface UseNodeBehaviorOptions {
10
- /** Whether the node is in edit mode */
11
- editable?: boolean;
12
- /** Whether tooltips are enabled */
13
- tooltipsEnabled?: boolean;
14
- /** Whether shift key is pressed */
15
- shiftKeyPressed?: boolean;
16
- /** Whether the node is selected */
17
- selected?: boolean;
18
- /** Whether the node is being dragged */
19
- dragging?: boolean;
20
- }
21
-
22
- export interface UseNodeBehaviorReturn {
23
- /** Ref for the node element */
24
- nodeRef: React.RefObject<HTMLDivElement>;
25
- /** Node ID from xyflow */
26
- nodeId: string | null;
27
- /** Whether the node is currently hovered */
28
- isHovered: boolean;
29
- /** Whether to show the tooltip */
30
- showTooltip: boolean;
31
- /** Mouse down handler for Cmd/Ctrl+click behavior */
32
- handleMouseDown: (event: React.MouseEvent) => void;
33
- /** Mouse enter handler */
34
- handleMouseEnter: () => void;
35
- /** Mouse leave handler */
36
- handleMouseLeave: () => void;
37
- /** Resize end handler */
38
- handleResizeEnd: (event: unknown, params: { width: number; height: number }) => void;
39
- }
40
-
41
- /**
42
- * Hook that provides common node behavior for resize, hide, hover, and tooltip interactions
43
- */
44
- export function useNodeBehavior(options: UseNodeBehaviorOptions): UseNodeBehaviorReturn {
45
- const {
46
- editable = false,
47
- tooltipsEnabled = true,
48
- shiftKeyPressed = false,
49
- selected = false,
50
- dragging = false,
51
- } = options;
52
-
53
- const nodeRef = useRef<HTMLDivElement>(null);
54
- const nodeId = useNodeId();
55
- const [isHovered, setIsHovered] = useState(false);
56
-
57
- const { onNodeResizeEnd, onToggleNodeHidden, onHideUnconnectedNodes } = useGraphEdit();
58
-
59
- // Handle resize end - notify parent to track the dimension change
60
- const handleResizeEnd = useCallback(
61
- (_event: unknown, params: { width: number; height: number }) => {
62
- if (nodeId && onNodeResizeEnd && params.width && params.height) {
63
- onNodeResizeEnd(nodeId, {
64
- width: Math.round(params.width),
65
- height: Math.round(params.height),
66
- });
67
- }
68
- },
69
- [nodeId, onNodeResizeEnd]
70
- );
71
-
72
- // Handle Cmd/Ctrl+mousedown to toggle hidden state
73
- // We use mousedown instead of click because in edit mode with draggable nodes,
74
- // ReactFlow's drag system intercepts Cmd+click before it becomes a click event
75
- // - Cmd/Ctrl+Shift+click: hide all nodes not directly connected to this node
76
- // - Cmd/Ctrl+click: toggle this single node's hidden state
77
- const handleMouseDown = useCallback(
78
- (event: React.MouseEvent) => {
79
- if ((event.metaKey || event.ctrlKey) && nodeId) {
80
- event.preventDefault();
81
- event.stopPropagation();
82
-
83
- if (event.shiftKey && onHideUnconnectedNodes) {
84
- // Cmd/Ctrl+Shift+click: hide unconnected nodes
85
- onHideUnconnectedNodes(nodeId);
86
- } else if (onToggleNodeHidden) {
87
- // Cmd/Ctrl+click: toggle single node
88
- onToggleNodeHidden(nodeId);
89
- }
90
- }
91
- },
92
- [nodeId, onToggleNodeHidden, onHideUnconnectedNodes]
93
- );
94
-
95
- const handleMouseEnter = useCallback(() => setIsHovered(true), []);
96
- const handleMouseLeave = useCallback(() => setIsHovered(false), []);
97
-
98
- // Show tooltip when:
99
- // 1. Hovering + not dragging + shift key pressed (always works), OR
100
- // 2. Node is selected AND not in edit mode (read-only selection shows tooltip)
101
- const showTooltip =
102
- tooltipsEnabled && ((isHovered && !dragging && shiftKeyPressed) || (!editable && !!selected));
103
-
104
- return {
105
- nodeRef,
106
- nodeId,
107
- isHovered,
108
- showTooltip,
109
- handleMouseDown,
110
- handleMouseEnter,
111
- handleMouseLeave,
112
- handleResizeEnd,
113
- };
114
- }