@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,270 +0,0 @@
1
- /**
2
- * MetricCard
3
- *
4
- * Displays a single metric value with optional trend indicator and sparkline.
5
- */
6
-
7
- import { useTheme } from '@principal-ade/industry-theme';
8
- import type { MetricCardProps } from '../types';
9
-
10
- export function MetricCard({
11
- title,
12
- value,
13
- unit,
14
- description,
15
- trend,
16
- changePercent,
17
- showTrend = true,
18
- showSparkline = false,
19
- sparklineData,
20
- thresholds,
21
- size = 'medium',
22
- onClick,
23
- }: MetricCardProps) {
24
- const { theme } = useTheme();
25
-
26
- // Font size indices into theme.fontSizes array
27
- // Typical array: [12, 14, 16, 20, 24, 32, 48]
28
- const sizeConfig = {
29
- small: {
30
- padding: '12px 16px',
31
- titleIndex: 0, // ~12px
32
- valueIndex: 4, // ~24px
33
- unitIndex: 0, // ~12px
34
- trendIndex: 0, // ~12px
35
- },
36
- medium: {
37
- padding: '16px 20px',
38
- titleIndex: 1, // ~14px
39
- valueIndex: 5, // ~32px
40
- unitIndex: 1, // ~14px
41
- trendIndex: 0, // ~12px
42
- },
43
- large: {
44
- padding: '20px 24px',
45
- titleIndex: 2, // ~16px
46
- valueIndex: 6, // ~48px
47
- unitIndex: 2, // ~16px
48
- trendIndex: 1, // ~14px
49
- },
50
- };
51
-
52
- const config = sizeConfig[size];
53
-
54
- const getValueColor = () => {
55
- if (!thresholds || typeof value !== 'number') {
56
- return theme.colors.text;
57
- }
58
- if (thresholds.critical !== undefined && value >= thresholds.critical) {
59
- return theme.colors.error;
60
- }
61
- if (thresholds.warning !== undefined && value >= thresholds.warning) {
62
- return theme.colors.warning;
63
- }
64
- return theme.colors.success;
65
- };
66
-
67
- const getTrendIcon = () => {
68
- if (!trend || !showTrend) return null;
69
-
70
- const iconSize = size === 'small' ? 12 : 16;
71
- const iconStyle: React.CSSProperties = {
72
- width: iconSize,
73
- height: iconSize,
74
- marginRight: 4,
75
- };
76
-
77
- if (trend === 'up') {
78
- return (
79
- <svg style={iconStyle} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
80
- <path d="M7 17l5-5 5 5M7 7l5 5 5-5" />
81
- </svg>
82
- );
83
- }
84
- if (trend === 'down') {
85
- return (
86
- <svg style={iconStyle} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
87
- <path d="M7 7l5 5 5-5M7 17l5-5 5 5" />
88
- </svg>
89
- );
90
- }
91
- return (
92
- <svg style={iconStyle} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
93
- <path d="M5 12h14" />
94
- </svg>
95
- );
96
- };
97
-
98
- const getTrendColor = () => {
99
- if (!trend) return theme.colors.textSecondary;
100
- if (trend === 'up') return theme.colors.success;
101
- if (trend === 'down') return theme.colors.error;
102
- return theme.colors.textSecondary;
103
- };
104
-
105
- const formatValue = (val: number | string): string => {
106
- if (typeof val === 'string') return val;
107
- if (val >= 1000000) return `${(val / 1000000).toFixed(1)}M`;
108
- if (val >= 1000) return `${(val / 1000).toFixed(1)}K`;
109
- if (val % 1 !== 0) return val.toFixed(1);
110
- return val.toString();
111
- };
112
-
113
- const renderSparkline = () => {
114
- if (!showSparkline || !sparklineData || sparklineData.length < 2) return null;
115
-
116
- const values = sparklineData
117
- .map((point) => point.value)
118
- .filter((v): v is number => typeof v === 'number');
119
-
120
- if (values.length < 2) return null;
121
-
122
- const minVal = Math.min(...values);
123
- const maxVal = Math.max(...values);
124
- const range = maxVal - minVal || 1;
125
-
126
- const width = size === 'small' ? 100 : size === 'medium' ? 140 : 180;
127
- const height = size === 'small' ? 24 : size === 'medium' ? 32 : 40;
128
- const padding = 2;
129
-
130
- const points = values.map((val, i) => {
131
- const x = padding + (i / (values.length - 1)) * (width - padding * 2);
132
- const y = height - padding - ((val - minVal) / range) * (height - padding * 2);
133
- return `${x},${y}`;
134
- });
135
-
136
- const pathD = `M ${points.join(' L ')}`;
137
-
138
- // Create gradient fill path
139
- const fillPoints = [
140
- `${padding},${height - padding}`,
141
- ...points,
142
- `${width - padding},${height - padding}`,
143
- ];
144
- const fillD = `M ${fillPoints.join(' L ')} Z`;
145
-
146
- const lineColor = trend === 'up' ? theme.colors.success : trend === 'down' ? theme.colors.error : theme.colors.primary || theme.colors.accent;
147
-
148
- return (
149
- <div style={{ marginTop: theme.space?.[2] || 8 }}>
150
- <svg width={width} height={height} style={{ display: 'block' }}>
151
- <defs>
152
- <linearGradient id={`sparkline-gradient-${title}`} x1="0%" y1="0%" x2="0%" y2="100%">
153
- <stop offset="0%" stopColor={lineColor} stopOpacity={0.3} />
154
- <stop offset="100%" stopColor={lineColor} stopOpacity={0.05} />
155
- </linearGradient>
156
- </defs>
157
- <path d={fillD} fill={`url(#sparkline-gradient-${title})`} />
158
- <path d={pathD} fill="none" stroke={lineColor} strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" />
159
- </svg>
160
- </div>
161
- );
162
- };
163
-
164
- return (
165
- <div
166
- onClick={onClick}
167
- style={{
168
- backgroundColor: theme.colors.surface || theme.colors.background,
169
- border: `1px solid ${theme.colors.border}`,
170
- borderRadius: theme.radii?.[2] || 8,
171
- padding: config.padding,
172
- cursor: onClick ? 'pointer' : 'default',
173
- transition: 'border-color 0.2s, box-shadow 0.2s',
174
- minWidth: size === 'small' ? 140 : size === 'medium' ? 180 : 220,
175
- fontFamily: theme.fonts.body,
176
- }}
177
- onMouseEnter={(e) => {
178
- if (onClick) {
179
- e.currentTarget.style.borderColor = theme.colors.primary || theme.colors.accent;
180
- }
181
- }}
182
- onMouseLeave={(e) => {
183
- e.currentTarget.style.borderColor = theme.colors.border;
184
- }}
185
- >
186
- {/* Title */}
187
- <div
188
- style={{
189
- fontSize: theme.fontSizes[config.titleIndex],
190
- color: theme.colors.textSecondary,
191
- marginBottom: theme.space?.[2] || 8,
192
- fontWeight: theme.fontWeights.medium,
193
- }}
194
- >
195
- {title}
196
- </div>
197
-
198
- {/* Value */}
199
- <div
200
- style={{
201
- display: 'flex',
202
- alignItems: 'baseline',
203
- gap: 4,
204
- }}
205
- >
206
- <span
207
- style={{
208
- fontSize: theme.fontSizes[config.valueIndex],
209
- fontWeight: theme.fontWeights.semibold,
210
- color: getValueColor(),
211
- fontVariantNumeric: 'tabular-nums',
212
- fontFamily: theme.fonts.monospace,
213
- }}
214
- >
215
- {formatValue(value)}
216
- </span>
217
- {unit && (
218
- <span
219
- style={{
220
- fontSize: theme.fontSizes[config.unitIndex],
221
- color: theme.colors.textSecondary,
222
- }}
223
- >
224
- {unit}
225
- </span>
226
- )}
227
- </div>
228
-
229
- {/* Trend */}
230
- {showTrend && (trend || changePercent !== undefined) && (
231
- <div
232
- style={{
233
- display: 'flex',
234
- alignItems: 'center',
235
- marginTop: theme.space?.[2] || 8,
236
- fontSize: theme.fontSizes[config.trendIndex],
237
- color: getTrendColor(),
238
- fontFamily: theme.fonts.monospace,
239
- }}
240
- >
241
- {getTrendIcon()}
242
- {changePercent !== undefined && (
243
- <span>
244
- {changePercent > 0 ? '+' : ''}
245
- {changePercent.toFixed(1)}%
246
- </span>
247
- )}
248
- </div>
249
- )}
250
-
251
- {/* Description */}
252
- {description && (
253
- <div
254
- style={{
255
- fontSize: theme.fontSizes[config.trendIndex],
256
- color: theme.colors.textSecondary,
257
- marginTop: theme.space?.[2] || 8,
258
- lineHeight: theme.lineHeights.body,
259
- opacity: 0.8,
260
- }}
261
- >
262
- {description}
263
- </div>
264
- )}
265
-
266
- {/* Sparkline */}
267
- {renderSparkline()}
268
- </div>
269
- );
270
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * SourceLink
3
- *
4
- * Displays a link to the workflow/canvas that sources a metric.
5
- */
6
-
7
- import { useTheme } from '@principal-ade/industry-theme';
8
- import type { SourceLinkProps } from '../types';
9
-
10
- export function SourceLink({ source, onClick }: SourceLinkProps) {
11
- const { theme } = useTheme();
12
-
13
- const formatSource = () => {
14
- const parts = [source.storyboard, source.workflow];
15
- if (source.nodes && source.nodes.length > 0) {
16
- parts.push(source.nodes.join(', '));
17
- }
18
- if (source.event) {
19
- parts.push(source.event);
20
- }
21
- return parts.join(' → ');
22
- };
23
-
24
- return (
25
- <button
26
- onClick={() => onClick?.(source)}
27
- style={{
28
- display: 'inline-flex',
29
- alignItems: 'center',
30
- gap: 6,
31
- padding: '4px 8px',
32
- fontSize: theme.fontSizes[0],
33
- fontFamily: theme.fonts.body,
34
- color: theme.colors.primary || theme.colors.accent,
35
- backgroundColor: 'transparent',
36
- border: `1px solid ${theme.colors.border}`,
37
- borderRadius: theme.radii?.[1] || 4,
38
- cursor: 'pointer',
39
- transition: 'background-color 0.2s',
40
- }}
41
- onMouseEnter={(e) => {
42
- e.currentTarget.style.backgroundColor = theme.colors.surface || theme.colors.background;
43
- }}
44
- onMouseLeave={(e) => {
45
- e.currentTarget.style.backgroundColor = 'transparent';
46
- }}
47
- >
48
- {/* Link icon */}
49
- <svg
50
- width={12}
51
- height={12}
52
- viewBox="0 0 24 24"
53
- fill="none"
54
- stroke="currentColor"
55
- strokeWidth={2}
56
- >
57
- <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
58
- <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
59
- </svg>
60
- <span style={{ fontFamily: theme.fonts.monospace }}>{formatSource()}</span>
61
- </button>
62
- );
63
- }
@@ -1,280 +0,0 @@
1
- /**
2
- * TimeRangeSelector
3
- *
4
- * Dropdown selector for time range and auto-refresh interval.
5
- */
6
-
7
- import { useState, useRef, useEffect } from 'react';
8
- import { useTheme } from '@principal-ade/industry-theme';
9
- import type { TimeRangeSelectorProps, TimeRangePreset, RefreshInterval } from '../types';
10
-
11
- const PRESET_LABELS: Record<TimeRangePreset, string> = {
12
- last_5m: 'Last 5 minutes',
13
- last_15m: 'Last 15 minutes',
14
- last_30m: 'Last 30 minutes',
15
- last_1h: 'Last 1 hour',
16
- last_3h: 'Last 3 hours',
17
- last_6h: 'Last 6 hours',
18
- last_12h: 'Last 12 hours',
19
- last_24h: 'Last 24 hours',
20
- last_7d: 'Last 7 days',
21
- last_30d: 'Last 30 days',
22
- custom: 'Custom range',
23
- };
24
-
25
- const REFRESH_LABELS: Record<RefreshInterval, string> = {
26
- off: 'Off',
27
- '10s': '10 seconds',
28
- '30s': '30 seconds',
29
- '1m': '1 minute',
30
- '5m': '5 minutes',
31
- '10m': '10 minutes',
32
- };
33
-
34
- const DEFAULT_PRESETS: TimeRangePreset[] = [
35
- 'last_1h',
36
- 'last_3h',
37
- 'last_6h',
38
- 'last_12h',
39
- 'last_24h',
40
- 'last_7d',
41
- ];
42
-
43
- const DEFAULT_REFRESH_INTERVALS: RefreshInterval[] = [
44
- 'off',
45
- '30s',
46
- '1m',
47
- '5m',
48
- ];
49
-
50
- export function TimeRangeSelector({
51
- timeRange,
52
- onTimeRangeChange,
53
- refreshInterval = 'off',
54
- onRefreshIntervalChange,
55
- config,
56
- }: TimeRangeSelectorProps) {
57
- const { theme } = useTheme();
58
- const [isOpen, setIsOpen] = useState(false);
59
- const [activeTab, setActiveTab] = useState<'range' | 'refresh'>('range');
60
- const dropdownRef = useRef<HTMLDivElement>(null);
61
-
62
- const presets = config?.presets ?? DEFAULT_PRESETS;
63
- const refreshIntervals = config?.refreshIntervals ?? DEFAULT_REFRESH_INTERVALS;
64
-
65
- // Close dropdown when clicking outside
66
- useEffect(() => {
67
- const handleClickOutside = (event: MouseEvent) => {
68
- if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
69
- setIsOpen(false);
70
- }
71
- };
72
-
73
- document.addEventListener('mousedown', handleClickOutside);
74
- return () => document.removeEventListener('mousedown', handleClickOutside);
75
- }, []);
76
-
77
- const getCurrentLabel = (): string => {
78
- if (timeRange.preset && timeRange.preset !== 'custom') {
79
- return PRESET_LABELS[timeRange.preset];
80
- }
81
- if (timeRange.start && timeRange.end) {
82
- const formatDate = (d: Date) => d.toLocaleDateString();
83
- return `${formatDate(timeRange.start)} - ${formatDate(timeRange.end)}`;
84
- }
85
- return 'Select time range';
86
- };
87
-
88
- const handlePresetSelect = (preset: TimeRangePreset) => {
89
- onTimeRangeChange({ preset });
90
- setIsOpen(false);
91
- };
92
-
93
- const handleRefreshSelect = (interval: RefreshInterval) => {
94
- onRefreshIntervalChange?.(interval);
95
- setIsOpen(false);
96
- };
97
-
98
- const buttonStyle: React.CSSProperties = {
99
- display: 'flex',
100
- alignItems: 'center',
101
- gap: 8,
102
- padding: '8px 12px',
103
- backgroundColor: theme.colors.surface || theme.colors.background,
104
- border: `1px solid ${theme.colors.border}`,
105
- borderRadius: theme.radii?.[1] || 4,
106
- fontSize: theme.fontSizes[1],
107
- fontFamily: theme.fonts.body,
108
- color: theme.colors.text,
109
- cursor: 'pointer',
110
- transition: 'border-color 0.2s',
111
- };
112
-
113
- const dropdownStyle: React.CSSProperties = {
114
- position: 'absolute',
115
- top: '100%',
116
- right: 0,
117
- marginTop: 4,
118
- minWidth: 200,
119
- backgroundColor: theme.colors.surface || theme.colors.background,
120
- border: `1px solid ${theme.colors.border}`,
121
- borderRadius: theme.radii?.[2] || 8,
122
- boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
123
- zIndex: 1000,
124
- overflow: 'hidden',
125
- };
126
-
127
- const tabStyle = (isActive: boolean): React.CSSProperties => ({
128
- flex: 1,
129
- padding: '8px 12px',
130
- backgroundColor: isActive ? theme.colors.surface : 'transparent',
131
- border: 'none',
132
- borderBottom: isActive ? `2px solid ${theme.colors.primary || theme.colors.accent}` : '2px solid transparent',
133
- fontSize: theme.fontSizes[0],
134
- fontFamily: theme.fonts.body,
135
- fontWeight: isActive ? theme.fontWeights.medium : theme.fontWeights.body,
136
- color: isActive ? theme.colors.text : theme.colors.textSecondary,
137
- cursor: 'pointer',
138
- });
139
-
140
- const optionStyle = (isSelected: boolean): React.CSSProperties => ({
141
- display: 'flex',
142
- alignItems: 'center',
143
- justifyContent: 'space-between',
144
- padding: '8px 12px',
145
- backgroundColor: isSelected ? (theme.colors.primary || theme.colors.accent) + '15' : 'transparent',
146
- border: 'none',
147
- width: '100%',
148
- textAlign: 'left',
149
- fontSize: theme.fontSizes[1],
150
- fontFamily: theme.fonts.body,
151
- color: theme.colors.text,
152
- cursor: 'pointer',
153
- transition: 'background-color 0.15s',
154
- });
155
-
156
- return (
157
- <div ref={dropdownRef} style={{ position: 'relative', display: 'inline-block' }}>
158
- {/* Main button */}
159
- <button
160
- onClick={() => setIsOpen(!isOpen)}
161
- style={buttonStyle}
162
- onMouseEnter={(e) => {
163
- e.currentTarget.style.borderColor = theme.colors.primary || theme.colors.accent;
164
- }}
165
- onMouseLeave={(e) => {
166
- e.currentTarget.style.borderColor = theme.colors.border;
167
- }}
168
- >
169
- {/* Clock icon */}
170
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
171
- <circle cx="12" cy="12" r="10" />
172
- <polyline points="12 6 12 12 16 14" />
173
- </svg>
174
- <span>{getCurrentLabel()}</span>
175
- {/* Chevron */}
176
- <svg
177
- width={12}
178
- height={12}
179
- viewBox="0 0 24 24"
180
- fill="none"
181
- stroke="currentColor"
182
- strokeWidth={2}
183
- style={{ transform: isOpen ? 'rotate(180deg)' : 'rotate(0)', transition: 'transform 0.2s' }}
184
- >
185
- <polyline points="6 9 12 15 18 9" />
186
- </svg>
187
- {/* Refresh indicator */}
188
- {refreshInterval !== 'off' && (
189
- <span
190
- style={{
191
- marginLeft: 4,
192
- padding: '2px 6px',
193
- backgroundColor: theme.colors.primary || theme.colors.accent,
194
- color: theme.colors.background,
195
- fontSize: theme.fontSizes[0],
196
- borderRadius: theme.radii?.[1] || 4,
197
- fontWeight: theme.fontWeights.medium,
198
- }}
199
- >
200
- {refreshInterval}
201
- </span>
202
- )}
203
- </button>
204
-
205
- {/* Dropdown */}
206
- {isOpen && (
207
- <div style={dropdownStyle}>
208
- {/* Tabs */}
209
- {onRefreshIntervalChange && (
210
- <div style={{ display: 'flex', borderBottom: `1px solid ${theme.colors.border}` }}>
211
- <button style={tabStyle(activeTab === 'range')} onClick={() => setActiveTab('range')}>
212
- Time Range
213
- </button>
214
- <button style={tabStyle(activeTab === 'refresh')} onClick={() => setActiveTab('refresh')}>
215
- Auto Refresh
216
- </button>
217
- </div>
218
- )}
219
-
220
- {/* Options */}
221
- <div style={{ maxHeight: 300, overflowY: 'auto' }}>
222
- {activeTab === 'range' &&
223
- presets.map((preset) => (
224
- <button
225
- key={preset}
226
- onClick={() => handlePresetSelect(preset)}
227
- style={optionStyle(timeRange.preset === preset)}
228
- onMouseEnter={(e) => {
229
- if (timeRange.preset !== preset) {
230
- e.currentTarget.style.backgroundColor = theme.colors.border + '40';
231
- }
232
- }}
233
- onMouseLeave={(e) => {
234
- e.currentTarget.style.backgroundColor =
235
- timeRange.preset === preset
236
- ? (theme.colors.primary || theme.colors.accent) + '15'
237
- : 'transparent';
238
- }}
239
- >
240
- <span>{PRESET_LABELS[preset]}</span>
241
- {timeRange.preset === preset && (
242
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
243
- <polyline points="20 6 9 17 4 12" />
244
- </svg>
245
- )}
246
- </button>
247
- ))}
248
-
249
- {activeTab === 'refresh' &&
250
- refreshIntervals.map((interval) => (
251
- <button
252
- key={interval}
253
- onClick={() => handleRefreshSelect(interval)}
254
- style={optionStyle(refreshInterval === interval)}
255
- onMouseEnter={(e) => {
256
- if (refreshInterval !== interval) {
257
- e.currentTarget.style.backgroundColor = theme.colors.border + '40';
258
- }
259
- }}
260
- onMouseLeave={(e) => {
261
- e.currentTarget.style.backgroundColor =
262
- refreshInterval === interval
263
- ? (theme.colors.primary || theme.colors.accent) + '15'
264
- : 'transparent';
265
- }}
266
- >
267
- <span>{REFRESH_LABELS[interval]}</span>
268
- {refreshInterval === interval && (
269
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
270
- <polyline points="20 6 9 17 4 12" />
271
- </svg>
272
- )}
273
- </button>
274
- ))}
275
- </div>
276
- </div>
277
- )}
278
- </div>
279
- );
280
- }
@@ -1,5 +0,0 @@
1
- export { MetricCard } from './MetricCard';
2
- export { LineChart } from './LineChart';
3
- export { BarChart } from './BarChart';
4
- export { SourceLink } from './SourceLink';
5
- export { TimeRangeSelector } from './TimeRangeSelector';
@@ -1,47 +0,0 @@
1
- // Main renderer
2
- export { DashboardRenderer } from './DashboardRenderer';
3
- export { MetricPanel } from './MetricPanel';
4
-
5
- // Individual components
6
- export { MetricCard, LineChart, BarChart, SourceLink, TimeRangeSelector } from './components';
7
-
8
- // Data providers
9
- export { MockDataProvider, createMockDataProvider } from './MockDataProvider';
10
-
11
- // Types
12
- export type {
13
- // Dashboard definition types
14
- DashboardDefinition,
15
- MetricDefinition,
16
- MetricType,
17
- MetricSource,
18
- MetricQuery,
19
- Derivation,
20
- TimeGroup,
21
- AlertDefinition,
22
- MetricDisplay,
23
- DisplayComponent,
24
- DashboardLayout,
25
- DashboardRow,
26
- PanelPlacement,
27
- // Time range types
28
- TimeRangePreset,
29
- TimeRange,
30
- RefreshInterval,
31
- TimeRangeConfig,
32
- // Mock data types
33
- MockMetricData,
34
- TimeSeriesPoint,
35
- HistogramData,
36
- // Runtime types
37
- MetricData,
38
- DataProvider,
39
- // Component props
40
- DashboardRendererProps,
41
- MetricPanelProps,
42
- MetricCardProps,
43
- LineChartProps,
44
- BarChartProps,
45
- SourceLinkProps,
46
- TimeRangeSelectorProps,
47
- } from './types';