@agentmark-ai/ui-components 0.1.0 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { GridFilterModel, GridSortModel, DataGridProps } from '@mui/x-data-grid';
3
3
  import * as React$1 from 'react';
4
- import React__default, { ReactNode, ComponentProps } from 'react';
4
+ import React__default, { ReactNode, Component, ComponentProps } from 'react';
5
5
  import { SxProps, Theme } from '@mui/material/styles';
6
6
  import { Node, Edge } from '@xyflow/react';
7
7
  import { UseTreeItemParameters } from '@mui/x-tree-view/useTreeItem';
@@ -490,6 +490,385 @@ interface TraceGraphCanvasProps {
490
490
  }
491
491
  declare function TraceGraphCanvas({ graphData, isLoading, }: TraceGraphCanvasProps): react_jsx_runtime.JSX.Element;
492
492
 
493
+ /**
494
+ * Timeline Types for Trace Timeline View
495
+ *
496
+ * TypeScript interfaces for timeline-specific computed values.
497
+ * Operates on existing SpanData with no data model changes.
498
+ */
499
+
500
+ /**
501
+ * Computed layout for a single span bar in the timeline.
502
+ */
503
+ interface TimelineBarLayout {
504
+ /** Original span ID */
505
+ spanId: string;
506
+ /** Span name for display */
507
+ name: string;
508
+ /** Horizontal position (0-1 normalized) */
509
+ x: number;
510
+ /** Bar width (0-1 normalized) */
511
+ width: number;
512
+ /** Vertical row index (0-based) */
513
+ row: number;
514
+ /** Nesting depth (0 = root) */
515
+ depth: number;
516
+ /** Duration in milliseconds */
517
+ durationMs: number;
518
+ /** Start time in milliseconds (relative to trace start) */
519
+ startTimeMs: number;
520
+ /** Percentage of total trace duration */
521
+ percentOfTrace: number;
522
+ /** Node type for coloring (reuses WorkflowNodeType) */
523
+ nodeType: WorkflowNodeType;
524
+ /** Error indicator */
525
+ hasError: boolean;
526
+ /** Reference to original span */
527
+ span: SpanData;
528
+ }
529
+ /**
530
+ * Zoom/pan state for the timeline viewport.
531
+ */
532
+ interface TimelineViewState {
533
+ /** SVG viewBox dimensions */
534
+ viewBox: {
535
+ x: number;
536
+ y: number;
537
+ width: number;
538
+ height: number;
539
+ };
540
+ /** Current zoom scale (1 = 100%) */
541
+ scale: number;
542
+ /** Whether user is currently panning */
543
+ isPanning: boolean;
544
+ }
545
+ /**
546
+ * Aggregate metrics for the timeline.
547
+ */
548
+ interface TimelineMetrics {
549
+ /** Total trace duration in milliseconds */
550
+ totalDurationMs: number;
551
+ /** Trace start time (earliest span timestamp) */
552
+ startTimeMs: number;
553
+ /** Trace end time (latest span end) */
554
+ endTimeMs: number;
555
+ /** Total number of spans */
556
+ spanCount: number;
557
+ /** Maximum nesting depth */
558
+ maxDepth: number;
559
+ /** Count of spans by type */
560
+ typeBreakdown: Partial<Record<WorkflowNodeType, number>>;
561
+ }
562
+ /**
563
+ * Time axis tick mark for the ruler.
564
+ */
565
+ interface TimelineRulerTick {
566
+ /** Position on the axis (0-1 normalized) */
567
+ position: number;
568
+ /** Display label (e.g., "0ms", "500ms", "1.2s") */
569
+ label: string;
570
+ /** Whether this is a major tick (larger, with label) */
571
+ isMajor: boolean;
572
+ }
573
+ /**
574
+ * Layout constants for timeline rendering.
575
+ */
576
+ declare const TIMELINE_CONSTANTS: {
577
+ /** Height of each span row in pixels */
578
+ readonly ROW_HEIGHT: 28;
579
+ /** Minimum bar width in pixels (for very short spans) */
580
+ readonly MIN_BAR_WIDTH: 4;
581
+ /** Indentation per depth level in pixels */
582
+ readonly DEPTH_INDENT: 16;
583
+ /** Bar height as ratio of row height */
584
+ readonly BAR_HEIGHT_RATIO: 0.7;
585
+ /** Minimum zoom scale */
586
+ readonly MIN_SCALE: 0.5;
587
+ /** Maximum zoom scale */
588
+ readonly MAX_SCALE: 10;
589
+ /** Height of the time ruler in pixels */
590
+ readonly RULER_HEIGHT: 24;
591
+ /** Padding around the timeline content */
592
+ readonly PADDING: 8;
593
+ /** Label area width for span names */
594
+ readonly LABEL_WIDTH: 120;
595
+ };
596
+ /**
597
+ * Props for the TimelineBar component.
598
+ */
599
+ interface TimelineBarProps {
600
+ /** Computed layout for this bar */
601
+ layout: TimelineBarLayout;
602
+ /** Whether this bar is currently selected */
603
+ isSelected: boolean;
604
+ /** Whether this bar is currently focused (keyboard navigation) */
605
+ isFocused?: boolean;
606
+ /** Callback when bar is clicked */
607
+ onSelect?: (spanId: string) => void;
608
+ /** Callback when mouse enters bar */
609
+ onMouseEnter?: (layout: TimelineBarLayout, event: React.MouseEvent) => void;
610
+ /** Callback when mouse leaves bar */
611
+ onMouseLeave?: () => void;
612
+ /** Total width of the timeline area in pixels */
613
+ timelineWidth: number;
614
+ }
615
+ /**
616
+ * Props for the TimelineRuler component.
617
+ */
618
+ interface TimelineRulerProps {
619
+ /** Tick marks to display */
620
+ ticks: TimelineRulerTick[];
621
+ /** Total width of the ruler in pixels */
622
+ width: number;
623
+ /** Height of the ruler in pixels */
624
+ height?: number;
625
+ }
626
+ /**
627
+ * Props for the TimelineTooltip component.
628
+ */
629
+ interface TimelineTooltipProps {
630
+ /** Layout data for the hovered span */
631
+ layout: TimelineBarLayout | null;
632
+ /** Tooltip position */
633
+ position: {
634
+ x: number;
635
+ y: number;
636
+ } | null;
637
+ /** Whether tooltip is visible */
638
+ visible: boolean;
639
+ }
640
+ /**
641
+ * Props for the TimelineLegend component.
642
+ */
643
+ interface TimelineLegendProps {
644
+ /** Type breakdown from metrics */
645
+ typeBreakdown: Partial<Record<WorkflowNodeType, number>>;
646
+ /** Whether to show counts */
647
+ showCounts?: boolean;
648
+ }
649
+ /**
650
+ * Props for the main TraceTimeline component.
651
+ */
652
+ interface TraceTimelineProps {
653
+ /** Spans to visualize */
654
+ spans: SpanData[];
655
+ /** Currently selected span ID */
656
+ selectedSpanId?: string;
657
+ /** Callback when a span is selected */
658
+ onSelectSpan?: (spanId: string) => void;
659
+ /** Whether to show the time ruler */
660
+ showRuler?: boolean;
661
+ /** Whether to show the type legend */
662
+ showLegend?: boolean;
663
+ /** Whether to enable mouse wheel zoom */
664
+ enableZoom?: boolean;
665
+ /** Whether to enable drag to pan */
666
+ enablePan?: boolean;
667
+ /** Custom styles */
668
+ sx?: Record<string, unknown>;
669
+ /** Loading state */
670
+ isLoading?: boolean;
671
+ }
672
+ /**
673
+ * Return type for useTimelineLayout hook.
674
+ */
675
+ interface UseTimelineLayoutResult {
676
+ /** Computed layouts for all spans */
677
+ layouts: TimelineBarLayout[];
678
+ /** Aggregate metrics */
679
+ metrics: TimelineMetrics;
680
+ /** Ruler tick marks */
681
+ rulerTicks: TimelineRulerTick[];
682
+ }
683
+ /**
684
+ * Return type for useTimelineZoom hook.
685
+ */
686
+ interface UseTimelineZoomResult {
687
+ /** Current view state */
688
+ viewState: TimelineViewState;
689
+ /** Zoom in by a factor */
690
+ zoomIn: () => void;
691
+ /** Zoom out by a factor */
692
+ zoomOut: () => void;
693
+ /** Reset to fit all content */
694
+ resetZoom: () => void;
695
+ /** Set zoom to specific scale */
696
+ setScale: (scale: number) => void;
697
+ /** Handler for mouse wheel events */
698
+ onWheel: (event: React.WheelEvent) => void;
699
+ /** Handlers for pan (drag) events */
700
+ panHandlers: {
701
+ onMouseDown: (event: React.MouseEvent) => void;
702
+ onMouseMove: (event: React.MouseEvent) => void;
703
+ onMouseUp: () => void;
704
+ onMouseLeave: () => void;
705
+ };
706
+ }
707
+
708
+ /**
709
+ * computeTimelineLayout - Pure function for timeline layout computation
710
+ *
711
+ * Computes timeline bar layouts from span data using depth-first traversal.
712
+ * Handles hierarchical positioning, concurrent span detection, and time normalization.
713
+ *
714
+ * This is extracted as a pure function to enable direct unit testing without React context.
715
+ */
716
+
717
+ /**
718
+ * Format duration for display.
719
+ * @param ms Duration in milliseconds
720
+ * @returns Formatted string (e.g., "500ms", "1.2s", "2m 30s")
721
+ */
722
+ declare function formatDuration(ms: number): string;
723
+ /**
724
+ * Compute timeline layouts from span data.
725
+ *
726
+ * @param spans Array of span data to visualize
727
+ * @returns Computed layouts, metrics, and ruler ticks
728
+ */
729
+ declare function computeTimelineLayout(spans: SpanData[]): UseTimelineLayoutResult;
730
+
731
+ /**
732
+ * useTimelineLayout Hook
733
+ *
734
+ * React hook wrapper around computeTimelineLayout.
735
+ * Provides memoization for performance optimization.
736
+ */
737
+
738
+ /**
739
+ * Hook to compute timeline layouts from span data.
740
+ *
741
+ * @param spans Array of span data to visualize
742
+ * @returns Computed layouts, metrics, and ruler ticks
743
+ */
744
+ declare function useTimelineLayout(spans: SpanData[]): UseTimelineLayoutResult;
745
+
746
+ /**
747
+ * useTimelineZoom Hook
748
+ *
749
+ * Manages zoom and pan state for the timeline SVG viewport.
750
+ * Supports mouse wheel zoom, drag-to-pan, and programmatic zoom controls.
751
+ */
752
+
753
+ /**
754
+ * Hook to manage timeline zoom and pan state.
755
+ *
756
+ * @param contentWidth Total width of the timeline content
757
+ * @param contentHeight Total height of the timeline content
758
+ * @returns Zoom state and control handlers
759
+ */
760
+ declare function useTimelineZoom(contentWidth?: number, contentHeight?: number): UseTimelineZoomResult;
761
+
762
+ /**
763
+ * useTimelineViewPreference Hook
764
+ *
765
+ * Manages user preference for graph vs timeline view with localStorage persistence.
766
+ * Used by consuming applications to implement view toggle functionality.
767
+ */
768
+ /** Available trace view types */
769
+ type TraceViewType = "graph" | "timeline";
770
+ /**
771
+ * Hook to manage trace view preference with localStorage persistence.
772
+ *
773
+ * @returns Current view, setter, and toggle function
774
+ */
775
+ declare function useTimelineViewPreference(): {
776
+ /** Current view type */
777
+ view: TraceViewType;
778
+ /** Set view to specific type */
779
+ setView: (newView: TraceViewType) => void;
780
+ /** Toggle between graph and timeline */
781
+ toggleView: () => void;
782
+ /** Whether current view is timeline */
783
+ isTimeline: boolean;
784
+ /** Whether current view is graph */
785
+ isGraph: boolean;
786
+ };
787
+
788
+ /**
789
+ * TraceTimeline Component
790
+ *
791
+ * Main container for the trace timeline visualization.
792
+ * Displays spans as horizontal bars positioned by start time and sized by duration.
793
+ */
794
+
795
+ /**
796
+ * TraceTimeline component displays spans as a waterfall timeline.
797
+ */
798
+ declare const TraceTimeline: React__default.NamedExoticComponent<TraceTimelineProps>;
799
+
800
+ /**
801
+ * TimelineBar Component
802
+ *
803
+ * Renders a single span bar in the timeline visualization.
804
+ * Displays the span as a horizontal bar with appropriate positioning, sizing, and styling.
805
+ */
806
+
807
+ /**
808
+ * TimelineBar component renders a single span bar.
809
+ */
810
+ declare const TimelineBar: React__default.NamedExoticComponent<TimelineBarProps>;
811
+
812
+ /**
813
+ * TimelineRuler Component
814
+ *
815
+ * Renders the time axis with tick marks and labels for the timeline.
816
+ */
817
+
818
+ /**
819
+ * TimelineRuler component renders the time axis.
820
+ */
821
+ declare const TimelineRuler: React__default.NamedExoticComponent<TimelineRulerProps>;
822
+
823
+ /**
824
+ * TimelineTooltip Component
825
+ *
826
+ * Displays hover tooltip with span details for the timeline.
827
+ */
828
+
829
+ /**
830
+ * TimelineTooltip component displays span details on hover.
831
+ */
832
+ declare const TimelineTooltip: React__default.NamedExoticComponent<TimelineTooltipProps>;
833
+
834
+ /**
835
+ * TimelineLegend Component
836
+ *
837
+ * Displays a legend showing span type colors for the timeline.
838
+ */
839
+
840
+ /**
841
+ * TimelineLegend component displays span type colors.
842
+ */
843
+ declare const TimelineLegend: React__default.NamedExoticComponent<TimelineLegendProps>;
844
+
845
+ /**
846
+ * TimelineErrorBoundary Component
847
+ *
848
+ * Error boundary to gracefully handle rendering errors in the timeline.
849
+ * Prevents crashes from malformed span data from breaking the entire UI.
850
+ */
851
+
852
+ interface TimelineErrorBoundaryProps {
853
+ children: ReactNode;
854
+ fallback?: ReactNode;
855
+ }
856
+ interface TimelineErrorBoundaryState {
857
+ hasError: boolean;
858
+ error: Error | null;
859
+ }
860
+ /**
861
+ * Error boundary for the timeline component.
862
+ * Catches rendering errors and displays a fallback UI.
863
+ */
864
+ declare class TimelineErrorBoundary extends Component<TimelineErrorBoundaryProps, TimelineErrorBoundaryState> {
865
+ constructor(props: TimelineErrorBoundaryProps);
866
+ static getDerivedStateFromError(error: Error): TimelineErrorBoundaryState;
867
+ componentDidCatch(error: Error, errorInfo: React__default.ErrorInfo): void;
868
+ handleRetry: () => void;
869
+ render(): ReactNode;
870
+ }
871
+
493
872
  interface SpanInfoContentProps {
494
873
  children: React.ReactNode;
495
874
  }
@@ -670,4 +1049,4 @@ declare function JsonEditor({ defaultValue, onChange, value, }: {
670
1049
  value?: string;
671
1050
  }): react_jsx_runtime.JSX.Element;
672
1051
 
673
- export { AddAnnotationDialog, AddAnnotations, AttributesTab, AttributesViewer, DataGrid, EmptyContent, EvaluationList, EvaluationProvider, EvaluationTab, FormProvider, Iconify, InputOutputTab, JsonEditor, type LLMPrompt, type LLMText, Label, type LabelColor, type LabelProps, type LabelVariant, type LayoutResult, NODE_DIMENSIONS, type NodeGroup, type NodeTypeStyle, OutputDisplay, PromptList, RHFJsonEditor, RHFMultiSelect, RHFSelect, RHFSlider, RHFSwitch, RHFTextField, type Request, Requests, type ScoreData, type Session, type SessionData, SessionsList, type SessionsListProps, type SpanData, type SpanForGrouping, SpanInfoContent, SpanInfoHeader, SpanInfoProvider, SpanInfoTabs, SpanInfoTitle, TableEmptyRows, TableHeadCustom, TablePaginationCustom, type TableProps, TableSelectedAction, TableSkeleton, type Trace, type TraceData, TraceDrawer, TraceDrawerCloseButton, TraceDrawerContainer, TraceDrawerContent, type TraceDrawerContextValue, TraceDrawerHeader, TraceDrawerMain, TraceDrawerProvider, type TraceDrawerProviderProps, TraceDrawerSidebar, TraceDrawerSidebarSectionResizer, TraceDrawerSubtitle, TraceDrawerTitle, TraceGraphCanvas, type TraceGraphCanvasProps, TraceInfoSkeleton, TraceLabel, type TraceListContextValue, TraceListItem, TraceListProvider, TraceTree, TraceTreeItem, TracesList, type TracesListProps, type WorkflowNodeType, applyDagreLayout, calculateBranchFamilies, getBranchColor, getDisplayName, getNodeTypeStyle, groupSpansByKey, hasChildSpans, inferNodeType, makeGroupKey, useEvaluationContext, useSpanInfoContext, useTable, useTraceDrawer, useTraceDrawerContext, useTraceListContext };
1052
+ export { AddAnnotationDialog, AddAnnotations, AttributesTab, AttributesViewer, DataGrid, EmptyContent, EvaluationList, EvaluationProvider, EvaluationTab, FormProvider, Iconify, InputOutputTab, JsonEditor, type LLMPrompt, type LLMText, Label, type LabelColor, type LabelProps, type LabelVariant, type LayoutResult, NODE_DIMENSIONS, type NodeGroup, type NodeTypeStyle, OutputDisplay, PromptList, RHFJsonEditor, RHFMultiSelect, RHFSelect, RHFSlider, RHFSwitch, RHFTextField, type Request, Requests, type ScoreData, type Session, type SessionData, SessionsList, type SessionsListProps, type SpanData, type SpanForGrouping, SpanInfoContent, SpanInfoHeader, SpanInfoProvider, SpanInfoTabs, SpanInfoTitle, TIMELINE_CONSTANTS, TableEmptyRows, TableHeadCustom, TablePaginationCustom, type TableProps, TableSelectedAction, TableSkeleton, TimelineBar, type TimelineBarLayout, type TimelineBarProps, TimelineErrorBoundary, TimelineLegend, type TimelineLegendProps, type TimelineMetrics, TimelineRuler, type TimelineRulerProps, type TimelineRulerTick, TimelineTooltip, type TimelineTooltipProps, type TimelineViewState, type Trace, type TraceData, TraceDrawer, TraceDrawerCloseButton, TraceDrawerContainer, TraceDrawerContent, type TraceDrawerContextValue, TraceDrawerHeader, TraceDrawerMain, TraceDrawerProvider, type TraceDrawerProviderProps, TraceDrawerSidebar, TraceDrawerSidebarSectionResizer, TraceDrawerSubtitle, TraceDrawerTitle, TraceGraphCanvas, type TraceGraphCanvasProps, TraceInfoSkeleton, TraceLabel, type TraceListContextValue, TraceListItem, TraceListProvider, TraceTimeline, type TraceTimelineProps, TraceTree, TraceTreeItem, type TraceViewType, TracesList, type TracesListProps, type UseTimelineLayoutResult, type UseTimelineZoomResult, type WorkflowNodeType, applyDagreLayout, calculateBranchFamilies, computeTimelineLayout, formatDuration, getBranchColor, getDisplayName, getNodeTypeStyle, groupSpansByKey, hasChildSpans, inferNodeType, makeGroupKey, useEvaluationContext, useSpanInfoContext, useTable, useTimelineLayout, useTimelineViewPreference, useTimelineZoom, useTraceDrawer, useTraceDrawerContext, useTraceListContext };