@osrd-project/ui-charts 0.0.68

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 (132) hide show
  1. package/README.md +63 -0
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.esm.js +2 -0
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/manchette/components/Manchette.d.ts +16 -0
  6. package/dist/manchette/components/ManchetteWithSpaceTimeChart.d.ts +22 -0
  7. package/dist/manchette/components/Waypoint.d.ts +10 -0
  8. package/dist/manchette/components/WaypointList.d.ts +9 -0
  9. package/dist/manchette/consts.d.ts +15 -0
  10. package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +66 -0
  11. package/dist/manchette/hooks/usePaths.d.ts +13 -0
  12. package/dist/manchette/index.d.ts +9 -0
  13. package/dist/manchette/types.d.ts +26 -0
  14. package/dist/manchette/utils/__tests__/helpers.spec.d.ts +1 -0
  15. package/dist/manchette/utils/helpers.d.ts +31 -0
  16. package/dist/manchette/utils/index.d.ts +12 -0
  17. package/dist/spaceTimeChart/__tests__/canvas.spec.d.ts +1 -0
  18. package/dist/spaceTimeChart/__tests__/geometry.spec.d.ts +1 -0
  19. package/dist/spaceTimeChart/__tests__/paths.spec.d.ts +1 -0
  20. package/dist/spaceTimeChart/__tests__/scales.spec.d.ts +1 -0
  21. package/dist/spaceTimeChart/__tests__/snapping.spec.d.ts +1 -0
  22. package/dist/spaceTimeChart/components/ConflictLayer.d.ts +16 -0
  23. package/dist/spaceTimeChart/components/ConflictTooltip.d.ts +13 -0
  24. package/dist/spaceTimeChart/components/OccupancyBlockLayer.d.ts +11 -0
  25. package/dist/spaceTimeChart/components/PathLayer.d.ts +36 -0
  26. package/dist/spaceTimeChart/components/PatternRect.d.ts +8 -0
  27. package/dist/spaceTimeChart/components/SpaceGraduations.d.ts +2 -0
  28. package/dist/spaceTimeChart/components/SpaceTimeChart.d.ts +3 -0
  29. package/dist/spaceTimeChart/components/TimeCaptions.d.ts +3 -0
  30. package/dist/spaceTimeChart/components/TimeGraduations.d.ts +2 -0
  31. package/dist/spaceTimeChart/components/WorkScheduleLayer.d.ts +14 -0
  32. package/dist/spaceTimeChart/components/ZoomRect.d.ts +2 -0
  33. package/dist/spaceTimeChart/config.d.ts +4 -0
  34. package/dist/spaceTimeChart/hooks/useCanvas.d.ts +19 -0
  35. package/dist/spaceTimeChart/hooks/useDevicePixelRatio.d.ts +1 -0
  36. package/dist/spaceTimeChart/hooks/useMouseInteractions.d.ts +8 -0
  37. package/dist/spaceTimeChart/hooks/useMouseTracking.d.ts +6 -0
  38. package/dist/spaceTimeChart/hooks/useSize.d.ts +8 -0
  39. package/dist/spaceTimeChart/index.d.ts +9 -0
  40. package/dist/spaceTimeChart/lib/consts.d.ts +20 -0
  41. package/dist/spaceTimeChart/lib/context.d.ts +16 -0
  42. package/dist/spaceTimeChart/lib/theme.d.ts +2 -0
  43. package/dist/spaceTimeChart/lib/types.d.ts +209 -0
  44. package/dist/spaceTimeChart/stories/additional-data.stories.d.ts +20 -0
  45. package/dist/spaceTimeChart/stories/base-rendering.stories.d.ts +28 -0
  46. package/dist/spaceTimeChart/stories/custom-styles.stories.d.ts +24 -0
  47. package/dist/spaceTimeChart/stories/horizontal-zoom.stories.d.ts +31 -0
  48. package/dist/spaceTimeChart/stories/layers.stories.d.ts +9 -0
  49. package/dist/spaceTimeChart/stories/lib/components.d.ts +15 -0
  50. package/dist/spaceTimeChart/stories/lib/paths.d.ts +16 -0
  51. package/dist/spaceTimeChart/stories/lib/utils.d.ts +22 -0
  52. package/dist/spaceTimeChart/stories/measuring.stories.d.ts +20 -0
  53. package/dist/spaceTimeChart/stories/options.stories.d.ts +27 -0
  54. package/dist/spaceTimeChart/stories/paths-interactions.stories.d.ts +24 -0
  55. package/dist/spaceTimeChart/stories/performances.stories.d.ts +25 -0
  56. package/dist/spaceTimeChart/stories/rectangle-zoom.stories.d.ts +40 -0
  57. package/dist/spaceTimeChart/stories/scroll-navigation.stories.d.ts +19 -0
  58. package/dist/spaceTimeChart/stories/split.stories.d.ts +21 -0
  59. package/dist/spaceTimeChart/stories/stage-interactions.stories.d.ts +25 -0
  60. package/dist/spaceTimeChart/stories/work-schedules.stories.d.ts +31 -0
  61. package/dist/spaceTimeChart/types.d.ts +6 -0
  62. package/dist/spaceTimeChart/utils/__tests__/canvas.spec.d.ts +1 -0
  63. package/dist/spaceTimeChart/utils/canvas.d.ts +55 -0
  64. package/dist/spaceTimeChart/utils/colors.d.ts +13 -0
  65. package/dist/spaceTimeChart/utils/events.d.ts +12 -0
  66. package/dist/spaceTimeChart/utils/geometry.d.ts +13 -0
  67. package/dist/spaceTimeChart/utils/paths.d.ts +16 -0
  68. package/dist/spaceTimeChart/utils/png.d.ts +5 -0
  69. package/dist/spaceTimeChart/utils/scales.d.ts +45 -0
  70. package/dist/spaceTimeChart/utils/snapping.d.ts +10 -0
  71. package/dist/spaceTimeChart/utils/vectors.d.ts +2 -0
  72. package/dist/speedSpaceChart/__tests__/utils.spec.d.ts +1 -0
  73. package/dist/speedSpaceChart/components/SpeedSpaceChart.d.ts +31 -0
  74. package/dist/speedSpaceChart/components/common/DetailsBox.d.ts +19 -0
  75. package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +9 -0
  76. package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +13 -0
  77. package/dist/speedSpaceChart/components/common/Tooltip.d.ts +9 -0
  78. package/dist/speedSpaceChart/components/const.d.ts +53 -0
  79. package/dist/speedSpaceChart/components/helpers/drawElements/axisY.d.ts +2 -0
  80. package/dist/speedSpaceChart/components/helpers/drawElements/curve.d.ts +2 -0
  81. package/dist/speedSpaceChart/components/helpers/drawElements/declivity.d.ts +2 -0
  82. package/dist/speedSpaceChart/components/helpers/drawElements/electricalProfile.d.ts +2 -0
  83. package/dist/speedSpaceChart/components/helpers/drawElements/powerRestrictions.d.ts +2 -0
  84. package/dist/speedSpaceChart/components/helpers/drawElements/reticle.d.ts +13 -0
  85. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimitTags.d.ts +3 -0
  86. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimits.d.ts +2 -0
  87. package/dist/speedSpaceChart/components/helpers/drawElements/steps.d.ts +2 -0
  88. package/dist/speedSpaceChart/components/helpers/drawElements/tickX.d.ts +2 -0
  89. package/dist/speedSpaceChart/components/helpers/drawElements/tickYRight.d.ts +2 -0
  90. package/dist/speedSpaceChart/components/helpers/frontFrame.d.ts +2 -0
  91. package/dist/speedSpaceChart/components/helpers/layersManager.d.ts +4 -0
  92. package/dist/speedSpaceChart/components/hooks.d.ts +11 -0
  93. package/dist/speedSpaceChart/components/layers/CurveLayer.d.ts +9 -0
  94. package/dist/speedSpaceChart/components/layers/DeclivityLayer.d.ts +9 -0
  95. package/dist/speedSpaceChart/components/layers/ElectricalProfileLayer.d.ts +9 -0
  96. package/dist/speedSpaceChart/components/layers/FrontInteractivityLayer.d.ts +10 -0
  97. package/dist/speedSpaceChart/components/layers/PowerRestrictionsLayer.d.ts +9 -0
  98. package/dist/speedSpaceChart/components/layers/ReticleLayer.d.ts +10 -0
  99. package/dist/speedSpaceChart/components/layers/SpeedLimitTagsLayer.d.ts +9 -0
  100. package/dist/speedSpaceChart/components/layers/SpeedLimitsLayer.d.ts +9 -0
  101. package/dist/speedSpaceChart/components/layers/StepsLayer.d.ts +9 -0
  102. package/dist/speedSpaceChart/components/layers/TickLayerX.d.ts +9 -0
  103. package/dist/speedSpaceChart/components/layers/TickLayerY.d.ts +9 -0
  104. package/dist/speedSpaceChart/components/layers/TickLayerYRight.d.ts +9 -0
  105. package/dist/speedSpaceChart/components/layers/index.d.ts +12 -0
  106. package/dist/speedSpaceChart/components/utils.d.ts +115 -0
  107. package/dist/speedSpaceChart/index.d.ts +3 -0
  108. package/dist/speedSpaceChart/stories/SpeedSpaceChart.stories.d.ts +8 -0
  109. package/dist/speedSpaceChart/stories/assets/const.d.ts +70 -0
  110. package/dist/speedSpaceChart/stories/assets/path_properties_PMP_LM.d.ts +2 -0
  111. package/dist/speedSpaceChart/stories/assets/power_restrictions_PMP_LM.d.ts +7 -0
  112. package/dist/speedSpaceChart/stories/assets/simulation_PMP_LM.d.ts +2 -0
  113. package/dist/speedSpaceChart/stories/assets/speed_limit_tags_PMP_LM.d.ts +9 -0
  114. package/dist/speedSpaceChart/stories/utils.d.ts +5 -0
  115. package/dist/speedSpaceChart/types/chartTypes.d.ts +114 -0
  116. package/dist/speedSpaceChart/types/simulationTypes.d.ts +47 -0
  117. package/dist/theme.css +6490 -0
  118. package/dist/theme.css.map +1 -0
  119. package/dist/trackOccupancyDiagram/__tests__/utils.spec.d.ts +1 -0
  120. package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +4 -0
  121. package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +4 -0
  122. package/dist/trackOccupancyDiagram/components/consts.d.ts +30 -0
  123. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +15 -0
  124. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +10 -0
  125. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTrack.d.ts +11 -0
  126. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +16 -0
  127. package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +11 -0
  128. package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +5 -0
  129. package/dist/trackOccupancyDiagram/components/types.d.ts +33 -0
  130. package/dist/trackOccupancyDiagram/components/utils.d.ts +24 -0
  131. package/dist/trackOccupancyDiagram/index.d.ts +3 -0
  132. package/package.json +60 -0
@@ -0,0 +1,4 @@
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;
4
+ export default TrackOccupancyCanvas;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { type TrackOccupancyManchetteProps } from './types';
3
+ declare const TrackOccupancyManchette: ({ tracks }: TrackOccupancyManchetteProps) => React.JSX.Element;
4
+ export default TrackOccupancyManchette;
@@ -0,0 +1,30 @@
1
+ export declare const TRACK_HEIGHT_CONTAINER = 100;
2
+ export declare const CANVAS_PADDING = 10;
3
+ export declare const OCCUPANCY_ZONE_Y_START: number;
4
+ export declare const OCCUPANCY_ZONE_HEIGHT = 3;
5
+ export declare const MINUTES_TEXT_OFFSET = 8.5;
6
+ export declare const STATION_TEXT_OFFSET = 5;
7
+ export declare const FONTS: {
8
+ SANS: string;
9
+ MONO: string;
10
+ };
11
+ export declare const COLORS: {
12
+ GREY_20: string;
13
+ GREY_50: string;
14
+ GREY_60: string;
15
+ GREY_80: string;
16
+ HOUR_BACKGROUND: string;
17
+ RAIL_TICK: string;
18
+ REMAINING_TRAINS_BACKGROUND: string;
19
+ SELECTION_20: string;
20
+ WHITE_50: string;
21
+ WHITE_100: string;
22
+ };
23
+ export declare const TICKS_PATTERN: {
24
+ MINUTE: number[];
25
+ FIVE_MINUTES: number[];
26
+ QUARTER_HOUR: number[];
27
+ HALF_HOUR: number[];
28
+ HOUR: number[];
29
+ };
30
+ export declare const TICKS_PRIORITIES: number[][];
@@ -0,0 +1,15 @@
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
+ };
15
+ }) => void;
@@ -0,0 +1,10 @@
1
+ import type { OccupancyZone } from '../../types';
2
+ export declare const drawOccupancyZonesTexts: ({ ctx, zone, arrivalTimePixel, departureTimePixel, yPosition, isThroughTrain, selectedTrainId, }: {
3
+ ctx: CanvasRenderingContext2D;
4
+ zone: OccupancyZone;
5
+ arrivalTimePixel: number;
6
+ departureTimePixel: number;
7
+ yPosition: number;
8
+ isThroughTrain: boolean;
9
+ selectedTrainId: string;
10
+ }) => void;
@@ -0,0 +1,11 @@
1
+ type DrawTrackProps = {
2
+ ctx: CanvasRenderingContext2D;
3
+ width: number;
4
+ getTimePixel: (time: number) => number;
5
+ labelMarks: Record<number, {
6
+ level: number;
7
+ rangeIndex: number;
8
+ }>;
9
+ };
10
+ export declare const drawTrack: ({ ctx, width, getTimePixel, labelMarks }: DrawTrackProps) => void;
11
+ export {};
@@ -0,0 +1,16 @@
1
+ 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 {};
@@ -0,0 +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
+ };
10
+ }) => null;
11
+ export default OccupancyZonesLayer;
@@ -0,0 +1,5 @@
1
+ import { type LayerType, type DrawingFunction } from '../../../spaceTimeChart/lib/types';
2
+ declare const TracksLayer: ({ useDraw }: {
3
+ useDraw: (layer: LayerType, fn: DrawingFunction) => void;
4
+ }) => null;
5
+ export default TracksLayer;
@@ -0,0 +1,33 @@
1
+ import { type TICKS_PATTERN } from './consts';
2
+ import { type DrawingFunction, type LayerType } from '../../spaceTimeChart/lib/types';
3
+ export type Track = {
4
+ id: string;
5
+ name: string;
6
+ line: string;
7
+ };
8
+ export type OccupancyZone = {
9
+ id: string;
10
+ trackId: string;
11
+ arrivalTrainName: string;
12
+ departureTrainName: string;
13
+ color: string;
14
+ originStation?: string;
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
+ };
29
+ };
30
+ export type TrackOccupancyManchetteProps = {
31
+ tracks: Track[];
32
+ };
33
+ export type TickPattern = keyof typeof TICKS_PATTERN;
@@ -0,0 +1,24 @@
1
+ import { type TickPattern } from './types';
2
+ type DrawTextType = {
3
+ ctx: CanvasRenderingContext2D;
4
+ text: string;
5
+ x: number;
6
+ y: number;
7
+ color: string;
8
+ xPosition?: 'left' | 'center' | 'right';
9
+ yPosition?: 'top' | 'middle' | 'bottom';
10
+ font?: string;
11
+ rotateAngle?: number;
12
+ stroke?: {
13
+ color: string;
14
+ width: number;
15
+ };
16
+ };
17
+ export declare const drawText: ({ ctx, text, x, y, color, xPosition, yPosition, font, rotateAngle, stroke, }: DrawTextType) => void;
18
+ export declare const getTickPattern: (minutes: string) => TickPattern;
19
+ export declare const getLabelMarks: (timeRanges: number[], minT: number, maxT: number, labelLevels: number[]) => Record<number, {
20
+ level: number;
21
+ rangeIndex: number;
22
+ }>;
23
+ export declare const getLabelLevels: (breakpoints: number[], pixelsPerMinute: number, ticksPriorities: number[][]) => number[];
24
+ export {};
@@ -0,0 +1,3 @@
1
+ import './styles/main.css';
2
+ export { default as TrackOccupancyCanvas } from './components/TrackOccupancyCanvas';
3
+ export { default as TrackOccupancyManchette } from './components/TrackOccupancyManchette';
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@osrd-project/ui-charts",
3
+ "version": "0.0.68",
4
+ "license": "LGPL-3.0-or-later",
5
+ "bugs": "https://github.com/osrd-project/osrd-ui/issues",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/osrd-project/osrd-ui.git",
9
+ "directory": "ui-charts"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "module": "dist/index.esm.js",
16
+ "types": "dist/index.d.ts",
17
+ "main": "dist/index.esm.js",
18
+ "style": "dist/theme.css",
19
+ "files": [
20
+ "/dist"
21
+ ],
22
+ "exports": {
23
+ "./dist/theme.css": "./dist/theme.css",
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.esm.js"
27
+ }
28
+ },
29
+ "scripts": {
30
+ "clean": "rimraf dist",
31
+ "build": "rollup -c --failAfterWarnings",
32
+ "watch": "rollup -c -w",
33
+ "test": "vitest run",
34
+ "prepublishOnly": "npm run clean && npm run build",
35
+ "lint": "eslint src --max-warnings 0",
36
+ "lint:fix": "eslint src --fix"
37
+ },
38
+ "peerDependencies": {
39
+ "classnames": ">=2.5",
40
+ "react": ">=18.0",
41
+ "react-dom": ">=18.0",
42
+ "tailwindcss": ">=3.4"
43
+ },
44
+ "dependencies": {
45
+ "@osrd-project/ui-core": "^0.0.68",
46
+ "@osrd-project/ui-icons": "^0.0.68",
47
+ "chroma-js": "^3.1.1",
48
+ "d3-selection": "^3.0.0",
49
+ "d3-zoom": "^3.0.0",
50
+ "lodash": "^4.17.21"
51
+ },
52
+ "devDependencies": {
53
+ "@types/chroma-js": "^3.1.0",
54
+ "@types/d3-selection": "^3.0.0",
55
+ "@types/d3-zoom": "^3.0.0",
56
+ "@types/file-saver": "^2.0.7",
57
+ "file-saver": "^2.0.5"
58
+ },
59
+ "gitHead": "103772f804d13da248ad6dcfd73d81f1cfc02aa9"
60
+ }