@moderneinc/react-charts 1.1.0 → 1.2.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 (19) hide show
  1. package/dist/components/parliament-chart/hooks/{useParliamentChart.d.ts → use-parliament-chart.hook.d.ts} +1 -1
  2. package/dist/components/parliament-chart/{ParliamentChart.d.ts → parliament-chart.component.d.ts} +1 -1
  3. package/dist/components/parliament-chart/{ParliamentChart.types.d.ts → parliament-chart.types.d.ts} +1 -1
  4. package/dist/components/timeline-chart/hooks/use-timeline-chart.hook.d.ts +2 -0
  5. package/dist/components/timeline-chart/timeline-chart.component.d.ts +9 -0
  6. package/dist/components/timeline-chart/timeline-chart.types.d.ts +112 -0
  7. package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
  8. package/dist/index.cjs +11 -11
  9. package/dist/index.d.ts +11 -8
  10. package/dist/index.js +2945 -2438
  11. package/dist/theme/timeline-defaults.d.ts +50 -0
  12. package/package.json +5 -4
  13. /package/dist/components/parliament-chart/{ParliamentChart.constants.d.ts → parliament-chart.constants.d.ts} +0 -0
  14. /package/dist/components/parliament-chart/utils/{parliamentArcCalculator.d.ts → parliament-arc-calculator.d.ts} +0 -0
  15. /package/dist/components/parliament-chart/utils/{parliamentChartData.utils.d.ts → parliament-chart-data.utils.d.ts} +0 -0
  16. /package/dist/components/parliament-chart/utils/{parliamentSvgEnhanced.d.ts → parliament-svg-enhanced.d.ts} +0 -0
  17. /package/dist/components/parliament-chart/utils/{parliamentSvgPatterns.d.ts → parliament-svg-patterns.d.ts} +0 -0
  18. /package/dist/components/parliament-chart/utils/{parliamentSvg.d.ts → parliament-svg.d.ts} +0 -0
  19. /package/dist/theme/{defaultColors.d.ts → default-colors.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { ChartConfig, HoveredData, ProcessedDataItem } from '../ParliamentChart.types';
2
+ import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
3
3
  type UseParliamentChartProps = {
4
4
  containerRef: RefObject<HTMLDivElement>;
5
5
  processedData: ProcessedDataItem[];
@@ -1,5 +1,5 @@
1
1
  import { FunctionComponent } from 'react';
2
- import { ParliamentChartProps } from './ParliamentChart.types';
2
+ import { ParliamentChartProps } from './parliament-chart.types';
3
3
  /**
4
4
  * Renders an interactive parliament-style chart visualization for repository statistics.
5
5
  * Displays repository counts as seats in a semi-circular or arc layout, with scaling
@@ -1,4 +1,4 @@
1
- import { ParliamentChartTheme } from '../../theme/defaultColors';
1
+ import { ParliamentChartTheme } from '../../theme/default-colors';
2
2
  type ParliamentDataSeries = {
3
3
  value: number;
4
4
  label: string;
@@ -0,0 +1,2 @@
1
+ import { UseTimelineChartProps, UseTimelineChartReturn } from '../timeline-chart.types';
2
+ export declare const useTimelineChart: ({ events, selectedRange, onSelectionChange, enableZoom, zoomToSelection, visibleRange, onVisibleRangeChange }: UseTimelineChartProps) => UseTimelineChartReturn;
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { TimelineChartProps } from './timeline-chart.types';
3
+ /**
4
+ * TimelineChart component - Interactive timeline with drag selection and zoom
5
+ *
6
+ * Displays events on a timeline with interactive selection capabilities.
7
+ * Users can click and drag to select date ranges, and use mouse wheel to zoom.
8
+ */
9
+ export declare const TimelineChart: FunctionComponent<TimelineChartProps>;
@@ -0,0 +1,112 @@
1
+ import { BoxProps, StackProps, TypographyProps } from '@mui/material';
2
+ export type TimelineEvent = {
3
+ date: Date;
4
+ timestamp: number;
5
+ eventName: string;
6
+ [key: string]: unknown;
7
+ };
8
+ export type TimelineSelection = {
9
+ start: number | null;
10
+ end: number | null;
11
+ };
12
+ export type TimelineChartSlotProps = {
13
+ /** Props for the header container (Stack) */
14
+ header?: StackProps;
15
+ /** Props for the title Typography component */
16
+ title?: TypographyProps;
17
+ /** Props for the instructions Typography component */
18
+ instructions?: TypographyProps;
19
+ /** Props for the month labels container (Stack) */
20
+ monthLabelsContainer?: StackProps;
21
+ /** Props for individual month label Typography components */
22
+ monthLabel?: TypographyProps;
23
+ /** Props for the timeline container (Box) */
24
+ timeline?: BoxProps;
25
+ /** Props for individual event markers (Box) */
26
+ event?: BoxProps;
27
+ /** Props for the selection highlight overlay (Box) */
28
+ selection?: BoxProps;
29
+ /** Props for the hover tooltip container (Box) */
30
+ tooltip?: BoxProps;
31
+ /** Props for the tooltip event name Typography component */
32
+ tooltipEventName?: TypographyProps;
33
+ /** Props for the tooltip date Typography component */
34
+ tooltipDate?: TypographyProps;
35
+ };
36
+ export type TimelineChartProps = {
37
+ /** Array of events to display on the timeline (must be sorted by timestamp) */
38
+ events: TimelineEvent[];
39
+ /** Callback when selection changes */
40
+ onSelectionChange?: (selection: TimelineSelection) => void;
41
+ /** Controlled selection state (optional) */
42
+ selectedRange?: TimelineSelection;
43
+ /** Height of the timeline container in pixels (default: 32) */
44
+ height?: number;
45
+ /** Custom date formatter */
46
+ formatDate?: (timestamp: number) => string;
47
+ /** Custom month/year formatter */
48
+ formatMonthYear?: (timestamp: number) => string;
49
+ /** Show month labels at top */
50
+ showMonthLabels?: boolean;
51
+ /** Number of month labels to display (default: 6) */
52
+ monthLabelCount?: number;
53
+ /** Enable zoom with mouse wheel */
54
+ enableZoom?: boolean;
55
+ /** Show header title and instructions (default: true) */
56
+ showHeader?: boolean;
57
+ /** Custom title for the header */
58
+ title?: string;
59
+ /**
60
+ * Zoom to selection mode - When enabled, dragging to select a range
61
+ * will automatically rescale the timeline to show only that range.
62
+ * Selection highlight only shows during drag.
63
+ */
64
+ zoomToSelection?: boolean;
65
+ /** Callback when the visible range changes (for zoom to selection mode) */
66
+ onVisibleRangeChange?: (range: TimelineSelection) => void;
67
+ /** Controlled visible range (for zoom to selection mode) */
68
+ visibleRange?: TimelineSelection;
69
+ /** Props for individual component slots */
70
+ slotProps?: TimelineChartSlotProps;
71
+ };
72
+ export type UseTimelineChartProps = {
73
+ events: TimelineEvent[];
74
+ selectedRange?: TimelineSelection;
75
+ onSelectionChange?: (selection: TimelineSelection) => void;
76
+ enableZoom: boolean;
77
+ zoomToSelection: boolean;
78
+ visibleRange?: TimelineSelection;
79
+ onVisibleRangeChange?: (range: TimelineSelection) => void;
80
+ };
81
+ export type UseTimelineChartReturn = {
82
+ isDragging: boolean;
83
+ dragStart: number | null;
84
+ internalSelectedRange: TimelineSelection;
85
+ internalVisibleRange: TimelineSelection;
86
+ hoveredEvent: TimelineEvent | null;
87
+ minDate: number;
88
+ maxDate: number;
89
+ timeSpan: number;
90
+ getPositionFromTimestamp: (timestamp: number) => number;
91
+ getTimestampFromPosition: (x: number, containerWidth: number) => number;
92
+ handleMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
93
+ handleMouseMove: (e: React.MouseEvent<HTMLDivElement>) => void;
94
+ handleMouseUp: () => void;
95
+ handleWheel: (e: React.WheelEvent<HTMLDivElement>) => void;
96
+ handleDoubleClick: () => void;
97
+ setHoveredEvent: (event: TimelineEvent | null) => void;
98
+ getEventsInRange: () => TimelineEvent[];
99
+ resetZoom: () => void;
100
+ };
101
+ export type TimelineSelectedEventsProps = {
102
+ /** Array of selected events to display */
103
+ events: TimelineEvent[];
104
+ /** Title for the selected events section */
105
+ title?: string;
106
+ /** Maximum height before scrolling */
107
+ maxHeight?: string;
108
+ /** Custom date formatter */
109
+ formatDate?: (timestamp: number) => string;
110
+ /** Primary color for event items */
111
+ primaryColor?: string;
112
+ };
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { TimelineSelectedEventsProps } from './timeline-chart.types';
3
+ /**
4
+ * TimelineSelectedEvents component - Displays selected events from timeline
5
+ *
6
+ * This component observes and displays events that have been selected in a timeline.
7
+ * It can be used independently alongside the TimelineChart component.
8
+ */
9
+ export declare const TimelineSelectedEvents: FunctionComponent<TimelineSelectedEventsProps>;