@osrd-project/ui-charts 0.0.74 → 0.0.78
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/README.md +22 -19
- package/dist/index.esm.js +744 -413
- package/dist/index.esm.js.map +1 -1
- package/dist/manchette/components/Manchette.d.ts +4 -3
- package/dist/manchette/components/Waypoint.d.ts +6 -4
- package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +13 -3
- package/dist/manchette/index.d.ts +5 -4
- package/dist/manchette/types.d.ts +0 -5
- package/dist/manchette/utils/helpers.d.ts +1 -5
- package/dist/manchette/utils/index.d.ts +3 -2
- package/dist/spaceTimeChart/index.d.ts +1 -0
- package/dist/spaceTimeChart/lib/types.d.ts +4 -6
- package/dist/spaceTimeChart/utils/__tests__/scales.spec.d.ts +1 -0
- package/dist/spaceTimeChart/utils/scales.d.ts +29 -0
- package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +2 -1
- package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +2 -1
- package/dist/speedSpaceChart/components/hooks.d.ts +1 -1
- package/dist/theme.css +1683 -2656
- package/dist/theme.css.map +1 -1
- package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +10 -2
- package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +5 -3
- package/dist/trackOccupancyDiagram/components/TrackOccupancyStandalone.d.ts +10 -0
- package/dist/trackOccupancyDiagram/components/consts.d.ts +3 -1
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +13 -14
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +2 -2
- package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +7 -15
- package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +9 -9
- package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +6 -3
- package/dist/trackOccupancyDiagram/components/types.d.ts +14 -22
- package/dist/trackOccupancyDiagram/index.d.ts +4 -0
- package/package.json +10 -10
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { InteractiveWaypoint
|
|
2
|
+
import type { InteractiveWaypoint } from '../types';
|
|
3
3
|
export type ManchetteProps = {
|
|
4
4
|
contents: (InteractiveWaypoint | React.ReactNode)[];
|
|
5
|
-
|
|
5
|
+
activeWaypointId?: string;
|
|
6
|
+
activeWaypointRef?: React.RefObject<HTMLDivElement | null>;
|
|
6
7
|
zoomYIn: () => void;
|
|
7
8
|
zoomYOut: () => void;
|
|
8
9
|
resetZoom: () => void;
|
|
@@ -12,5 +13,5 @@ export type ManchetteProps = {
|
|
|
12
13
|
isProportional?: boolean;
|
|
13
14
|
toggleMode: () => void;
|
|
14
15
|
};
|
|
15
|
-
declare const Manchette: ({ zoomYIn, zoomYOut, resetZoom, yZoom, contents,
|
|
16
|
+
declare const Manchette: ({ zoomYIn, zoomYOut, resetZoom, yZoom, contents, activeWaypointId, activeWaypointRef, isProportional, toggleMode, children, height, }: ManchetteProps) => React.JSX.Element;
|
|
16
17
|
export default Manchette;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type InteractiveWaypoint } from '../types';
|
|
3
3
|
type WaypointProps = {
|
|
4
|
-
waypoint: InteractiveWaypoint
|
|
5
|
-
|
|
4
|
+
waypoint: Omit<InteractiveWaypoint, 'name'> & {
|
|
5
|
+
name?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
waypointRef?: React.RefObject<HTMLDivElement | null>;
|
|
6
8
|
isActive: boolean;
|
|
7
9
|
isMenuActive?: boolean;
|
|
8
10
|
};
|
|
9
|
-
declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick },
|
|
11
|
+
declare const Waypoint: ({ waypoint: { name, secondaryCode, id, position, onClick }, waypointRef, isActive, isMenuActive, }: WaypointProps) => React.JSX.Element;
|
|
10
12
|
export default Waypoint;
|
|
@@ -48,14 +48,24 @@ export type SplitPoint = {
|
|
|
48
48
|
/** a React node to render the split point, manchette side */
|
|
49
49
|
manchetteNode?: ReactNode;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
export type ManchetteWithSpaceTimeChartOptions = {
|
|
52
|
+
displayTimeCaptions: boolean;
|
|
53
|
+
enableTimePan: boolean;
|
|
54
|
+
enableSpacePan: boolean;
|
|
55
|
+
enableTimeZoom: boolean;
|
|
56
|
+
};
|
|
57
|
+
export declare const DEFAULT_MANCHETTE_WITH_SPACE_TIME_CHART_OPTIONS: ManchetteWithSpaceTimeChartOptions;
|
|
58
|
+
declare const useManchetteWithSpaceTimeChart: ({ waypoints, manchetteWithSpaceTimeChartRef, height, spaceTimeChartRef, defaultTimeOrigin, defaultSpaceOrigin, defaultXOffset, verticalPadding, splitPoints, options, }: {
|
|
52
59
|
waypoints: Waypoint[];
|
|
53
|
-
manchetteWithSpaceTimeChartRef: React.RefObject<HTMLDivElement>;
|
|
60
|
+
manchetteWithSpaceTimeChartRef: React.RefObject<HTMLDivElement | null>;
|
|
54
61
|
height?: number;
|
|
55
|
-
spaceTimeChartRef?: React.RefObject<HTMLDivElement>;
|
|
62
|
+
spaceTimeChartRef?: React.RefObject<HTMLDivElement | null>;
|
|
56
63
|
defaultTimeOrigin?: number;
|
|
57
64
|
defaultSpaceOrigin?: number;
|
|
65
|
+
defaultXOffset?: number;
|
|
66
|
+
verticalPadding?: number;
|
|
58
67
|
splitPoints?: SplitPoint[];
|
|
68
|
+
options?: Partial<ManchetteWithSpaceTimeChartOptions>;
|
|
59
69
|
}) => {
|
|
60
70
|
manchetteProps: ManchetteProps;
|
|
61
71
|
spaceTimeChartProps: SpaceTimeChartProps;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import '@osrd-project/ui-core/dist/theme.css';
|
|
2
2
|
import './styles/main.css';
|
|
3
3
|
import './consts';
|
|
4
|
+
export { default as WaypointComponent } from './components/Waypoint';
|
|
4
5
|
export { default as Manchette, type ManchetteProps } from './components/Manchette';
|
|
5
6
|
export { default as ManchetteWithSpaceTimeChart, type ManchetteWithSpaceTimeChartProps, } from './components/ManchetteWithSpaceTimeChart';
|
|
6
|
-
export { DEFAULT_ZOOM_MS_PER_PX } from './consts';
|
|
7
|
-
export { default as useManchetteWithSpaceTimeChart } from './hooks/useManchetteWithSpaceTimeChart';
|
|
7
|
+
export { DEFAULT_ZOOM_MS_PER_PX, BASE_WAYPOINT_HEIGHT } from './consts';
|
|
8
|
+
export { default as useManchetteWithSpaceTimeChart, type SplitPoint, } from './hooks/useManchetteWithSpaceTimeChart';
|
|
8
9
|
export { default as usePaths } from './hooks/usePaths';
|
|
9
|
-
export type {
|
|
10
|
-
export { positionMmToKm } from './utils';
|
|
10
|
+
export type { Waypoint, ProjectPathTrainResult, InteractiveWaypoint } from './types';
|
|
11
|
+
export { positionMmToKm, positionKmToMm } from './utils';
|
|
11
12
|
export { timeScaleToZoomValue, isInteractiveWaypoint } from './utils/helpers';
|
|
@@ -10,11 +10,6 @@ export type InteractiveWaypoint = Waypoint & {
|
|
|
10
10
|
styles?: CSSProperties;
|
|
11
11
|
onClick?: (waypointId: string) => void;
|
|
12
12
|
};
|
|
13
|
-
export type WaypointMenuData = {
|
|
14
|
-
menu: React.ReactNode;
|
|
15
|
-
activeWaypointId?: string;
|
|
16
|
-
manchetteWrapperRef: React.RefObject<HTMLDivElement>;
|
|
17
|
-
};
|
|
18
13
|
export type ProjectPathTrainResult = {
|
|
19
14
|
id: string;
|
|
20
15
|
name: string;
|
|
@@ -29,11 +29,7 @@ export declare const selectWaypointsToDisplay: (waypoints: Waypoint[], { height,
|
|
|
29
29
|
* km (isProportional): { coefficient: gives a scale in meter/pixel }
|
|
30
30
|
* linear: { size: height in pixel } (each point distributed evenly along the height of manchette.)
|
|
31
31
|
*/
|
|
32
|
-
export declare const getScales: (waypoints: Waypoint[], { isProportional, yZoom }: WaypointsOptions, minZoomMillimeterPerPx: number, maxZoomMillimeterPerPx: number) => {
|
|
33
|
-
from: number;
|
|
34
|
-
to: number;
|
|
35
|
-
size: number;
|
|
36
|
-
}[] | ({
|
|
32
|
+
export declare const getScales: (waypoints: Waypoint[], { isProportional, yZoom, height }: WaypointsOptions, minZoomMillimeterPerPx: number, maxZoomMillimeterPerPx: number) => ({
|
|
37
33
|
coefficient: number;
|
|
38
34
|
size?: undefined;
|
|
39
35
|
from: number;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export declare const getHeightWithoutLastWaypoint: (height: number) => number;
|
|
2
2
|
export declare const positionMmToKm: (position: number) => number;
|
|
3
|
+
export declare const positionKmToMm: (position: number) => number;
|
|
3
4
|
export declare const msToS: (time: number) => number;
|
|
4
|
-
export declare const calcTotalDistance:
|
|
5
|
+
export declare const calcTotalDistance: (ops: {
|
|
5
6
|
position: number;
|
|
6
|
-
}
|
|
7
|
+
}[]) => number;
|
|
7
8
|
type Point = {
|
|
8
9
|
x: number;
|
|
9
10
|
y: number;
|
|
@@ -17,3 +17,4 @@ export type { HoveredItem, SpaceTimeChartProps, SpaceScale, OperationalPoint, Sp
|
|
|
17
17
|
export { isPathOnScreen } from './utils/geometry';
|
|
18
18
|
export { getSpaceAtTime } from './utils/scales';
|
|
19
19
|
export { getCrispLineCoordinate } from './utils/canvas';
|
|
20
|
+
export { computeRectZoomOffsets } from './utils/scales';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type HTMLProps, type ReactNode } from 'react';
|
|
2
|
-
import type { Track, OccupancyZone } from '../../trackOccupancyDiagram/components/types';
|
|
3
2
|
export type Point = {
|
|
4
3
|
x: number;
|
|
5
4
|
y: number;
|
|
@@ -61,7 +60,7 @@ export type PixelToTime = (x: number) => number;
|
|
|
61
60
|
export type PixelToSpace = (y: number) => number;
|
|
62
61
|
export type PointToData = (point: Point) => DataPoint;
|
|
63
62
|
export type DataToPoint = (data: DataPoint) => Point;
|
|
64
|
-
export declare const PICKING_LAYERS: readonly ["paths"];
|
|
63
|
+
export declare const PICKING_LAYERS: readonly ["paths", "overlay"];
|
|
65
64
|
export type PickingLayerType = (typeof PICKING_LAYERS)[number];
|
|
66
65
|
export declare const LAYERS: readonly ["background", "graduations", "paths", "overlay", "captions"];
|
|
67
66
|
export type LayerType = (typeof LAYERS)[number];
|
|
@@ -143,6 +142,7 @@ export type SpaceTimeChartProps = {
|
|
|
143
142
|
yOffset?: number;
|
|
144
143
|
swapAxis?: boolean;
|
|
145
144
|
enableSnapping?: boolean;
|
|
145
|
+
hideTimeCaptions?: boolean;
|
|
146
146
|
hideGrid?: boolean;
|
|
147
147
|
hidePathsLabels?: boolean;
|
|
148
148
|
hideDates?: boolean;
|
|
@@ -184,8 +184,6 @@ export type SpaceTimeChartProps = {
|
|
|
184
184
|
export type SpaceTimeChartContextType = {
|
|
185
185
|
width: number;
|
|
186
186
|
height: number;
|
|
187
|
-
trackOccupancyWidth?: number;
|
|
188
|
-
trackOccupancyHeight?: number;
|
|
189
187
|
timeAxis: Axis;
|
|
190
188
|
spaceAxis: Axis;
|
|
191
189
|
swapAxis: boolean;
|
|
@@ -199,6 +197,7 @@ export type SpaceTimeChartContextType = {
|
|
|
199
197
|
timeScale: number;
|
|
200
198
|
spaceOrigin: number;
|
|
201
199
|
spaceScaleTree: NormalizedScaleTree;
|
|
200
|
+
flatSteps: Set<number>;
|
|
202
201
|
getTimePixel: TimeToPixel;
|
|
203
202
|
getSpacePixel: SpaceToPixel;
|
|
204
203
|
getPoint: DataToPoint;
|
|
@@ -206,11 +205,10 @@ export type SpaceTimeChartContextType = {
|
|
|
206
205
|
getSpace: PixelToSpace;
|
|
207
206
|
getData: PointToData;
|
|
208
207
|
operationalPoints: OperationalPoint[];
|
|
209
|
-
tracks?: Track[];
|
|
210
|
-
occupancyZones?: OccupancyZone[];
|
|
211
208
|
theme: SpaceTimeChartTheme;
|
|
212
209
|
captionSize: number;
|
|
213
210
|
enableSnapping: boolean;
|
|
211
|
+
hideTimeCaptions: boolean;
|
|
214
212
|
hideGrid: boolean;
|
|
215
213
|
hidePathsLabels: boolean;
|
|
216
214
|
hideDates: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,11 @@ import { type NormalizedScaleTree, type NormalizedScale, type SpaceScale, type S
|
|
|
7
7
|
* purpose.
|
|
8
8
|
*/
|
|
9
9
|
export declare function spaceScalesToBinaryTree(spaceOrigin: number, spaceScales: SpaceScale[], skipSiblingReferences?: boolean): NormalizedScaleTree;
|
|
10
|
+
/**
|
|
11
|
+
* This function takes a sequence of SpaceScales, identifies the flat steps (i.e. the scales that do
|
|
12
|
+
* not increase the position), and returns them in a set.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFlatSteps(spaceScales: SpaceScale[]): Set<number>;
|
|
10
15
|
/**
|
|
11
16
|
* This function takes a NormalizedScaleTree and a position, and returns the leaf node from the
|
|
12
17
|
* tree that contains that position.
|
|
@@ -43,3 +48,27 @@ export declare function getSpaceAtTime(path: PathData, time: number): number;
|
|
|
43
48
|
* positions between these the two input positions (the array can be empty).
|
|
44
49
|
*/
|
|
45
50
|
export declare function getSpaceBreakpoints(from: number, to: number, tree: NormalizedScaleTree): number[];
|
|
51
|
+
/**
|
|
52
|
+
* in most cases, after the rectangle zoom, the screen will be centered
|
|
53
|
+
* on the center of the rectangle the user drew.
|
|
54
|
+
* In case we reach max zoom, not to break this expectation we need a different offset calculation
|
|
55
|
+
*/
|
|
56
|
+
export declare function computeRectZoomOffsets({ rect, timeOrigin, spaceOrigin, newTimeScale, newSpaceScale, swapAxes, chartWidth, chartHeight, }: {
|
|
57
|
+
rect: {
|
|
58
|
+
timeStart: Date;
|
|
59
|
+
timeEnd: Date;
|
|
60
|
+
spaceStart: number;
|
|
61
|
+
spaceEnd: number;
|
|
62
|
+
};
|
|
63
|
+
timeOrigin: number;
|
|
64
|
+
spaceOrigin: number;
|
|
65
|
+
newTimeScale: number;
|
|
66
|
+
newSpaceScale: number;
|
|
67
|
+
swapAxes: boolean;
|
|
68
|
+
chartWidth: number;
|
|
69
|
+
chartHeight: number;
|
|
70
|
+
}): {
|
|
71
|
+
xOffset: number;
|
|
72
|
+
yOffset: number;
|
|
73
|
+
};
|
|
74
|
+
export declare function sideOffset(origin: number, newScale: number, rectStart: number | Date, rectEnd: number | Date, chartSideSizePx: number, axisPadding?: number): number;
|
|
@@ -4,6 +4,7 @@ type InteractionButtonsProps = {
|
|
|
4
4
|
reset: () => void;
|
|
5
5
|
openSettingsPanel: () => void;
|
|
6
6
|
store: Store;
|
|
7
|
+
testIdPrefix?: string;
|
|
7
8
|
};
|
|
8
|
-
declare const InteractionButtons: ({ reset, openSettingsPanel, store }: InteractionButtonsProps) => React.JSX.Element;
|
|
9
|
+
declare const InteractionButtons: ({ reset, openSettingsPanel, store, testIdPrefix, }: InteractionButtonsProps) => React.JSX.Element;
|
|
9
10
|
export default InteractionButtons;
|
|
@@ -8,6 +8,7 @@ type SettingsPanelProps = {
|
|
|
8
8
|
setStore: React.Dispatch<React.SetStateAction<Store>>;
|
|
9
9
|
setIsMouseHoveringSettingsPanel: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
10
|
translations?: SpeedSpaceChartProps['translations'];
|
|
11
|
+
testIdPrefix?: string;
|
|
11
12
|
};
|
|
12
|
-
declare const SettingsPanel: ({ globalHeight, color, store, setStore, setIsMouseHoveringSettingsPanel, translations, }: SettingsPanelProps) => React.JSX.Element;
|
|
13
|
+
declare const SettingsPanel: ({ globalHeight, color, store, setStore, setIsMouseHoveringSettingsPanel, translations, testIdPrefix, }: SettingsPanelProps) => React.JSX.Element;
|
|
13
14
|
export default SettingsPanel;
|
|
@@ -6,6 +6,6 @@ type UseCanvasParams = {
|
|
|
6
6
|
store: Store;
|
|
7
7
|
setStore?: React.Dispatch<React.SetStateAction<Store>>;
|
|
8
8
|
};
|
|
9
|
-
type UseCanvas = (draw: DrawFunction, params: UseCanvasParams) => React.RefObject<HTMLCanvasElement>;
|
|
9
|
+
type UseCanvas = (draw: DrawFunction, params: UseCanvasParams) => React.RefObject<HTMLCanvasElement | null>;
|
|
10
10
|
export declare const useCanvas: UseCanvas;
|
|
11
11
|
export {};
|