@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.
Files changed (31) hide show
  1. package/README.md +22 -19
  2. package/dist/index.esm.js +744 -413
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/manchette/components/Manchette.d.ts +4 -3
  5. package/dist/manchette/components/Waypoint.d.ts +6 -4
  6. package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +13 -3
  7. package/dist/manchette/index.d.ts +5 -4
  8. package/dist/manchette/types.d.ts +0 -5
  9. package/dist/manchette/utils/helpers.d.ts +1 -5
  10. package/dist/manchette/utils/index.d.ts +3 -2
  11. package/dist/spaceTimeChart/index.d.ts +1 -0
  12. package/dist/spaceTimeChart/lib/types.d.ts +4 -6
  13. package/dist/spaceTimeChart/utils/__tests__/scales.spec.d.ts +1 -0
  14. package/dist/spaceTimeChart/utils/scales.d.ts +29 -0
  15. package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +2 -1
  16. package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +2 -1
  17. package/dist/speedSpaceChart/components/hooks.d.ts +1 -1
  18. package/dist/theme.css +1683 -2656
  19. package/dist/theme.css.map +1 -1
  20. package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +10 -2
  21. package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +5 -3
  22. package/dist/trackOccupancyDiagram/components/TrackOccupancyStandalone.d.ts +10 -0
  23. package/dist/trackOccupancyDiagram/components/consts.d.ts +3 -1
  24. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +13 -14
  25. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +2 -2
  26. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +7 -15
  27. package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +9 -9
  28. package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +6 -3
  29. package/dist/trackOccupancyDiagram/components/types.d.ts +14 -22
  30. package/dist/trackOccupancyDiagram/index.d.ts +4 -0
  31. package/package.json +10 -10
@@ -1,4 +1,12 @@
1
1
  import React from 'react';
2
- import { type TrackOccupancyCanvasProps } from './types';
3
- declare const TrackOccupancyCanvas: ({ opId, useDraw, setCanvasesRoot, selectedTrainId, setSelectedTrainId, mousePosition, }: TrackOccupancyCanvasProps) => React.JSX.Element;
2
+ import type { OccupancyZone, Track } from './types';
3
+ declare const TrackOccupancyCanvas: ({ position, tracks, occupancyZones, selectedTrainId, onClose, topPadding, hideBorders, }: {
4
+ position: number;
5
+ tracks: Track[];
6
+ occupancyZones: OccupancyZone[];
7
+ selectedTrainId?: string;
8
+ onClose?: () => void;
9
+ topPadding?: number;
10
+ hideBorders?: boolean;
11
+ }) => React.JSX.Element;
4
12
  export default TrackOccupancyCanvas;
@@ -1,4 +1,6 @@
1
- import React from 'react';
2
- import { type TrackOccupancyManchetteProps } from './types';
3
- declare const TrackOccupancyManchette: ({ tracks }: TrackOccupancyManchetteProps) => React.JSX.Element;
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import type { Track } from './types';
3
+ declare const TrackOccupancyManchette: ({ tracks, children }: PropsWithChildren<{
4
+ tracks: Track[];
5
+ }>) => React.JSX.Element;
4
6
  export default TrackOccupancyManchette;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { OccupancyZone, Track } from './types';
3
+ declare const TrackOccupancyStandalone: ({ tracks, occupancyZones, selectedTrainId, onSelectedTrainIdChange, height, }: {
4
+ tracks: Track[];
5
+ occupancyZones: OccupancyZone[];
6
+ selectedTrainId?: string;
7
+ onSelectedTrainIdChange?: (selectedTrainId?: string) => void;
8
+ height?: number;
9
+ }) => React.JSX.Element;
10
+ export default TrackOccupancyStandalone;
@@ -13,7 +13,9 @@ export declare const COLORS: {
13
13
  GREY_50: string;
14
14
  GREY_60: string;
15
15
  GREY_80: string;
16
- HOUR_BACKGROUND: string;
16
+ MANCHETTE_BACKGROUND: string;
17
+ HOUR_BACKGROUND_1: string;
18
+ HOUR_BACKGROUND_2: string;
17
19
  RAIL_TICK: string;
18
20
  REMAINING_TRAINS_BACKGROUND: string;
19
21
  SELECTION_20: string;
@@ -1,15 +1,14 @@
1
- import type { OccupancyZone, Track } from '../../types';
2
- export declare const drawOccupancyZones: ({ ctx, width, height, tracks, occupancyZones, getTimePixel, selectedTrainId, setSelectedTrainId, mousePosition, }: {
3
- ctx: CanvasRenderingContext2D;
4
- width: number;
5
- height: number;
6
- tracks: Track[] | undefined;
7
- occupancyZones: OccupancyZone[] | undefined;
8
- getTimePixel: (time: number) => number;
9
- selectedTrainId: string;
10
- setSelectedTrainId: (id: string) => void;
11
- mousePosition: {
12
- x: number;
13
- y: number;
14
- };
1
+ import { type SpaceTimeChartContextType } from '../../../../spaceTimeChart';
2
+ import type { OccupancyZone } from '../../types';
3
+ export declare const drawRemainingTrainsBox: (ctx: CanvasRenderingContext2D, { getTimePixel, getSpacePixel }: SpaceTimeChartContextType, { time, position, yOffset, remainingTrainsNb, }: {
4
+ time: number;
5
+ position: number;
6
+ yOffset: number;
7
+ remainingTrainsNb: number;
8
+ }) => void;
9
+ export declare const drawOccupationZone: (ctx: CanvasRenderingContext2D, stcContext: SpaceTimeChartContextType, { zone, yOffset, position, isSelected, }: {
10
+ zone: OccupancyZone;
11
+ yOffset: number;
12
+ position: number;
13
+ isSelected?: boolean;
15
14
  }) => void;
@@ -1,10 +1,10 @@
1
1
  import type { OccupancyZone } from '../../types';
2
- export declare const drawOccupancyZonesTexts: ({ ctx, zone, arrivalTimePixel, departureTimePixel, yPosition, isThroughTrain, selectedTrainId, }: {
2
+ export declare const drawOccupancyZonesTexts: ({ ctx, zone, arrivalTimePixel, departureTimePixel, yPosition, isThroughTrain, isSelected, }: {
3
3
  ctx: CanvasRenderingContext2D;
4
4
  zone: OccupancyZone;
5
5
  arrivalTimePixel: number;
6
6
  departureTimePixel: number;
7
7
  yPosition: number;
8
8
  isThroughTrain: boolean;
9
- selectedTrainId: string;
9
+ isSelected?: boolean;
10
10
  }) => void;
@@ -1,16 +1,8 @@
1
+ import type { SpaceTimeChartContextType } from '../../../../spaceTimeChart';
1
2
  import { type Track } from '../../types';
2
- export declare function getTimeToPixel(timeOrigin: number, pixelOffset: number, timeScale: number): (time: number) => number;
3
- type DrawTracksProps = {
4
- ctx: CanvasRenderingContext2D;
5
- width: number;
6
- height: number;
7
- tracks: Track[] | undefined;
8
- timeOrigin: number;
9
- timePixelOffset: number;
10
- getTimePixel: (time: number) => number;
11
- timeRanges: number[];
12
- breakpoints: number[];
13
- timeScale: number;
14
- };
15
- export declare const drawTracks: ({ ctx, width, height, tracks, timeOrigin, timePixelOffset, getTimePixel, timeRanges, breakpoints, timeScale, }: DrawTracksProps) => void;
16
- export {};
3
+ export declare const drawTracks: (ctx: CanvasRenderingContext2D, stcContext: SpaceTimeChartContextType, { position, tracks, drawBorders, topPadding, }: {
4
+ position: number;
5
+ tracks: Track[];
6
+ drawBorders: boolean;
7
+ topPadding: number;
8
+ }) => void;
@@ -1,11 +1,11 @@
1
- import { type LayerType, type DrawingFunction } from '../../../spaceTimeChart/lib/types';
2
- declare const OccupancyZonesLayer: ({ useDraw, selectedTrainId, setSelectedTrainId, mousePosition, }: {
3
- useDraw: (layer: LayerType, fn: DrawingFunction) => void;
4
- selectedTrainId: string;
5
- setSelectedTrainId: (id: string) => void;
6
- mousePosition: {
7
- x: number;
8
- y: number;
9
- };
1
+ import { type PickingElement } from '../../../spaceTimeChart';
2
+ import type { OccupancyZone, OccupancyZonePickingElement, Track } from '../types';
3
+ export declare function isOccupancyPickingElement(element: PickingElement): element is OccupancyZonePickingElement;
4
+ declare const OccupancyZonesLayer: ({ tracks, occupancyZones, position, topPadding, selectedTrainId, }: {
5
+ tracks: Track[];
6
+ occupancyZones: OccupancyZone[];
7
+ position: number;
8
+ topPadding: number;
9
+ selectedTrainId?: string;
10
10
  }) => null;
11
11
  export default OccupancyZonesLayer;
@@ -1,5 +1,8 @@
1
- import { type LayerType, type DrawingFunction } from '../../../spaceTimeChart/lib/types';
2
- declare const TracksLayer: ({ useDraw }: {
3
- useDraw: (layer: LayerType, fn: DrawingFunction) => void;
1
+ import type { Track } from '../types';
2
+ declare const TracksLayer: ({ tracks, position, topPadding, drawBorders, }: {
3
+ tracks: Track[];
4
+ position: number;
5
+ topPadding: number;
6
+ drawBorders: boolean;
4
7
  }) => null;
5
8
  export default TracksLayer;
@@ -1,33 +1,25 @@
1
1
  import { type TICKS_PATTERN } from './consts';
2
- import { type DrawingFunction, type LayerType } from '../../spaceTimeChart/lib/types';
2
+ import { type PickingElement } from '../../spaceTimeChart';
3
3
  export type Track = {
4
4
  id: string;
5
- name: string;
6
- line: string;
5
+ name?: string;
6
+ line?: string;
7
7
  };
8
8
  export type OccupancyZone = {
9
- id: string;
9
+ trainId: string;
10
10
  trackId: string;
11
- arrivalTrainName: string;
12
- departureTrainName: string;
13
- color: string;
11
+ color?: string;
12
+ size?: number;
13
+ trainName: string;
14
14
  originStation?: string;
15
15
  destinationStation?: string;
16
- arrivalTime: Date;
17
- departureTime: Date;
18
- };
19
- export type TrackOccupancyCanvasProps = {
20
- opId: string;
21
- useDraw: (layer: LayerType, fn: DrawingFunction) => void;
22
- setCanvasesRoot: (root: HTMLDivElement | null) => void;
23
- selectedTrainId: string;
24
- setSelectedTrainId: (id: string) => void;
25
- mousePosition: {
26
- x: number;
27
- y: number;
28
- };
16
+ startTime: number;
17
+ endTime: number;
18
+ startDirection?: 'up' | 'down';
19
+ endDirection?: 'up' | 'down';
29
20
  };
30
- export type TrackOccupancyManchetteProps = {
31
- tracks: Track[];
21
+ export type OccupancyZonePickingElement = PickingElement & {
22
+ type: 'occupancyZone';
23
+ pathId: string;
32
24
  };
33
25
  export type TickPattern = keyof typeof TICKS_PATTERN;
@@ -1,3 +1,7 @@
1
1
  import './styles/main.css';
2
+ export * from './components/types';
3
+ export * from './components/consts';
4
+ export { isOccupancyPickingElement } from './components/layers/OccupancyZonesLayer';
2
5
  export { default as TrackOccupancyCanvas } from './components/TrackOccupancyCanvas';
3
6
  export { default as TrackOccupancyManchette } from './components/TrackOccupancyManchette';
7
+ export { default as TrackOccupancyStandalone } from './components/TrackOccupancyStandalone';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@osrd-project/ui-charts",
3
- "version": "0.0.74",
3
+ "version": "0.0.78",
4
4
  "license": "LGPL-3.0-or-later",
5
- "bugs": "https://github.com/osrd-project/osrd-ui/issues",
5
+ "bugs": "https://github.com/OpenRailAssociation/osrd/issues",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/osrd-project/osrd-ui.git",
9
- "directory": "ui-charts"
8
+ "url": "https://github.com/OpenRailAssociation/osrd.git",
9
+ "directory": "front/ui/ui-charts"
10
10
  },
11
11
  "publishConfig": {
12
12
  "access": "public"
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "classnames": ">=2.5",
40
- "react": ">=18.0",
41
- "react-dom": ">=18.0",
40
+ "react": "^18.0.0 || ^19.1.0",
41
+ "react-dom": "^18.0.0 || ^19.1.0",
42
42
  "tailwindcss": ">=3.4"
43
43
  },
44
44
  "dependencies": {
45
- "@osrd-project/ui-core": "^0.0.74",
46
- "@osrd-project/ui-icons": "^0.0.74",
45
+ "@osrd-project/ui-core": "^0.0.78",
46
+ "@osrd-project/ui-icons": "^0.0.78",
47
47
  "chroma-js": "^3.1.1",
48
48
  "d3-selection": "^3.0.0",
49
49
  "d3-zoom": "^3.0.0",
@@ -51,10 +51,10 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/chroma-js": "^3.1.0",
54
- "@types/d3-selection": "^3.0.0",
54
+ "@types/d3-selection": "^3.0.11",
55
55
  "@types/d3-zoom": "^3.0.0",
56
56
  "@types/file-saver": "^2.0.7",
57
57
  "file-saver": "^2.0.5"
58
58
  },
59
- "gitHead": "ef66588d9ffead71f09a97c137a899972623db14"
59
+ "gitHead": "24db3e20e98b272573d3157a207f2b646b45fd88"
60
60
  }