@principal-ai/principal-view-react 0.16.63 → 0.16.65

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.
@@ -1,149 +0,0 @@
1
- /**
2
- * EdgeLegendModal — modal over the graph area showing the edge-mechanism
3
- * legend (moved out of the sidebar), plus the canonical mechanism
4
- * descriptions table shared with the canvas's edge-label overlay.
5
- */
6
-
7
- import { useEffect } from 'react';
8
- import { useTheme } from '@principal-ade/industry-theme';
9
- import { X } from 'lucide-react';
10
- import { MECHANISM_COLOR, type SubsystemEdgeMechanism } from './model';
11
-
12
- /** Mechanism → [description, verifiable-with-graphify]. Drives the legend
13
- * modal and the "not directly verifiable" styling of edge labels. */
14
- export const MECHANISM_DESCRIPTIONS: [SubsystemEdgeMechanism, string, boolean][] = [
15
- ['imports', 'import statement (code-level dependency)', true],
16
- ['imports_from', 'imported by (reverse dependency)', true],
17
- ['re_exports', 're-exports symbols from', true],
18
- ['defines', 'defines / declares symbol', true],
19
- ['calls', 'function/method call (call graph edge)', true],
20
- ['extends', 'class inheritance', true],
21
- ['inherits', 'class inheritance', true],
22
- ['implements', 'implements interface / protocol', true],
23
- ['mixes_in', 'applies mixin', true],
24
- ['uses', 'general dependency (import, call, or reference)', false],
25
- ['method', 'structural: has method / member', true],
26
- ['references', 'type / symbol reference (not a call)', true],
27
- ['contains', 'structural: contains / encapsulates', true],
28
- ['feeds', 'data flow: output feeds into input', false],
29
- ['produces', 'data flow: produces / outputs', false],
30
- ['writes', 'state access: mutates retained state', true],
31
- ['reads', 'state access: reads retained state', true],
32
- ['watches', 'observes retained state without owning it', false],
33
- ['registers-into', 'registration pattern', false],
34
- ];
35
-
36
- /** Modal over the graph area showing the edge-mechanism legend (moved out of
37
- * the sidebar). Closes on backdrop click or Escape; renders nothing when
38
- * closed. */
39
- export function EdgeLegendModal({
40
- open,
41
- mechanisms,
42
- onClose,
43
- }: {
44
- open: boolean;
45
- mechanisms: Set<string>;
46
- onClose: () => void;
47
- }) {
48
- const { theme } = useTheme();
49
- const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
50
-
51
- useEffect(() => {
52
- if (!open) return;
53
- const onKey = (e: KeyboardEvent) => {
54
- if (e.key === 'Escape') onClose();
55
- };
56
- window.addEventListener('keydown', onKey);
57
- return () => window.removeEventListener('keydown', onKey);
58
- }, [open, onClose]);
59
-
60
- if (!open) return null;
61
-
62
- return (
63
- <div
64
- onClick={onClose}
65
- style={{
66
- position: 'absolute',
67
- inset: 0,
68
- zIndex: 20,
69
- display: 'flex',
70
- alignItems: 'center',
71
- justifyContent: 'center',
72
- background: 'rgba(0,0,0,0.5)',
73
- }}
74
- >
75
- <div
76
- onClick={(e) => e.stopPropagation()}
77
- style={{
78
- background: theme.colors.background,
79
- border: `1px solid ${theme.colors.border}`,
80
- borderRadius: 8,
81
- boxShadow: '0 8px 32px rgba(0,0,0,0.4)',
82
- padding: '16px',
83
- width: 420,
84
- maxWidth: '90%',
85
- maxHeight: '80%',
86
- overflowY: 'auto',
87
- fontFamily: theme.fonts.body,
88
- }}
89
- >
90
- <div
91
- style={{
92
- display: 'flex',
93
- alignItems: 'center',
94
- justifyContent: 'space-between',
95
- marginBottom: 12,
96
- }}
97
- >
98
- <span
99
- style={{
100
- fontSize: theme.fontSizes[1],
101
- fontWeight: 600,
102
- color: theme.colors.text,
103
- }}
104
- >
105
- Edge Legend
106
- </span>
107
- <button
108
- type="button"
109
- onClick={onClose}
110
- aria-label="Close legend"
111
- style={{
112
- display: 'inline-flex',
113
- alignItems: 'center',
114
- justifyContent: 'center',
115
- width: 22,
116
- height: 22,
117
- padding: 0,
118
- border: 'none',
119
- borderRadius: 4,
120
- background: 'transparent',
121
- color: theme.colors.text,
122
- cursor: 'pointer',
123
- }}
124
- >
125
- <X size={14} />
126
- </button>
127
- </div>
128
- <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
129
- {MECHANISM_DESCRIPTIONS.filter(([m]) => mechanisms.has(m)).map(([mechanism, desc, verifiable]) => (
130
- <div key={mechanism} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: theme.fontSizes[0] }}>
131
- <span
132
- style={{
133
- width: 10,
134
- height: 10,
135
- borderRadius: verifiable ? '50%' : '30% 70% 70% 30% / 30% 30% 70% 70%',
136
- background: MECHANISM_COLOR[mechanism],
137
- border: verifiable ? 'none' : `1px dashed ${MECHANISM_COLOR[mechanism]}`,
138
- flexShrink: 0,
139
- }}
140
- />
141
- <span style={{ fontFamily: theme.fonts.monospace, color: MECHANISM_COLOR[mechanism], fontWeight: 500 }}>{mechanism}</span>
142
- <span style={{ color: muted }}>{desc}</span>
143
- </div>
144
- ))}
145
- </div>
146
- </div>
147
- </div>
148
- );
149
- }