@osrd-project/ui-charts 0.0.80 → 0.0.83

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 (78) hide show
  1. package/dist/chronogram/components/Chronogram.d.ts +3 -0
  2. package/dist/chronogram/components/ChronogramCanvas.d.ts +3 -0
  3. package/dist/chronogram/components/ChronogramManchette.d.ts +9 -0
  4. package/dist/chronogram/components/OccupancyBlocksLayer.d.ts +1 -0
  5. package/dist/chronogram/hooks/useChronogram.d.ts +35 -0
  6. package/dist/chronogram/index.d.ts +9 -0
  7. package/dist/chronogram/lib/const.d.ts +5 -0
  8. package/dist/chronogram/lib/context.d.ts +6 -0
  9. package/dist/chronogram/lib/types.d.ts +30 -0
  10. package/dist/chronogram/utils/format.d.ts +1 -0
  11. package/dist/common/consts.d.ts +5 -0
  12. package/dist/common/context.d.ts +2 -0
  13. package/dist/{spaceTimeChart/utils → common/helpers}/colors.d.ts +9 -4
  14. package/dist/common/helpers/time.d.ts +31 -0
  15. package/dist/common/helpers/utils.d.ts +8 -0
  16. package/dist/common/hooks/useCanvas.d.ts +16 -0
  17. package/dist/common/hooks/useMouseInteractions.d.ts +41 -0
  18. package/dist/{spaceTimeChart → common}/hooks/useMouseTracking.d.ts +1 -1
  19. package/dist/{spaceTimeChart → common}/hooks/useSize.d.ts +0 -1
  20. package/dist/common/index.d.ts +5 -0
  21. package/dist/common/types.d.ts +104 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.esm.js +2281 -1531
  24. package/dist/index.esm.js.map +1 -1
  25. package/dist/manchette/assets/sampleData.d.ts +2 -0
  26. package/dist/manchette/components/Manchette.d.ts +6 -1
  27. package/dist/manchette/components/ManchetteWithSpaceTimeChart.d.ts +4 -4
  28. package/dist/manchette/components/Waypoint.d.ts +2 -1
  29. package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +3 -36
  30. package/dist/manchette/hooks/useSyncManchette.d.ts +94 -0
  31. package/dist/manchette/index.d.ts +1 -2
  32. package/dist/manchette/types.d.ts +13 -0
  33. package/dist/spaceTimeChart/components/ConflictLayer.d.ts +1 -1
  34. package/dist/spaceTimeChart/components/ConflictTooltip.d.ts +1 -1
  35. package/dist/spaceTimeChart/components/PathLayer.d.ts +2 -1
  36. package/dist/spaceTimeChart/components/Quadrilateral.d.ts +2 -1
  37. package/dist/spaceTimeChart/components/Tooltip.d.ts +1 -1
  38. package/dist/spaceTimeChart/index.d.ts +2 -5
  39. package/dist/spaceTimeChart/lib/consts.d.ts +0 -3
  40. package/dist/spaceTimeChart/lib/context.d.ts +3 -6
  41. package/dist/spaceTimeChart/lib/types.d.ts +4 -91
  42. package/dist/spaceTimeChart/utils/canvas.d.ts +2 -37
  43. package/dist/spaceTimeChart/utils/events.d.ts +1 -1
  44. package/dist/spaceTimeChart/utils/geometry.d.ts +1 -1
  45. package/dist/spaceTimeChart/utils/scales.d.ts +2 -3
  46. package/dist/spaceTimeChart/utils/snapping.d.ts +1 -1
  47. package/dist/spaceTimeChart/utils/vectors.d.ts +1 -1
  48. package/dist/speedSpaceChart/components/SpeedSpaceChart.d.ts +21 -2
  49. package/dist/speedSpaceChart/components/common/DetailsBox.d.ts +5 -2
  50. package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +2 -1
  51. package/dist/speedSpaceChart/components/const.d.ts +22 -6
  52. package/dist/speedSpaceChart/components/helpers/drawElements/reticle.d.ts +2 -1
  53. package/dist/speedSpaceChart/components/layers/ReticleLayer.d.ts +3 -1
  54. package/dist/speedSpaceChart/components/utils.d.ts +7 -3
  55. package/dist/speedSpaceChart/index.d.ts +2 -1
  56. package/dist/speedSpaceChart/types.d.ts +40 -0
  57. package/dist/theme.css +1382 -483
  58. package/dist/theme.css.map +1 -1
  59. package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +1 -1
  60. package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +1 -1
  61. package/dist/trackOccupancyDiagram/components/TrackOccupancyStandalone.d.ts +1 -1
  62. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +8 -2
  63. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +1 -1
  64. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +1 -1
  65. package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +2 -2
  66. package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +1 -1
  67. package/dist/trackOccupancyDiagram/components/utils.d.ts +1 -1
  68. package/dist/trackOccupancyDiagram/index.d.ts +2 -2
  69. package/dist/trackOccupancyDiagram/{components → lib}/types.d.ts +2 -1
  70. package/package.json +10 -9
  71. package/dist/manchette/hooks/usePaths.d.ts +0 -11
  72. package/dist/spaceTimeChart/hooks/useCanvas.d.ts +0 -19
  73. package/dist/spaceTimeChart/hooks/useMouseInteractions.d.ts +0 -8
  74. /package/dist/{spaceTimeChart/utils → common/helpers}/png.d.ts +0 -0
  75. /package/dist/{spaceTimeChart → common}/hooks/useDevicePixelRatio.d.ts +0 -0
  76. /package/dist/{spaceTimeChart/components → common/layers}/TimeCaptions.d.ts +0 -0
  77. /package/dist/{spaceTimeChart/components → common/layers}/TimeGraduations.d.ts +0 -0
  78. /package/dist/trackOccupancyDiagram/{components → lib}/consts.d.ts +0 -0
@@ -0,0 +1,2 @@
1
+ import type { ChartPath } from '../types';
2
+ export declare const SAMPLE_CHART_PATHS: ChartPath[];
@@ -8,11 +8,16 @@ export type ManchetteProps = {
8
8
  zoomYOut: () => void;
9
9
  resetZoom: () => void;
10
10
  height?: number;
11
+ width?: number;
11
12
  yZoom?: number;
12
13
  children?: React.ReactNode;
13
14
  isProportional?: boolean;
14
15
  testIdPrefix?: string;
15
16
  toggleMode: () => void;
17
+ hidePositions?: boolean;
18
+ translations?: {
19
+ linearMode: string;
20
+ };
16
21
  };
17
- declare const Manchette: ({ zoomYIn, zoomYOut, resetZoom, yZoom, contents, activeWaypointId, activeWaypointRef, isProportional, toggleMode, children, height, }: ManchetteProps) => React.JSX.Element;
22
+ declare const Manchette: ({ zoomYIn, zoomYOut, resetZoom, yZoom, contents, activeWaypointId, activeWaypointRef, isProportional, toggleMode, children, height, width, hidePositions, translations, }: ManchetteProps) => React.JSX.Element;
18
23
  export default Manchette;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { type ManchetteProps } from './Manchette';
3
2
  import { type SpaceTimeChartProps } from '../../spaceTimeChart';
4
3
  import { type SplitPoint } from '../hooks/useManchetteWithSpaceTimeChart';
5
- import { type ProjectPathTrainResult, type Waypoint } from '../types';
4
+ import type { ChartPath, Waypoint } from '../types';
5
+ import { type ManchetteProps } from './Manchette';
6
6
  export type ManchetteWithSpaceTimeChartProps = {
7
7
  waypoints: Waypoint[];
8
- projectPathTrainResult: ProjectPathTrainResult[];
8
+ paths: ChartPath[];
9
9
  height?: number;
10
10
  children?: React.ReactNode;
11
11
  header?: React.ReactNode;
@@ -19,5 +19,5 @@ export type ManchetteWithSpaceTimeChartProps = {
19
19
  * This only covers basic usage. For more advanced control over the manchette
20
20
  * and space time chart, the useManchetteWithSpaceTimeChart() hook can be used.
21
21
  */
22
- declare const ManchetteWithSpaceTimeChart: ({ waypoints, projectPathTrainResult, height, children, header, manchetteProps: additionalManchetteProps, spaceTimeChartProps: additionalSpaceTimeChartProps, splitPoints, }: ManchetteWithSpaceTimeChartProps) => React.JSX.Element;
22
+ declare const ManchetteWithSpaceTimeChart: ({ waypoints, paths, height, children, header, manchetteProps: additionalManchetteProps, spaceTimeChartProps: additionalSpaceTimeChartProps, splitPoints, }: ManchetteWithSpaceTimeChartProps) => React.JSX.Element;
23
23
  export default ManchetteWithSpaceTimeChart;
@@ -8,6 +8,7 @@ type WaypointProps = {
8
8
  isActive: boolean;
9
9
  isMenuActive?: boolean;
10
10
  testIdPrefix?: string;
11
+ hidePositions?: boolean;
11
12
  };
12
- declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick }, waypointRef, isActive, isMenuActive, testIdPrefix, }: WaypointProps) => React.JSX.Element;
13
+ declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick, styles }, waypointRef, isActive, isMenuActive, testIdPrefix, hidePositions, }: WaypointProps) => React.JSX.Element;
13
14
  export default Waypoint;
@@ -1,41 +1,8 @@
1
1
  import React, { type ReactNode } from 'react';
2
- import { type SpaceScale, type SpaceTimeChartProps } from '../../spaceTimeChart';
2
+ import { type SpaceTimeChartProps } from '../../spaceTimeChart';
3
3
  import type { ManchetteProps } from '../components/Manchette';
4
4
  import type { Waypoint } from '../types';
5
- type State = {
6
- xZoom: number;
7
- yZoom: number;
8
- timeOrigin: number;
9
- spaceOrigin: number;
10
- /** current x PIXEL offset from x origin */
11
- xOffset: number;
12
- /** current y PIXEL offset from y origin (the current y-scroll of the view. always updates) */
13
- yOffset: number;
14
- /** only update after a zoom. used to update back the view scroll value */
15
- scrollTo: number | null;
16
- panning: {
17
- initialOffset: {
18
- x: number;
19
- y: number;
20
- };
21
- } | null;
22
- zoomMode: boolean;
23
- rect: {
24
- timeStart: Date;
25
- timeEnd: Date;
26
- spaceStart: number;
27
- spaceEnd: number;
28
- } | null;
29
- pixelRect: {
30
- xStart: number;
31
- xEnd: number;
32
- yStart: number;
33
- yEnd: number;
34
- } | null;
35
- isProportional: boolean;
36
- waypointsChart: Waypoint[];
37
- scales: SpaceScale[];
38
- };
5
+ import { type SyncManchetteState } from './useSyncManchette';
39
6
  export type SplitPoint = {
40
7
  /** helper identify nodes for this split point in the React tree */
41
8
  id: string;
@@ -74,7 +41,7 @@ declare const useManchetteWithSpaceTimeChart: ({ waypoints, manchetteWithSpaceTi
74
41
  xZoom: number;
75
42
  toggleZoomMode: () => void;
76
43
  zoomMode: boolean;
77
- rect: State["rect"];
44
+ rect: SyncManchetteState["rect"];
78
45
  timeScale: number;
79
46
  spaceScale: number;
80
47
  setTimeOrigin: (v: number) => void;
@@ -0,0 +1,94 @@
1
+ import type { SpaceTimeChartProps } from '../../spaceTimeChart';
2
+ export type SyncManchetteState = {
3
+ xZoom: number;
4
+ yZoom: number;
5
+ timeOrigin: number;
6
+ spaceOrigin: number;
7
+ /** current x PIXEL offset from x origin */
8
+ xOffset: number;
9
+ /** current y PIXEL offset from y origin (the current y-scroll of the view. always updates) */
10
+ yOffset: number;
11
+ /** only update after a zoom. used to update back the view scroll value */
12
+ scrollTo: number | null;
13
+ panning: {
14
+ initialOffset: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ } | null;
19
+ zoomMode: boolean;
20
+ rect: {
21
+ timeStart: Date;
22
+ timeEnd: Date;
23
+ spaceStart: number;
24
+ spaceEnd: number;
25
+ } | null;
26
+ pixelRect: {
27
+ xStart: number;
28
+ xEnd: number;
29
+ yStart: number;
30
+ yEnd: number;
31
+ } | null;
32
+ };
33
+ /**
34
+ * This hook can be used to synchronize a manchette and a diagram which has a
35
+ * time scale for X.
36
+ *
37
+ * It provides offsets on both axis and functions to handle some
38
+ * classic behaviors such as zoom, pan and scroll.
39
+ */
40
+ declare const useSyncManchette: ({ manchetteWithSpaceTimeChartRef, diagramRef, initialState, maxYZoom, enableTimeZoom, }: {
41
+ manchetteWithSpaceTimeChartRef: React.RefObject<HTMLDivElement | null>;
42
+ maxYZoom: number;
43
+ diagramRef?: React.RefObject<HTMLDivElement | null>;
44
+ height?: number;
45
+ initialState?: {
46
+ timeOrigin?: number;
47
+ spaceOrigin?: number;
48
+ xOffset?: number;
49
+ };
50
+ enableTimeZoom?: boolean;
51
+ }) => {
52
+ state: SyncManchetteState;
53
+ setState: import("react").Dispatch<import("react").SetStateAction<SyncManchetteState>>;
54
+ handleScrollInManchette: (e: React.UIEvent<HTMLDivElement>) => void;
55
+ handleXZoom: (newXZoom: number, xPosition?: number) => void;
56
+ handleXZoomOnWheelEvent: (wheelEvent: WheelEvent, newXZoom: number, xPosition: number) => void;
57
+ yZoomHelpers: {
58
+ zoomYIn: () => void;
59
+ zoomYOut: () => void;
60
+ resetZoom: () => void;
61
+ };
62
+ basicOnPan: (payload: Parameters<NonNullable<SpaceTimeChartProps["onPan"]>>[0], prev: SyncManchetteState) => {
63
+ xZoom: number;
64
+ yZoom: number;
65
+ timeOrigin: number;
66
+ spaceOrigin: number;
67
+ /** current x PIXEL offset from x origin */
68
+ xOffset: number;
69
+ /** current y PIXEL offset from y origin (the current y-scroll of the view. always updates) */
70
+ yOffset: number;
71
+ /** only update after a zoom. used to update back the view scroll value */
72
+ scrollTo: number | null;
73
+ panning: {
74
+ initialOffset: {
75
+ x: number;
76
+ y: number;
77
+ };
78
+ } | null;
79
+ zoomMode: boolean;
80
+ rect: {
81
+ timeStart: Date;
82
+ timeEnd: Date;
83
+ spaceStart: number;
84
+ spaceEnd: number;
85
+ } | null;
86
+ pixelRect: {
87
+ xStart: number;
88
+ xEnd: number;
89
+ yStart: number;
90
+ yEnd: number;
91
+ } | null;
92
+ };
93
+ };
94
+ export default useSyncManchette;
@@ -6,7 +6,6 @@ export { default as Manchette, type ManchetteProps } from './components/Manchett
6
6
  export { default as ManchetteWithSpaceTimeChart, type ManchetteWithSpaceTimeChartProps, } from './components/ManchetteWithSpaceTimeChart';
7
7
  export { DEFAULT_ZOOM_MS_PER_PX, BASE_WAYPOINT_HEIGHT } from './consts';
8
8
  export { default as useManchetteWithSpaceTimeChart, type SplitPoint, } from './hooks/useManchetteWithSpaceTimeChart';
9
- export { default as usePaths } from './hooks/usePaths';
10
- export type { Waypoint, ProjectPathTrainResult, InteractiveWaypoint } from './types';
9
+ export type { Waypoint, ProjectPathTrainResult, InteractiveWaypoint, ChartPath } from './types';
11
10
  export { positionMmToKm, positionKmToMm } from './utils';
12
11
  export { timeScaleToZoomValue, isInteractiveWaypoint } from './utils/helpers';
@@ -19,3 +19,16 @@ export type ProjectPathTrainResult = {
19
19
  }[];
20
20
  departureTime: Date;
21
21
  };
22
+ export type ChartPoint = {
23
+ time: number;
24
+ position: number;
25
+ };
26
+ export type ChartPath = {
27
+ id: string;
28
+ label: string;
29
+ color: string;
30
+ points: {
31
+ time: number;
32
+ position: number;
33
+ }[];
34
+ };
@@ -1,4 +1,4 @@
1
- import type { PickingElement } from '../lib/types';
1
+ import type { PickingElement } from '../../common/types';
2
2
  export type Conflict = {
3
3
  timeStart: number;
4
4
  timeEnd: number;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Point } from '../lib/types';
2
+ import type { Point } from '../../common/types';
3
3
  export type ConflictTooltipProps = {
4
4
  position: Point;
5
5
  time: number;
@@ -1,4 +1,5 @@
1
- import { type PathData, type PickingElement, type Point } from '../lib/types';
1
+ import type { PickingElement, Point } from '../../common/types';
2
+ import { type PathData } from '../lib/types';
2
3
  export type PointPickingElement = PickingElement & {
3
4
  type: 'point';
4
5
  pathId: string;
@@ -1,4 +1,5 @@
1
- import type { DataPoint, PickingElement } from '../lib/types';
1
+ import type { PickingElement } from '../../common/types';
2
+ import type { DataPoint } from '../lib/types';
2
3
  export type QuadrilaterPickingElement = PickingElement & {
3
4
  type: 'quadrilateral';
4
5
  id: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Point } from '../lib/types';
2
+ import type { Point } from '../../common/types';
3
3
  export type TooltipProps = {
4
4
  position: Point;
5
5
  children: React.ReactNode;
@@ -9,12 +9,9 @@ export * from './components/WorkScheduleLayer';
9
9
  export * from './components/PatternRect';
10
10
  export * from './components/Quadrilateral';
11
11
  export * from './components/ZoomRect';
12
- export * from './components/TimeCaptions';
13
- export { usePicking, useDraw } from './hooks/useCanvas';
14
12
  export { DEFAULT_THEME } from './lib/consts';
15
- export { CanvasContext, MouseContext, SpaceTimeChartContext } from './lib/context';
16
- export type { HoveredItem, SpaceTimeChartProps, SpaceScale, OperationalPoint, SpaceTimeChartTheme, PathData, Point, DataPoint, SpaceTimeChartContextType, DrawingFunction, PickingDrawingFunction, PickingElement, } from './lib/types';
13
+ export { MouseContext, SpaceTimeChartContext, SpaceTimeChartCanvasContext } from './lib/context';
14
+ export type { SpaceTimeChartProps, SpaceScale, OperationalPoint, SpaceTimeChartTheme, PathData, DataPoint, SpaceTimeChartContextType, } from './lib/types';
17
15
  export { isPathOnScreen } from './utils/geometry';
18
16
  export { getSpaceAtTime } from './utils/scales';
19
- export { getCrispLineCoordinate } from './utils/canvas';
20
17
  export { computeRectZoomOffsets } from './utils/scales';
@@ -14,7 +14,4 @@ export declare const OCCUPANCY_SEMAPHORE = "#FFD4D8";
14
14
  export declare const OCCUPANCY_WARNING = "#FFEABF";
15
15
  export declare const FONT_SIZE = 10;
16
16
  export declare const FONT = "IBM Plex Sans, sans-serif";
17
- export declare const SECOND = 1000;
18
- export declare const MINUTE: number;
19
- export declare const HOUR: number;
20
17
  export declare const DEFAULT_THEME: SpaceTimeChartTheme;
@@ -1,14 +1,11 @@
1
- import { type CanvasContextType, type MouseContextType, type SpaceTimeChartContextType } from './types';
1
+ import type { CanvasContextType } from '../../common/types';
2
+ import type { MouseContextType, SpaceTimeChartContextType } from './types';
2
3
  /**
3
4
  * This context exports everything necessary to draw the chart.
4
5
  * It is updated anytime the scales are updated.
5
6
  */
6
7
  export declare const SpaceTimeChartContext: import("react").Context<SpaceTimeChartContextType>;
7
- /**
8
- * This context only contains necessary helpers to (un)register drawing functions.
9
- * It is basically never updated.
10
- */
11
- export declare const CanvasContext: import("react").Context<CanvasContextType>;
8
+ export declare const SpaceTimeChartCanvasContext: import("react").Context<CanvasContextType<SpaceTimeChartContextType>>;
12
9
  /**
13
10
  * This context exports everything necessary to draw the chart.
14
11
  * It is updated anytime the scales are updated or the mouse moves.
@@ -1,10 +1,6 @@
1
- import { type HTMLProps, type ReactNode } from 'react';
2
- export type Point = {
3
- x: number;
4
- y: number;
5
- };
1
+ import type { ReactNode } from 'react';
2
+ import type { TimeChartContextType, ChartEventHandlers, HoveredItem, Point } from '../../common/types';
6
3
  export type Handler<P extends object> = (payload: P) => void;
7
- export type RGBAColor = [number, number, number, number];
8
4
  export type RGBColor = [number, number, number];
9
5
  export type SpaceScale = {
10
6
  to: number;
@@ -54,39 +50,10 @@ export type OperationalPoint = {
54
50
  };
55
51
  export type Axis = 'x' | 'y';
56
52
  export type Direction = 'forward' | 'backward' | 'still';
57
- export type TimeToPixel = (time: number) => number;
58
53
  export type SpaceToPixel = (position: number, fromEnd?: boolean) => number;
59
- export type PixelToTime = (x: number) => number;
60
54
  export type PixelToSpace = (y: number) => number;
61
55
  export type PointToData = (point: Point) => DataPoint;
62
56
  export type DataToPoint = (data: DataPoint) => Point;
63
- export declare const PICKING_LAYERS: readonly ["paths", "overlay"];
64
- export type PickingLayerType = (typeof PICKING_LAYERS)[number];
65
- export declare const LAYERS: readonly ["background", "graduations", "paths", "overlay", "captions"];
66
- export type LayerType = (typeof LAYERS)[number];
67
- export type PickingElement = {
68
- type: string;
69
- };
70
- export type HoveredItem = {
71
- layer: PickingLayerType;
72
- element: PickingElement;
73
- };
74
- export type DrawingFunction = (canvasContext: CanvasRenderingContext2D, stcContext: SpaceTimeChartContextType) => void;
75
- export type PickingDrawingFunction = (imageData: ImageData, stcContext: SpaceTimeChartContextType, scalingRatio: number) => void;
76
- export type DrawingFunctionHandler = (arg: {
77
- type: 'picking';
78
- layer: PickingLayerType;
79
- fn: PickingDrawingFunction;
80
- } | {
81
- type: 'rendering';
82
- layer: LayerType;
83
- fn: DrawingFunction;
84
- }) => void;
85
- export type CanvasContextType = {
86
- register: DrawingFunctionHandler;
87
- unregister: DrawingFunctionHandler;
88
- captureCanvases: () => Promise<Blob>;
89
- };
90
57
  export type MouseState = {
91
58
  down?: {
92
59
  ctrl?: boolean;
@@ -148,69 +115,15 @@ export type SpaceTimeChartProps = {
148
115
  hideDates?: boolean;
149
116
  showTicks?: boolean;
150
117
  theme?: Partial<SpaceTimeChartTheme>;
151
- onPan?: Handler<{
152
- isPanning: boolean;
153
- initialPosition: Point;
154
- position: Point;
155
- initialData: DataPoint;
156
- data: DataPoint;
157
- context: SpaceTimeChartContextType;
158
- }>;
159
- onZoom?: Handler<{
160
- delta: number;
161
- position: Point;
162
- event: WheelEvent;
163
- context: SpaceTimeChartContextType;
164
- }>;
165
- onClick?: Handler<{
166
- position: Point;
167
- data: DataPoint;
168
- event: MouseEvent;
169
- hoveredItem: HoveredItem | null;
170
- context: SpaceTimeChartContextType;
171
- }>;
172
- onMouseMove?: Handler<{
173
- position: Point;
174
- data: DataPoint;
175
- isHover: boolean;
176
- hoveredItem: HoveredItem | null;
177
- context: SpaceTimeChartContextType;
178
- }>;
179
- onHoveredChildUpdate?: Handler<{
180
- item: HoveredItem | null;
181
- context: SpaceTimeChartContextType;
182
- }>;
183
- } & Omit<HTMLProps<HTMLDivElement>, 'onClick' | 'onMouseMove'>;
184
- export type SpaceTimeChartContextType = {
185
- width: number;
186
- height: number;
118
+ } & ChartEventHandlers<SpaceTimeChartContextType>;
119
+ export type SpaceTimeChartContextType = TimeChartContextType & {
187
120
  timeAxis: Axis;
188
121
  spaceAxis: Axis;
189
- swapAxis: boolean;
190
- fingerprint: string;
191
- pickingElements: PickingElement[];
192
- resetPickingElements: () => void;
193
- registerPickingElement: (element: PickingElement) => number;
194
- timePixelOffset: number;
195
- spacePixelOffset: number;
196
- timeOrigin: number;
197
- timeScale: number;
198
122
  spaceOrigin: number;
199
123
  spaceScaleTree: NormalizedScaleTree;
200
124
  flatSteps: Set<number>;
201
- getTimePixel: TimeToPixel;
202
125
  getSpacePixel: SpaceToPixel;
203
- getPoint: DataToPoint;
204
- getTime: PixelToTime;
205
126
  getSpace: PixelToSpace;
206
- getData: PointToData;
207
127
  operationalPoints: OperationalPoint[];
208
- theme: SpaceTimeChartTheme;
209
128
  captionSize: number;
210
- enableSnapping: boolean;
211
- hideTimeCaptions: boolean;
212
- hideGrid: boolean;
213
- hidePathsLabels: boolean;
214
- hideDates: boolean;
215
- showTicks: boolean;
216
129
  };
@@ -1,12 +1,5 @@
1
- import type { SpaceTimeChartContextType, Direction, PathEnd, Point, RGBAColor, RGBColor } from '../lib/types';
2
- /**
3
- * This function returns the picking layers scaling ratio. We basically take the min of the screen
4
- * pixels and the "HTML pixels", and divide it by two.
5
- *
6
- * This allows having a smaller picking stage to fill (so it's faster), while keeping a "good enough
7
- * precision".
8
- */
9
- export declare function getPickingScalingRatio(): number;
1
+ import type { Point, RGBAColor } from '../../common/types';
2
+ import type { SpaceTimeChartContextType, Direction, PathEnd, RGBColor } from '../lib/types';
10
3
  /**
11
4
  * This function draws a thick lines from "from" to "to" on the given ImageData, with no
12
5
  * antialiasing. This is very useful to handle picking, since it is not possible to disable
@@ -34,34 +27,6 @@ export declare function drawPathOutExtremity(ctx: CanvasRenderingContext2D, time
34
27
  * This function draws a path extremity.
35
28
  */
36
29
  export declare function drawPathExtremity(ctx: CanvasRenderingContext2D, timePixel: number, spacePixel: number, swapAxis: boolean, extremityType: 'from' | 'to', pathDirection: Direction, pathEnd: PathEnd): void;
37
- /**
38
- * @param minT number timestamp
39
- * @param maxT number timestamp
40
- * @param timeRanges time frames (24h, 12h, 6h, …)
41
- * @param gridlinesLevels width of the lines for each time frame
42
- * @param formatter function to format de values inside the output object
43
- * Keys are times in ms
44
- * Values are the highest level on each time
45
- */
46
- export declare function computeVisibleTimeMarkers<T extends object = {
47
- level: number;
48
- }>(minT: number, maxT: number, timeRanges: number[], gridlinesLevels: number[], formatter?: (level: number, i: number) => T): (T & {
49
- time: number;
50
- })[];
51
- /**
52
- * To get crisp horizontal or vertical lines on a canvas, we must draw them as thin as possible, in
53
- * terms of actual pixels on screen.
54
- * The best way for this is:
55
- * - To center lines 1, 3, 5... pixels wide in the middle of a pixel (0.5, 1.5, 2.5...)
56
- * - To center lines 2, 4, 6... pixels wide between two pixels (0, 1, 2, 3...)
57
- * Also, for HiDPi screens:
58
- * - To center lines of "integer thicknesses" between two screen pixels (0, 0.5, 1, 1.5, 2...)
59
- * - To center lines with `n + 0.5` thicknesses in the middle of a screen pixel (0.25, 0.75, 1.25, 1.75...)
60
- * @param rawCoordinate Any input coordinate to fix
61
- * @param lineWidth The width of the line to draw
62
- * @param devicePixelRatio
63
- */
64
- export declare function getCrispLineCoordinate(rawCoordinate: number, lineWidth: number, devicePixelRatio?: number): number;
65
30
  export type CanvasRect = {
66
31
  timeStart: Date;
67
32
  timeEnd: Date;
@@ -1,4 +1,4 @@
1
- import { type Point } from '../lib/types';
1
+ import type { Point } from '../../common/types';
2
2
  /**
3
3
  * This function takes a MouseEvent and an HTMLElement, and returns the position of the mouse,
4
4
  * relatively to the DOM element. This allows for instance dragging an element that is on the given
@@ -1,4 +1,4 @@
1
- import { type Point } from '../lib/types';
1
+ import type { Point } from '../../common/types';
2
2
  /**
3
3
  * This function helps to find if two segments do intersect.
4
4
  */
@@ -1,4 +1,5 @@
1
- import { type NormalizedScaleTree, type NormalizedScale, type SpaceScale, type SpaceToPixel, type TimeToPixel, type PixelToTime, type PixelToSpace, type PointToData, type DataToPoint, type Axis, type PathData } from '../lib/types';
1
+ import type { PixelToTime, TimeToPixel } from '../../common/types';
2
+ import { type NormalizedScaleTree, type NormalizedScale, type SpaceScale, type SpaceToPixel, type PixelToSpace, type PointToData, type DataToPoint, type Axis, type PathData } from '../lib/types';
2
3
  /**
3
4
  * This function helps to index a sequence of consecutive scales into a binary tree, to make it
4
5
  * faster to find which scale contains any given position.
@@ -31,8 +32,6 @@ export declare function getNormalizedScaleAtPosition(position: number, tree: Nor
31
32
  * is returned and if it is higher than the max pixel (tree.pixelTo), the last leaf is returned.
32
33
  */
33
34
  export declare function getNormalizedScaleAtPixel(y: number, tree: NormalizedScaleTree): NormalizedScale;
34
- export declare function getTimeToPixel(timeOrigin: number, pixelOffset: number, timeScale: number): TimeToPixel;
35
- export declare function getPixelToTime(timeOrigin: number, pixelOffset: number, timeScale: number): PixelToTime;
36
35
  export declare function getSpaceToPixel(pixelOffset: number, binaryTree: NormalizedScaleTree): SpaceToPixel;
37
36
  export declare function getPixelToSpace(pixelOffset: number, binaryTree: NormalizedScaleTree): PixelToSpace;
38
37
  export declare function getPointToData(getTime: PixelToTime, getSpace: PixelToSpace, timeAxis: Axis, spaceAxis: Axis): PointToData;
@@ -1,4 +1,4 @@
1
- import { type HoveredItem, type Point } from '../lib/types';
1
+ import type { HoveredItem, Point } from '../../common/types';
2
2
  /**
3
3
  * This function takes a point and a segment, and returns the point of the segment that is the
4
4
  * closest to the input point.
@@ -1,2 +1,2 @@
1
- import { type Point } from '../lib/types';
1
+ import type { Point } from '../../common/types';
2
2
  export declare function getDiff(a: Point, b: Point): Point;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import type { Data } from '../types';
2
+ import type { Data, EtcsBrakingCurves } from '../types';
3
3
  export type SpeedSpaceChartProps = {
4
4
  width: number;
5
5
  height: number;
6
6
  backgroundColor: string;
7
7
  setHeight: React.Dispatch<React.SetStateAction<number>>;
8
+ fetchEtcsBrakingCurves?: () => Promise<void>;
9
+ etcsBrakingCurves?: EtcsBrakingCurves;
8
10
  data: Data;
9
11
  translations?: {
10
12
  detailsBoxDisplay: {
@@ -12,6 +14,7 @@ export type SpeedSpaceChartProps = {
12
14
  energySource: string;
13
15
  tractionStatus: string;
14
16
  declivities: string;
17
+ etcs: string;
15
18
  electricalProfiles: string;
16
19
  powerRestrictions: string;
17
20
  };
@@ -25,7 +28,23 @@ export type SpeedSpaceChartProps = {
25
28
  powerRestrictions: string;
26
29
  speedLimitTags: string;
27
30
  };
31
+ etcsLayersDisplay: {
32
+ title: string;
33
+ etcsBrakingTypes: {
34
+ stop: string;
35
+ transition: string;
36
+ stopsAndTransitions: string;
37
+ signals: string;
38
+ spacing: string;
39
+ routing: string;
40
+ };
41
+ etcsBrakingCurveTypes: {
42
+ indication: string;
43
+ permittedSpeed: string;
44
+ guidance: string;
45
+ };
46
+ };
28
47
  };
29
48
  };
30
- declare const SpeedSpaceChart: ({ width, height, backgroundColor, data, setHeight, translations, }: SpeedSpaceChartProps) => React.JSX.Element;
49
+ declare const SpeedSpaceChart: ({ width, height, backgroundColor, data, setHeight, translations, fetchEtcsBrakingCurves, etcsBrakingCurves, }: SpeedSpaceChartProps) => React.JSX.Element;
31
50
  export default SpeedSpaceChart;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import type { Store } from '../../types';
2
+ import type { EtcsBrakingCurveType, EtcsBrakingType, EtcsSpeedValue, Store } from '../../types';
3
+ import type { SpeedSpaceChartProps } from '../SpeedSpaceChart';
3
4
  type DetailsBoxProps = {
4
5
  width: number;
5
6
  height: number;
@@ -8,6 +9,8 @@ type DetailsBoxProps = {
8
9
  curveY: number;
9
10
  speedText: string;
10
11
  ecoSpeedText: string;
12
+ etcsSpeedValues?: Record<EtcsBrakingType, Record<EtcsBrakingCurveType, EtcsSpeedValue[]>>;
13
+ translations?: SpeedSpaceChartProps['translations'];
11
14
  effortText: string;
12
15
  electricalModeText: string;
13
16
  electricalProfileText: string;
@@ -15,5 +18,5 @@ type DetailsBoxProps = {
15
18
  previousGradientText: number;
16
19
  modeText: string;
17
20
  };
18
- declare const DetailsBox: ({ width, height, store, curveX, curveY, speedText, ecoSpeedText, effortText, electricalModeText, electricalProfileText, powerRestrictionText, previousGradientText, modeText, }: DetailsBoxProps) => React.JSX.Element;
21
+ declare const DetailsBox: ({ width, height, store, curveX, curveY, speedText, ecoSpeedText, etcsSpeedValues, translations, effortText, electricalModeText, electricalProfileText, powerRestrictionText, previousGradientText, modeText, }: DetailsBoxProps) => React.JSX.Element;
19
22
  export default DetailsBox;
@@ -9,6 +9,7 @@ type SettingsPanelProps = {
9
9
  adjustHeightOnLayerChange: (layerName: 'electricalProfiles' | 'powerRestrictions' | 'speedLimitTags', isCurrentlyActive: boolean) => void;
10
10
  translations?: SpeedSpaceChartProps['translations'];
11
11
  testIdPrefix?: string;
12
+ displayEtcs?: boolean;
12
13
  };
13
- declare const SettingsPanel: ({ color, store, setStore, setIsMouseHoveringSettingsPanel, adjustHeightOnLayerChange, translations, testIdPrefix, }: SettingsPanelProps) => React.JSX.Element;
14
+ declare const SettingsPanel: ({ color, store, setStore, setIsMouseHoveringSettingsPanel, adjustHeightOnLayerChange, translations, testIdPrefix, displayEtcs, }: SettingsPanelProps) => React.JSX.Element;
14
15
  export default SettingsPanel;