@osrd-project/ui-charts 0.0.78 → 0.0.80

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.
@@ -11,6 +11,7 @@ export type ManchetteProps = {
11
11
  yZoom?: number;
12
12
  children?: React.ReactNode;
13
13
  isProportional?: boolean;
14
+ testIdPrefix?: string;
14
15
  toggleMode: () => void;
15
16
  };
16
17
  declare const Manchette: ({ zoomYIn, zoomYOut, resetZoom, yZoom, contents, activeWaypointId, activeWaypointRef, isProportional, toggleMode, children, height, }: ManchetteProps) => React.JSX.Element;
@@ -7,6 +7,7 @@ type WaypointProps = {
7
7
  waypointRef?: React.RefObject<HTMLDivElement | null>;
8
8
  isActive: boolean;
9
9
  isMenuActive?: boolean;
10
+ testIdPrefix?: string;
10
11
  };
11
- declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick }, waypointRef, isActive, isMenuActive, }: WaypointProps) => React.JSX.Element;
12
+ declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick }, waypointRef, isActive, isMenuActive, testIdPrefix, }: WaypointProps) => React.JSX.Element;
12
13
  export default Waypoint;
@@ -1,6 +1,5 @@
1
1
  export declare const INITIAL_OP_LIST_HEIGHT = 521;
2
2
  export declare const BASE_WAYPOINT_HEIGHT = 32;
3
- export declare const INITIAL_WAYPOINT_LIST_HEIGHT = 521;
4
3
  export declare const INITIAL_SPACE_TIME_CHART_HEIGHT: number;
5
4
  export declare const MIN_ZOOM_MS_PER_PX = 600000;
6
5
  export declare const MAX_ZOOM_MS_PER_PX = 625;
@@ -1,5 +1,11 @@
1
- import { type DataPoint } from '../lib/types';
1
+ import type { DataPoint, PickingElement } from '../lib/types';
2
+ export type QuadrilaterPickingElement = PickingElement & {
3
+ type: 'quadrilateral';
4
+ id: string;
5
+ };
6
+ export declare function isQuadrilaterPickingElement(element: PickingElement): element is QuadrilaterPickingElement;
2
7
  export type QuadrilateralProps = {
8
+ id: string;
3
9
  vertices: [DataPoint, DataPoint, DataPoint, DataPoint];
4
10
  style: {
5
11
  backgroundColor: string;
@@ -16,4 +22,4 @@ export type QuadrilateralProps = {
16
22
  * vertices[3] /________/ vertices[2]
17
23
  *
18
24
  */
19
- export declare const Quadrilateral: ({ vertices, style }: QuadrilateralProps) => null;
25
+ export declare const Quadrilateral: ({ id, vertices, style }: QuadrilateralProps) => null;
@@ -18,6 +18,15 @@ export declare function getAliasedDiscShape(radius: number): Uint8Array;
18
18
  * This function draws an aliased disc, using a shape computed by getDiscShape.
19
19
  */
20
20
  export declare function drawAliasedDisc(imageData: ImageData, { x: centerX, y: centerY }: Point, radius: number, [r, g, b]: RGBColor | RGBAColor, drawOnBottom: boolean, scalingRatio?: number): void;
21
+ /**
22
+ * Draws an aliased quadrilateral
23
+ *
24
+ * vertices[0] ________ vertices[1]
25
+ * / /
26
+ * vertices[3] /________/ vertices[2]
27
+ *
28
+ */
29
+ export declare function drawAliasedQuadrilateral(imageData: ImageData, points: [Point, Point, Point, Point], [r, g, b]: RGBColor | RGBAColor, scalingRatio?: number): void;
21
30
  export declare function drawAliasedRect(imageData: ImageData, { x, y }: Point, width: number, height: number, [r, g, b]: RGBColor | RGBAColor, scalingRatio?: number): void;
22
31
  export declare function drawPathStopExtremity(ctx: CanvasRenderingContext2D, timePixel: number, spacePixel: number, swapAxis: boolean): void;
23
32
  export declare function drawPathOutExtremity(ctx: CanvasRenderingContext2D, timePixel: number, spacePixel: number, swapAxis: boolean, extremityType: 'from' | 'to', pathDirection: Direction): void;
@@ -43,8 +52,11 @@ export declare function computeVisibleTimeMarkers<T extends object = {
43
52
  * To get crisp horizontal or vertical lines on a canvas, we must draw them as thin as possible, in
44
53
  * terms of actual pixels on screen.
45
54
  * The best way for this is:
46
- * - To center lines 1, 3, 5... pixels wide in the middle of a pixel
47
- * - To center lines 2, 4, 6... pixels wide between two pixels
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...)
48
60
  * @param rawCoordinate Any input coordinate to fix
49
61
  * @param lineWidth The width of the line to draw
50
62
  * @param devicePixelRatio
@@ -1,4 +1,7 @@
1
1
  import { type RGBAColor } from '../lib/types';
2
+ export declare const WHITE_ALPHA_75 = "#ffffffbf";
3
+ export declare const BLACK_ALPHA_25 = "#00000025";
4
+ export declare const GREY_50 = "#797671";
2
5
  /**
3
6
  * This function returns a unique hex color corresponding to the given index. The colors are
4
7
  * generated as #000001, #000002 ... #0000ff, #000100 etc.
@@ -2,13 +2,13 @@ import React from 'react';
2
2
  import type { Store } from '../../types';
3
3
  import type { SpeedSpaceChartProps } from '../SpeedSpaceChart';
4
4
  type SettingsPanelProps = {
5
- globalHeight: number;
6
5
  color: string;
7
6
  store: Store;
8
7
  setStore: React.Dispatch<React.SetStateAction<Store>>;
9
8
  setIsMouseHoveringSettingsPanel: React.Dispatch<React.SetStateAction<boolean>>;
9
+ adjustHeightOnLayerChange: (layerName: 'electricalProfiles' | 'powerRestrictions' | 'speedLimitTags', isCurrentlyActive: boolean) => void;
10
10
  translations?: SpeedSpaceChartProps['translations'];
11
11
  testIdPrefix?: string;
12
12
  };
13
- declare const SettingsPanel: ({ globalHeight, color, store, setStore, setIsMouseHoveringSettingsPanel, translations, testIdPrefix, }: SettingsPanelProps) => React.JSX.Element;
13
+ declare const SettingsPanel: ({ color, store, setStore, setIsMouseHoveringSettingsPanel, adjustHeightOnLayerChange, translations, testIdPrefix, }: SettingsPanelProps) => React.JSX.Element;
14
14
  export default SettingsPanel;
@@ -51,3 +51,8 @@ export declare const WHITE: chroma.Color;
51
51
  * COLOR_DICTIONARY maps specific colors to their corresponding secondary colors used for speed limit tags.
52
52
  */
53
53
  export declare const COLOR_DICTIONARY: ColorDictionary;
54
+ export declare const ZOOM_CONFIG: {
55
+ MIN_RATIO: number;
56
+ MAX_RATIO: number;
57
+ SLIDER_WIDTH: number;
58
+ };
@@ -2,3 +2,4 @@ import * as d3zoom from 'd3-zoom';
2
2
  import type { Store } from '../../types';
3
3
  export declare const resetZoom: () => void;
4
4
  export declare const zoom: (setStore: React.Dispatch<React.SetStateAction<Store>>) => d3zoom.ZoomBehavior<Element, unknown>;
5
+ export declare const computeLeftOffsetOnZoom: (value: number) => number;
@@ -2,9 +2,8 @@ import React from 'react';
2
2
  import type { Store } from '../../types';
3
3
  type ReticleLayerProps = {
4
4
  width: number;
5
- height: number;
6
- heightOffset: number;
5
+ internalHeight: number;
7
6
  store: Store;
8
7
  };
9
- declare const ReticleLayer: ({ width, height, heightOffset, store }: ReticleLayerProps) => React.JSX.Element;
8
+ declare const ReticleLayer: ({ width, internalHeight: height, store }: ReticleLayerProps) => React.JSX.Element;
10
9
  export default ReticleLayer;
@@ -29,19 +29,6 @@ export declare const maxSpeedValue: (store: Store) => number;
29
29
  */
30
30
  export declare const maxPositionValue: (speeds: LayerData<number>[]) => number;
31
31
  export declare const clearCanvas: (ctx: CanvasRenderingContext2D, width: number, height: number) => void;
32
- /**
33
- * Calculates the adaptive height based on the height supplied and the lineaires displayed.
34
- * @param height - The initial height value.
35
- * @param layersDisplay - The linear display options.
36
- * @param isIncludingLinearLayers - A flag to add or remove layers. Default is true.
37
- * @returns The calculated adaptive height.
38
- */
39
- export declare const getAdaptiveHeight: (height: number, layersDisplay: Store["layersDisplay"], isIncludingLinearLayers?: boolean) => number;
40
- /**
41
- * Calculates the top position for the linear layers based on the height and the layers displayed.
42
- * The speed limit tags linear layer needs to call this function with the isSpeedLimitByTag flag set to true.
43
- */
44
- export declare const getLinearLayerMarginTop: (height: number, layersDisplay: Store["layersDisplay"], isSpeedLimitByTag?: boolean) => number;
45
32
  export declare const getLinearLayersDisplayedHeight: (layersDisplay: Store["layersDisplay"]) => number;
46
33
  /**
47
34
  * Calculates the position on the graph scale based on the given parameters.