@osrd-project/ui-charts 0.0.71 → 0.0.72

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.
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type ManchetteProps } from './Manchette';
3
3
  import { type SpaceTimeChartProps } from '../../spaceTimeChart';
4
+ import { type SplitPoint } from '../hooks/useManchetteWithSpaceTimeChart';
4
5
  import { type ProjectPathTrainResult, type Waypoint } from '../types';
5
6
  export type ManchetteWithSpaceTimeChartProps = {
6
7
  waypoints: Waypoint[];
@@ -10,6 +11,7 @@ export type ManchetteWithSpaceTimeChartProps = {
10
11
  header?: React.ReactNode;
11
12
  manchetteProps?: ManchetteProps;
12
13
  spaceTimeChartProps?: SpaceTimeChartProps;
14
+ splitPoints?: SplitPoint[];
13
15
  };
14
16
  /**
15
17
  * A simple component to display a manchette and a space time chart.
@@ -17,5 +19,5 @@ export type ManchetteWithSpaceTimeChartProps = {
17
19
  * This only covers basic usage. For more advanced control over the manchette
18
20
  * and space time chart, the useManchetteWithSpaceTimeChart() hook can be used.
19
21
  */
20
- declare const ManchetteWithSpaceTimeChart: ({ waypoints, projectPathTrainResult, height, children, header, manchetteProps: additionalManchetteProps, spaceTimeChartProps: additionalSpaceTimeChartProps, }: ManchetteWithSpaceTimeChartProps) => React.JSX.Element;
22
+ declare const ManchetteWithSpaceTimeChart: ({ waypoints, projectPathTrainResult, height, children, header, manchetteProps: additionalManchetteProps, spaceTimeChartProps: additionalSpaceTimeChartProps, splitPoints, }: ManchetteWithSpaceTimeChartProps) => React.JSX.Element;
21
23
  export default ManchetteWithSpaceTimeChart;
@@ -1,82 +1,72 @@
1
- import type { SpaceTimeChartProps } from '../../spaceTimeChart';
2
- import type { ProjectPathTrainResult, Waypoint } from '../types';
3
- declare const useManchetteWithSpaceTimeChart: ({ waypoints, projectPathTrainResult, manchetteWithSpaceTimeChartRef, height, spaceTimeChartRef, defaultTimeOrigin, defaultSpaceOrigin, }: {
1
+ import React, { type ReactNode } from 'react';
2
+ import { type SpaceScale, type SpaceTimeChartProps } from '../../spaceTimeChart';
3
+ import type { ManchetteProps } from '../components/Manchette';
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
+ };
39
+ export type SplitPoint = {
40
+ /** helper identify nodes for this split point in the React tree */
41
+ id: string;
42
+ /** position of this split point, in mm from start */
43
+ position: number;
44
+ /** size of this split point, in pixels on screen */
45
+ size: number;
46
+ /** a React node to render the split point, space/time chart side */
47
+ spaceTimeChartNode?: ReactNode;
48
+ /** a React node to render the split point, manchette side */
49
+ manchetteNode?: ReactNode;
50
+ };
51
+ declare const useManchetteWithSpaceTimeChart: ({ waypoints, manchetteWithSpaceTimeChartRef, height, spaceTimeChartRef, defaultTimeOrigin, defaultSpaceOrigin, splitPoints, }: {
4
52
  waypoints: Waypoint[];
5
- projectPathTrainResult: ProjectPathTrainResult[];
6
53
  manchetteWithSpaceTimeChartRef: React.RefObject<HTMLDivElement>;
7
54
  height?: number;
8
55
  spaceTimeChartRef?: React.RefObject<HTMLDivElement>;
9
56
  defaultTimeOrigin?: number;
10
57
  defaultSpaceOrigin?: number;
58
+ splitPoints?: SplitPoint[];
11
59
  }) => {
12
- manchetteProps: {
13
- contents: import("../types").InteractiveWaypoint[];
14
- zoomYIn: () => void;
15
- zoomYOut: () => void;
16
- resetZoom: () => void;
17
- toggleMode: () => void;
18
- yZoom: number;
19
- isProportional: boolean;
20
- yOffset: number;
21
- };
22
- spaceTimeChartProps: {
23
- operationalPoints: {
24
- id: string;
25
- label: string;
26
- position: number;
27
- importanceLevel: number;
28
- }[];
29
- spaceScales: {
30
- from: number;
31
- to: number;
32
- size: number;
33
- }[] | ({
34
- coefficient: number;
35
- size?: undefined;
36
- from: number;
37
- to: number;
38
- } | {
39
- size: number;
40
- coefficient?: undefined;
41
- from: number;
42
- to: number;
43
- })[];
44
- timeScale: number;
45
- paths: {
46
- id: string;
47
- label: string;
48
- points: {
49
- time: number;
50
- position: number;
51
- }[];
52
- color: string;
53
- }[];
54
- xOffset: number;
55
- yOffset: number;
56
- timeOrigin: number;
57
- spaceOrigin: number;
58
- rect: {
59
- timeStart: Date;
60
- timeEnd: Date;
61
- spaceStart: number;
62
- spaceEnd: number;
63
- } | null;
64
- onZoom: ({ delta, position }: Parameters<NonNullable<SpaceTimeChartProps["onZoom"]>>[0]) => void;
65
- onPan: (payload: Parameters<NonNullable<SpaceTimeChartProps["onPan"]>>[0]) => void;
66
- };
60
+ manchetteProps: ManchetteProps;
61
+ spaceTimeChartProps: SpaceTimeChartProps;
67
62
  handleScroll: () => void;
68
63
  handleXZoom: (newXZoom: number, xPosition?: number) => void;
69
64
  xZoom: number;
70
65
  toggleZoomMode: () => void;
71
66
  zoomMode: boolean;
72
- rect: {
73
- timeStart: Date;
74
- timeEnd: Date;
75
- spaceStart: number;
76
- spaceEnd: number;
77
- } | null;
67
+ rect: State["rect"];
78
68
  timeScale: number;
79
69
  spaceScale: number;
80
- setTimeOrigin: (newTimeOrigin: number) => void;
70
+ setTimeOrigin: (v: number) => void;
81
71
  };
82
72
  export default useManchetteWithSpaceTimeChart;
@@ -2,8 +2,10 @@ import '@osrd-project/ui-core/dist/theme.css';
2
2
  import './styles/main.css';
3
3
  import './consts';
4
4
  export { default as Manchette, type ManchetteProps } from './components/Manchette';
5
- export { default as ManchetteWithSpaceTimeChart } from './components/ManchetteWithSpaceTimeChart';
5
+ export { default as ManchetteWithSpaceTimeChart, type ManchetteWithSpaceTimeChartProps, } from './components/ManchetteWithSpaceTimeChart';
6
6
  export { DEFAULT_ZOOM_MS_PER_PX } from './consts';
7
7
  export { default as useManchetteWithSpaceTimeChart } from './hooks/useManchetteWithSpaceTimeChart';
8
+ export { default as usePaths } from './hooks/usePaths';
8
9
  export type { WaypointMenuData, Waypoint, ProjectPathTrainResult, InteractiveWaypoint, } from './types';
9
- export { timeScaleToZoomValue } from './utils/helpers';
10
+ export { positionMmToKm } from './utils';
11
+ export { timeScaleToZoomValue, isInteractiveWaypoint } from './utils/helpers';
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from 'react';
1
2
  import type { InteractiveWaypoint, Waypoint } from '../types';
2
3
  export declare const zoomValueToTimeScale: (slider: number) => number;
3
4
  export declare const timeScaleToZoomValue: (timeScale: number) => number;
@@ -22,7 +23,7 @@ type WaypointsOptions = {
22
23
  height: number;
23
24
  };
24
25
  export declare const filterVisibleElements: (elements: Waypoint[], totalDistance: number, heightWithoutFinalWaypoint: number, minSpace: number) => Waypoint[];
25
- export declare const computeWaypointsToDisplay: (waypoints: Waypoint[], { height, isProportional, yZoom }: WaypointsOptions, minZoomMillimeterPerPx: number, maxZoomMillimeterPerPx: number) => InteractiveWaypoint[];
26
+ export declare const selectWaypointsToDisplay: (waypoints: Waypoint[], { height, isProportional, yZoom }: WaypointsOptions) => Waypoint[];
26
27
  /**
27
28
  * 2 modes for space scales
28
29
  * km (isProportional): { coefficient: gives a scale in meter/pixel }
@@ -43,4 +44,5 @@ export declare const getScales: (waypoints: Waypoint[], { isProportional, yZoom
43
44
  from: number;
44
45
  to: number;
45
46
  })[];
47
+ export declare const isInteractiveWaypoint: (item: InteractiveWaypoint | ReactNode) => item is InteractiveWaypoint;
46
48
  export {};
@@ -4,6 +4,7 @@ export type OccupancyBlock = {
4
4
  spaceStart: number;
5
5
  spaceEnd: number;
6
6
  color: string;
7
+ blinking?: boolean;
7
8
  };
8
9
  export type OccupancyBlockLayerProps = {
9
10
  occupancyBlocks: OccupancyBlock[];
@@ -49,8 +49,8 @@ export type PathData = {
49
49
  };
50
50
  export type OperationalPoint = {
51
51
  id: string;
52
- label: string;
53
52
  position: number;
53
+ label?: string;
54
54
  importanceLevel?: number;
55
55
  };
56
56
  export type Axis = 'x' | 'y';
@@ -132,7 +132,8 @@ export type SpaceTimeChartTheme = {
132
132
  dateCaptionsSize: number;
133
133
  };
134
134
  export type SpaceTimeChartProps = {
135
- children?: ReactNode[];
135
+ children?: ReactNode | ReactNode[];
136
+ additionalChildren?: ReactNode | ReactNode[];
136
137
  operationalPoints: OperationalPoint[];
137
138
  spaceOrigin: number;
138
139
  spaceScales: SpaceScale[];
package/dist/theme.css CHANGED
@@ -3102,7 +3102,7 @@ video {
3102
3102
  }
3103
3103
 
3104
3104
  .modal-ui-overlay {
3105
- position: fixed;
3105
+ position: absolute;
3106
3106
  top: 0;
3107
3107
  left: 0;
3108
3108
  right: 0;
@@ -4689,6 +4689,18 @@ video {
4689
4689
  font-size: 0.875rem;
4690
4690
  line-height: 14px;
4691
4691
  }
4692
+ .manchette-container .waypoints-list {
4693
+ width: 349px;
4694
+ border-bottom-left-radius: 0.25rem;
4695
+ padding-left: 0.5rem;
4696
+ padding-right: 1.625rem;
4697
+ --tw-bg-opacity: 1;
4698
+ background-color: rgba(255, 255, 255, 1);
4699
+ background-color: rgba(255, 255, 255, var(--tw-bg-opacity, 1));
4700
+ }
4701
+ .manchette-container .waypoints-list .waypoint-wrapper:last-child .waypoint::after {
4702
+ bottom: 16px;
4703
+ }
4692
4704
  .manchette-space-time-chart-wrapper {
4693
4705
  border-radius: 10px;
4694
4706
  box-shadow:
@@ -4707,9 +4719,10 @@ video {
4707
4719
  overflow-y: clip;
4708
4720
  }
4709
4721
  .manchette-space-time-chart-wrapper .space-time-chart-container {
4710
- height: 561px;
4711
- width: 100%;
4722
+ top: 0;
4723
+ right: 0;
4712
4724
  bottom: 0;
4725
+ left: 0;
4713
4726
  }
4714
4727
  .waypoint {
4715
4728
  --tw-text-opacity: 1;
@@ -4818,18 +4831,6 @@ video {
4818
4831
  background-color: rgba(148, 145, 142, 1);
4819
4832
  background-color: rgba(148, 145, 142, var(--tw-bg-opacity, 1));
4820
4833
  }
4821
- .waypoint-list {
4822
- width: 349px;
4823
- border-bottom-left-radius: 0.25rem;
4824
- padding-left: 0.5rem;
4825
- padding-right: 1.625rem;
4826
- --tw-bg-opacity: 1;
4827
- background-color: rgba(255, 255, 255, 1);
4828
- background-color: rgba(255, 255, 255, var(--tw-bg-opacity, 1));
4829
- }
4830
- .waypoint-list .waypoint-wrapper:last-child .waypoint::after {
4831
- bottom: 16px;
4832
- }
4833
4834
  .menu {
4834
4835
  --tw-bg-opacity: 1;
4835
4836
  background-color: rgba(245, 245, 245, 1);