@moderneinc/react-charts 1.1.0-next.203e4f
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/LICENSE +24 -0
- package/README.md +44 -0
- package/dist/components/parliament-chart/hooks/use-parliament-chart.hook.d.ts +22 -0
- package/dist/components/parliament-chart/parliament-chart.component.d.ts +8 -0
- package/dist/components/parliament-chart/parliament-chart.constants.d.ts +40 -0
- package/dist/components/parliament-chart/parliament-chart.types.d.ts +36 -0
- package/dist/components/parliament-chart/utils/parliament-arc-calculator.d.ts +27 -0
- package/dist/components/parliament-chart/utils/parliament-chart-data.utils.d.ts +18 -0
- package/dist/components/parliament-chart/utils/parliament-svg-enhanced.d.ts +28 -0
- package/dist/components/parliament-chart/utils/parliament-svg-patterns.d.ts +35 -0
- package/dist/components/parliament-chart/utils/parliament-svg.d.ts +20 -0
- package/dist/components/timeline-chart/hooks/use-timeline-chart.hook.d.ts +2 -0
- package/dist/components/timeline-chart/timeline-chart.component.d.ts +9 -0
- package/dist/components/timeline-chart/timeline-chart.types.d.ts +112 -0
- package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +5890 -0
- package/dist/theme/default-colors.d.ts +30 -0
- package/dist/theme/timeline-defaults.d.ts +50 -0
- package/package.json +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @moderneinc/react-charts
|
|
2
|
+
|
|
3
|
+
A React component library for parliament-style chart visualizations, perfect for displaying repository statistics, compliance metrics, and migration progress.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @moderneinc/react-charts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer Dependencies
|
|
12
|
+
|
|
13
|
+
This package requires the following peer dependencies:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
18
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
19
|
+
"@mui/material": ">=7.0.0",
|
|
20
|
+
"@mui/icons-material": ">=7.0.0",
|
|
21
|
+
"@emotion/react": ">=11.0.0",
|
|
22
|
+
"@emotion/styled": ">=11.0.0"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
### Run Storybook
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run storybook
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Build Library
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Run Tests
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm test
|
|
44
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
|
|
3
|
+
type UseParliamentChartProps = {
|
|
4
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
5
|
+
processedData: ProcessedDataItem[];
|
|
6
|
+
totalRepositories: number;
|
|
7
|
+
arcAngle: number;
|
|
8
|
+
useEnhanced: boolean;
|
|
9
|
+
maxSeats: number;
|
|
10
|
+
setHoveredData: (data: HoveredData) => void;
|
|
11
|
+
activePartyName: string | null;
|
|
12
|
+
setActivePartyName: (name: string | null) => void;
|
|
13
|
+
chartConfig: ChartConfig;
|
|
14
|
+
seatSize: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Hook that manages parliament chart rendering and interactivity.
|
|
18
|
+
* Generates SVG visualization with seat circles and handles hover states
|
|
19
|
+
* for displaying repository statistics.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize }: UseParliamentChartProps) => void;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { ParliamentChartProps } from './parliament-chart.types';
|
|
3
|
+
/**
|
|
4
|
+
* Renders an interactive parliament-style chart visualization for repository statistics.
|
|
5
|
+
* Displays repository counts as seats in a semi-circular or arc layout, with scaling
|
|
6
|
+
* applied for large datasets. Includes hover interactions and a summary table.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ParliamentChart: FunctionComponent<ParliamentChartProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const DEFAULT_CHART_CONFIG: {
|
|
2
|
+
readonly arcAngle: 180;
|
|
3
|
+
readonly maxSeats: 200;
|
|
4
|
+
readonly useEnhanced: true;
|
|
5
|
+
readonly chartConfig: {
|
|
6
|
+
readonly radius: 220;
|
|
7
|
+
readonly seatSize: 5;
|
|
8
|
+
readonly minSeatSize: 4;
|
|
9
|
+
readonly maxSeatSize: 18;
|
|
10
|
+
readonly spacing: 1.1;
|
|
11
|
+
readonly innerRadiusRatio: 0.4;
|
|
12
|
+
readonly arcAngleFlexibility: 5;
|
|
13
|
+
};
|
|
14
|
+
readonly colors: {
|
|
15
|
+
readonly emptySeats: "#f8f8f8";
|
|
16
|
+
readonly emptySeatsBorder: "#d8d8d8";
|
|
17
|
+
readonly seatBorder: "#fff";
|
|
18
|
+
};
|
|
19
|
+
readonly animation: {
|
|
20
|
+
readonly transitionDuration: "0.2s";
|
|
21
|
+
readonly hoverOpacity: {
|
|
22
|
+
readonly active: "1";
|
|
23
|
+
readonly dimmed: "0.2";
|
|
24
|
+
readonly empty: "0.3";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly scaling: {
|
|
28
|
+
readonly enableScaling: true;
|
|
29
|
+
readonly scaleThreshold: 200;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const MODERNE_VULNERABILITY_COLORS: {
|
|
33
|
+
COMPLETED: "#40c048";
|
|
34
|
+
NOT_APPLICABLE: string;
|
|
35
|
+
NO_LST: string;
|
|
36
|
+
DATA_MISSING: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const CAMPAIGN_NOT_APPLICABLE = "N/A";
|
|
39
|
+
export declare const CAMPAIGN_NO_LST = "No LST";
|
|
40
|
+
export declare const CAMPAIGN_DATA_MISSING = "Data Missing";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ParliamentChartTheme } from '../../theme/default-colors';
|
|
2
|
+
type ParliamentDataSeries = {
|
|
3
|
+
value: number;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export type ParliamentChartProps = {
|
|
7
|
+
dataSeries: Array<ParliamentDataSeries>;
|
|
8
|
+
totalRepositories: number;
|
|
9
|
+
notApplicableRepositories: number;
|
|
10
|
+
noLstRepositories: number;
|
|
11
|
+
unavailableRepositories: number;
|
|
12
|
+
arcAngle?: number;
|
|
13
|
+
useEnhanced?: boolean;
|
|
14
|
+
theme?: ParliamentChartTheme;
|
|
15
|
+
};
|
|
16
|
+
export type ProcessedDataItem = {
|
|
17
|
+
id: string | number;
|
|
18
|
+
label: string;
|
|
19
|
+
value: number;
|
|
20
|
+
color: string;
|
|
21
|
+
};
|
|
22
|
+
export type HoveredData = {
|
|
23
|
+
label: string;
|
|
24
|
+
value: number;
|
|
25
|
+
color: string;
|
|
26
|
+
} | null;
|
|
27
|
+
export type ChartConfig = {
|
|
28
|
+
radius: number;
|
|
29
|
+
seatSize: number;
|
|
30
|
+
minSeatSize: number;
|
|
31
|
+
maxSeatSize: number;
|
|
32
|
+
spacing: number;
|
|
33
|
+
innerRadiusRatio: number;
|
|
34
|
+
arcAngleFlexibility: number;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates optimal arc angle based on repository count.
|
|
3
|
+
* Smaller repository counts get smaller arcs for better visual density,
|
|
4
|
+
* while larger counts expand to full parliament-style semicircle.
|
|
5
|
+
*
|
|
6
|
+
* Algorithm uses smooth interpolation between breakpoints:
|
|
7
|
+
* - < 10 repos: 60° (compact, focused visualization)
|
|
8
|
+
* - 10-25 repos: 60-90° (gradual expansion)
|
|
9
|
+
* - 25-50 repos: 90-120° (quarter to third circle)
|
|
10
|
+
* - 50-100 repos: 120-150° (approaching semicircle)
|
|
11
|
+
* - 100-200 repos: 150-180° (near-full parliament)
|
|
12
|
+
* - > 200 repos: 180° (full semicircle)
|
|
13
|
+
*/
|
|
14
|
+
export declare const calculateOptimalArcAngle: ({ repositoryCount }: {
|
|
15
|
+
repositoryCount: number;
|
|
16
|
+
}) => number;
|
|
17
|
+
/**
|
|
18
|
+
* Calculates optimal seat size based on repository count.
|
|
19
|
+
* Smaller repository counts get larger seats for better visibility,
|
|
20
|
+
* while larger counts use smaller seats to fit more in the arc.
|
|
21
|
+
*
|
|
22
|
+
* Uses the same breakpoint system as arc angle calculation
|
|
23
|
+
* for consistent visual scaling.
|
|
24
|
+
*/
|
|
25
|
+
export declare const calculateOptimalSeatSize: ({ repositoryCount }: {
|
|
26
|
+
repositoryCount: number;
|
|
27
|
+
}) => number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NotAppleWatchDataSeries = {
|
|
2
|
+
value: number;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
type ParliamentDataSeries = Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
value: number;
|
|
9
|
+
color: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const calculateDataSeries: ({ dataSeries, notApplicableRepositories, noLstRepositories, unavailableRepositories }: {
|
|
12
|
+
dataSeries: Array<NotAppleWatchDataSeries>;
|
|
13
|
+
notApplicableRepositories: number;
|
|
14
|
+
noLstRepositories: number;
|
|
15
|
+
totalRepositories: number;
|
|
16
|
+
unavailableRepositories: number;
|
|
17
|
+
}) => ParliamentDataSeries;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Element } from 'hast';
|
|
2
|
+
import { s as hastH } from 'hastscript';
|
|
3
|
+
type Party = {
|
|
4
|
+
id: string | number;
|
|
5
|
+
name: string;
|
|
6
|
+
seats: number;
|
|
7
|
+
colour: string;
|
|
8
|
+
};
|
|
9
|
+
type EnhancedParliamentOptions = {
|
|
10
|
+
seatCount?: boolean;
|
|
11
|
+
arcAngle?: number;
|
|
12
|
+
arcAngleFlexibility?: number;
|
|
13
|
+
radius?: number;
|
|
14
|
+
seatSize?: number;
|
|
15
|
+
minSeatSize?: number;
|
|
16
|
+
maxSeatSize?: number;
|
|
17
|
+
spacing?: number;
|
|
18
|
+
innerRadiusRatio?: number;
|
|
19
|
+
showLabels?: boolean;
|
|
20
|
+
hFunction?: typeof hastH;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Generates enhanced parliament visualization with optimized seat placement.
|
|
24
|
+
* Automatically adjusts arc angle and seat sizing to maximize visual appeal
|
|
25
|
+
* while maintaining proportional representation.
|
|
26
|
+
*/
|
|
27
|
+
export declare const generateEnhancedParliament: (parties: Party[], options?: EnhancedParliamentOptions) => Element;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Element } from 'hast';
|
|
2
|
+
import { s as hastH } from 'hastscript';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the grey hatch pattern definition for N/A category.
|
|
5
|
+
* Uses horizontal lines for clear differentiation.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createGreyHatchPattern: (hFunction?: typeof hastH) => Element;
|
|
8
|
+
/**
|
|
9
|
+
* Creates the yellow hatch pattern definition for Data Missing category.
|
|
10
|
+
* Uses 45-degree diagonal lines.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createDataMissingHatchPattern: (hFunction?: typeof hastH) => Element;
|
|
13
|
+
/**
|
|
14
|
+
* Creates the red hatch pattern definition for No LST category.
|
|
15
|
+
* Uses -45-degree diagonal lines.
|
|
16
|
+
*/
|
|
17
|
+
export declare const createNoLstHatchPattern: (hFunction?: typeof hastH) => Element;
|
|
18
|
+
/**
|
|
19
|
+
* Color values for hatch patterns to use in CSS and hover states.
|
|
20
|
+
* Exported for consistency across components.
|
|
21
|
+
*/
|
|
22
|
+
export declare const HATCH_PATTERN_COLORS: {
|
|
23
|
+
readonly greyHatch: {
|
|
24
|
+
readonly background: "#EDEFEF";
|
|
25
|
+
readonly lines: "#ADB5BD";
|
|
26
|
+
};
|
|
27
|
+
readonly dataMissingHatch: {
|
|
28
|
+
readonly background: "#FFF3CC";
|
|
29
|
+
readonly lines: "#FFB800";
|
|
30
|
+
};
|
|
31
|
+
readonly noLstHatch: {
|
|
32
|
+
readonly background: "#FFE5E5";
|
|
33
|
+
readonly lines: "#ED4134";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Element } from 'hast';
|
|
2
|
+
import { s as hastH } from 'hastscript';
|
|
3
|
+
type Party = {
|
|
4
|
+
id: string | number;
|
|
5
|
+
name: string;
|
|
6
|
+
seats: number;
|
|
7
|
+
colour: string;
|
|
8
|
+
};
|
|
9
|
+
type ParliamentOptions = {
|
|
10
|
+
seatCount?: boolean;
|
|
11
|
+
arcAngle?: number;
|
|
12
|
+
hFunction?: typeof hastH;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generates parliament-style SVG visualization from party seat data.
|
|
16
|
+
* Arranges seats in a semicircular arc pattern using the Sainte-Laguë method
|
|
17
|
+
* for proportional distribution across rings.
|
|
18
|
+
*/
|
|
19
|
+
export declare const generateParliament: (parliament: Party[], options?: ParliamentOptions) => Element;
|
|
20
|
+
export {};
|
|
@@ -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>;
|