@moderneinc/react-charts 1.2.0-next.2d0a72 → 1.2.0-next.313329

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 (29) hide show
  1. package/dist/components/chrono-chart/chrono-chart.component.d.ts +10 -0
  2. package/dist/components/chrono-chart/chrono-chart.types.d.ts +118 -0
  3. package/dist/components/chrono-chart/components/category-table.component.d.ts +13 -0
  4. package/dist/components/chrono-chart/components/category-table.types.d.ts +42 -0
  5. package/dist/components/chrono-chart/utils/data-transformer.d.ts +41 -0
  6. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +21 -1
  7. package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +7 -2
  8. package/dist/components/morph-chart/hooks/shared/computations.d.ts +12 -8
  9. package/dist/components/morph-chart/hooks/shared/types.d.ts +9 -5
  10. package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +45 -1
  11. package/dist/components/morph-chart/morph-chart.types.d.ts +22 -0
  12. package/dist/components/morph-chart/utils/accordion-generator.d.ts +102 -0
  13. package/dist/components/morph-chart/utils/area-renderer.d.ts +1 -0
  14. package/dist/components/morph-chart/utils/bar-renderer.d.ts +0 -9
  15. package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +55 -16
  16. package/dist/components/morph-chart/utils/parliament-renderer.d.ts +2 -0
  17. package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +35 -0
  18. package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +25 -0
  19. package/dist/components/timeline-chart/timeline-chart.types.d.ts +30 -0
  20. package/dist/index.cjs +84 -78
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +19340 -17737
  23. package/dist/theme/timeline-defaults.d.ts +33 -1
  24. package/package.json +6 -2
  25. package/dist/components/chrono-perspective-chart/chrono-perspective-chart.component.d.ts +0 -3
  26. package/dist/components/chrono-perspective-chart/chrono-perspective-chart.types.d.ts +0 -62
  27. package/dist/components/chrono-perspective-chart/components/category-table.component.d.ts +0 -3
  28. package/dist/components/chrono-perspective-chart/components/category-table.types.d.ts +0 -13
  29. package/dist/components/chrono-perspective-chart/utils/data-transformer.d.ts +0 -9
@@ -1,11 +1,13 @@
1
1
  import { Selection } from 'd3-selection';
2
2
  import { MorphChartCategory } from '../morph-chart.types';
3
3
  interface AnimationDurations {
4
- seatsToBar: number;
4
+ seatsToRings: number;
5
+ ringsToBar: number;
5
6
  axesReveal: number;
6
7
  barSlide: number;
7
8
  barsGrow: number;
8
9
  barsToArea: number;
10
+ ringsHold?: number;
9
11
  }
10
12
  interface AnimationCallbacks {
11
13
  onStageComplete?: (stage: string) => void;
@@ -34,39 +36,76 @@ export declare class GSAPOrchestrator {
34
36
  private durations;
35
37
  constructor(durations: AnimationDurations, callbacks?: AnimationCallbacks);
36
38
  /**
37
- * Stage 1: Animate parliament seats collapsing into bar segments
39
+ * Stage 1a: Animate parliament seats transforming into slinky rings
38
40
  *
39
- * Transforms the circular parliament layout into a stacked vertical bar.
40
- * Each seat morphs from its position in the parliament arc into a rectangular
41
- * segment of a bar, maintaining visual continuity through smooth transitions.
41
+ * Transforms the circular parliament layout into a slinky (spring coil) formation.
42
+ * This creates a whimsical intermediate state between the circular parliament
43
+ * and the stacked bar, making the transition more visually engaging.
42
44
  *
43
- * @param seats - D3 selection of parliament seat rectangles to animate
44
- * @param targetPositions - Array of target positions for each seat, where each position defines the final rectangle geometry (x, y, width, height)
45
+ * @param seats - D3 selection of parliament seat elements to animate
46
+ * @param baselineY - Y-coordinate of the chart baseline (reference for positioning)
45
47
  * @returns this - Returns the orchestrator instance for method chaining
46
48
  *
47
49
  * @remarks
48
50
  * **Visual transformation:**
49
- * - Parliament seats (circular arc) → Vertical bar segments (stacked rectangles)
50
- * - All seats animate simultaneously (no stagger)
51
- * - Uses power2.inOut easing for smooth acceleration/deceleration
51
+ * - Parliament seats (circular arc) → Slinky rings (elliptical coils)
52
+ * - Seats morph and fade into overlapping rings
53
+ * - Rings positioned along the parliament arc initially
54
+ * - Uses perspective effects for 3D slinky appearance
52
55
  *
53
56
  * **Data preservation:**
54
57
  * - Original seat positions stored in data-orig-* attributes for potential reversal
55
- * - Target positions must match seat count (indexed by array position)
58
+ * - Current dimensions preserved before transformation
56
59
  *
57
60
  * **Timeline integration:**
58
- * - Added at 'seatsToBar' label
59
- * - Duration: 30% of total animation (STAGE_DURATION_RATIOS.SEATS_TO_BAR)
61
+ * - Added at 'seatsToRings' label (first stage)
62
+ * - Duration: Set by durations.seatsToRings
60
63
  * - Triggers onStageComplete callback when starting
61
64
  *
62
65
  * @example
63
66
  * ```ts
64
67
  * const seats = svg.selectAll('.parliament-seat');
65
- * const targets = calculateBarPositions(seats);
66
- * orchestrator.animateSeatsToBar(seats, targets);
68
+ * const baselineY = height - margin.bottom;
69
+ * orchestrator.animateSeatsToRings(seats, baselineY);
70
+ * ```
71
+ */
72
+ animateSeatsToRings(seats: Selection<SVGRectElement, unknown, null, undefined>, baselineY: number): GSAPOrchestrator;
73
+ /**
74
+ * Stage 1b: Animate slinky rings collapsing into stacked bar
75
+ *
76
+ * Transforms the slinky rings created in Stage 1a into a stacked
77
+ * vertical bar. Rings compress and stack vertically to form rectangular
78
+ * segments of the final bar, maintaining visual continuity.
79
+ *
80
+ * @param seats - D3 selection of ring elements (formerly seats) to animate
81
+ * @param targetPositions - Array of target positions for each segment, where each position defines the final rectangle geometry (x, y, width, height)
82
+ * @returns this - Returns the orchestrator instance for method chaining
83
+ *
84
+ * @remarks
85
+ * **Visual transformation:**
86
+ * - Slinky rings → Stacked bar segments (rectangles)
87
+ * - Rings compress and flatten into bar segments
88
+ * - Reposition to stack vertically in correct order
89
+ * - All segments animate simultaneously (no stagger)
90
+ * - Uses power2.inOut easing for smooth acceleration/deceleration
91
+ *
92
+ * **Data requirements:**
93
+ * - Target positions must match ring count (indexed by array position)
94
+ * - Each position defines final x, y, width, height for the bar segment
95
+ *
96
+ * **Timeline integration:**
97
+ * - Added at 'ringsToBar' label (after seatsToRings)
98
+ * - Duration: Set by durations.ringsToBar
99
+ * - Triggers onStageComplete callback when starting
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const rings = svg.selectAll('.slinky-ring');
104
+ * const targets = calculateBarPositions(rings);
105
+ * orchestrator.animateRingsToBar(rings, targets);
67
106
  * ```
68
107
  */
69
- animateSeatsToBar(seats: Selection<SVGRectElement, unknown, null, undefined>, targetPositions: Array<{
108
+ animateRingsToBar(seats: Selection<SVGRectElement, unknown, null, undefined>, targetPositions: Array<{
70
109
  x: number;
71
110
  y: number;
72
111
  width: number;
@@ -9,6 +9,8 @@ interface ParliamentRenderOptions {
9
9
  centerX: number;
10
10
  centerY: number;
11
11
  addClasses?: boolean;
12
+ instanceId?: string;
13
+ parliamentRadius?: number;
12
14
  }
13
15
  /**
14
16
  * Render parliament seats into an SVG container
@@ -0,0 +1,35 @@
1
+ import { Selection } from 'd3-selection';
2
+ export interface Slinky3DConfig {
3
+ categories: Array<{
4
+ name: string;
5
+ color: string;
6
+ seatCount: number;
7
+ }>;
8
+ centerX: number;
9
+ centerY: number;
10
+ radius: number;
11
+ arcAngle: number;
12
+ }
13
+ /**
14
+ * Generate HTML content for 3D slinky rings
15
+ */
16
+ export declare function generate3DSlinkyHTML(categories: Array<{
17
+ name: string;
18
+ color: string;
19
+ seatCount: number;
20
+ }>): string;
21
+ /**
22
+ * Generate CSS styles for 3D slinky effect
23
+ */
24
+ export declare function generate3DSlinkyStyles(instanceId: string): string;
25
+ /**
26
+ * Create 3D slinky elements in SVG using foreignObject
27
+ */
28
+ export declare function create3DSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: Slinky3DConfig, instanceId: string): {
29
+ wrapper: Selection<SVGForeignObjectElement, unknown, null, undefined>;
30
+ cleanup: () => void;
31
+ };
32
+ /**
33
+ * Animate 3D slinky compression using GSAP
34
+ */
35
+ export declare function animate3DSlinkyCompression(instanceId: string, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
@@ -0,0 +1,25 @@
1
+ import { Selection } from 'd3-selection';
2
+ export interface SvgSlinkyConfig {
3
+ categories: Array<{
4
+ name: string;
5
+ color: string;
6
+ seatCount: number;
7
+ }>;
8
+ centerX: number;
9
+ centerY: number;
10
+ radius: number;
11
+ innerRadius: number;
12
+ arcAngle: number;
13
+ }
14
+ /**
15
+ * Create SVG slinky coils
16
+ */
17
+ export declare function createSvgSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: SvgSlinkyConfig, instanceId: string): {
18
+ slinkyGroup: Selection<SVGGElement, unknown, null, undefined>;
19
+ cleanup: () => void;
20
+ };
21
+ /**
22
+ * Animate SVG slinky closing - stacks rings vertically into a bar on the right
23
+ * Uses staggered animation phases to create realistic slinky walking effect
24
+ */
25
+ export declare function animateSvgSlinkyCompression(slinkyGroup: Selection<SVGGElement, unknown, null, undefined>, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
@@ -3,12 +3,20 @@ export type TimelineEvent = {
3
3
  date: Date;
4
4
  timestamp: number;
5
5
  eventName: string;
6
+ /**
7
+ * Optional color for the event marker.
8
+ * If not provided, defaults to #2F42FF (Digital Blue 500).
9
+ * Accepts any valid CSS color string.
10
+ */
11
+ color?: string;
6
12
  [key: string]: unknown;
7
13
  };
8
14
  export type TimelineSelection = {
9
15
  start: number | null;
10
16
  end: number | null;
11
17
  };
18
+ export type DragHandleType = 'start' | 'end' | 'body' | null;
19
+ type DragHandleVariant = 'arrow' | 'grip';
12
20
  export type TimelineChartSlotProps = {
13
21
  /** Props for the header container (Stack) */
14
22
  header?: StackProps;
@@ -26,6 +34,10 @@ export type TimelineChartSlotProps = {
26
34
  event?: BoxProps;
27
35
  /** Props for the selection highlight overlay (Box) */
28
36
  selection?: BoxProps;
37
+ /** Props for the start drag handle (Box) */
38
+ startHandle?: BoxProps;
39
+ /** Props for the end drag handle (Box) */
40
+ endHandle?: BoxProps;
29
41
  /** Props for the hover tooltip container (Box) */
30
42
  tooltip?: BoxProps;
31
43
  /** Props for the tooltip event name Typography component */
@@ -42,6 +54,13 @@ export type TimelineChartProps = {
42
54
  selectedRange?: TimelineSelection;
43
55
  /** Height of the timeline container in pixels (default: 32) */
44
56
  height?: number;
57
+ /** Margin around the timeline drawable area (for alignment with other charts) */
58
+ margin?: {
59
+ top: number;
60
+ right: number;
61
+ bottom: number;
62
+ left: number;
63
+ };
45
64
  /** Custom date formatter */
46
65
  formatDate?: (timestamp: number) => string;
47
66
  /** Custom month/year formatter */
@@ -52,6 +71,10 @@ export type TimelineChartProps = {
52
71
  monthLabelCount?: number;
53
72
  /** Enable zoom with mouse wheel */
54
73
  enableZoom?: boolean;
74
+ /** Drag handle style variant (default: 'arrow') */
75
+ dragHandleVariant?: DragHandleVariant;
76
+ /** Color for drag handles (default: '#4B5563' for arrow, '#9CA3AF' for grip) */
77
+ dragHandleColor?: string;
55
78
  /** Show header title and instructions (default: true) */
56
79
  showHeader?: boolean;
57
80
  /** Custom title for the header */
@@ -95,12 +118,14 @@ export type UseTimelineChartProps = {
95
118
  export type UseTimelineChartReturn = {
96
119
  isDragging: boolean;
97
120
  dragStart: number | null;
121
+ dragHandleType: DragHandleType;
98
122
  internalSelectedRange: TimelineSelection;
99
123
  internalVisibleRange: TimelineSelection;
100
124
  hoveredEvent: TimelineEvent | null;
101
125
  minDate: number;
102
126
  maxDate: number;
103
127
  timeSpan: number;
128
+ timelineContainerRef: React.RefObject<HTMLDivElement>;
104
129
  getPositionFromTimestamp: (timestamp: number) => number;
105
130
  getTimestampFromPosition: (x: number, containerWidth: number) => number;
106
131
  handleMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
@@ -108,9 +133,13 @@ export type UseTimelineChartReturn = {
108
133
  handleMouseUp: () => void;
109
134
  handleWheel: (e: React.WheelEvent<HTMLDivElement>) => void;
110
135
  handleDoubleClick: () => void;
136
+ handleStartHandleMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
137
+ handleEndHandleMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
138
+ handleSelectionBodyMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
111
139
  setHoveredEvent: (event: TimelineEvent | null) => void;
112
140
  getEventsInRange: () => TimelineEvent[];
113
141
  resetZoom: () => void;
142
+ showHandles: boolean;
114
143
  };
115
144
  export type TimelineSelectedEventsProps = {
116
145
  /** Array of selected events to display */
@@ -124,3 +153,4 @@ export type TimelineSelectedEventsProps = {
124
153
  /** Primary color for event items */
125
154
  primaryColor?: string;
126
155
  };
156
+ export {};