@osrd-project/ui-charts 0.0.83 → 0.0.85

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 (128) hide show
  1. package/dist/index.d.ts +1055 -7
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +7148 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/theme.css +1065 -3725
  6. package/package.json +17 -16
  7. package/dist/chronogram/components/Chronogram.d.ts +0 -3
  8. package/dist/chronogram/components/ChronogramCanvas.d.ts +0 -3
  9. package/dist/chronogram/components/ChronogramManchette.d.ts +0 -9
  10. package/dist/chronogram/components/OccupancyBlocksLayer.d.ts +0 -1
  11. package/dist/chronogram/hooks/useChronogram.d.ts +0 -35
  12. package/dist/chronogram/index.d.ts +0 -9
  13. package/dist/chronogram/lib/const.d.ts +0 -5
  14. package/dist/chronogram/lib/context.d.ts +0 -6
  15. package/dist/chronogram/lib/types.d.ts +0 -30
  16. package/dist/chronogram/utils/format.d.ts +0 -1
  17. package/dist/common/consts.d.ts +0 -5
  18. package/dist/common/context.d.ts +0 -2
  19. package/dist/common/helpers/colors.d.ts +0 -21
  20. package/dist/common/helpers/png.d.ts +0 -5
  21. package/dist/common/helpers/time.d.ts +0 -31
  22. package/dist/common/helpers/utils.d.ts +0 -8
  23. package/dist/common/hooks/useCanvas.d.ts +0 -16
  24. package/dist/common/hooks/useDevicePixelRatio.d.ts +0 -1
  25. package/dist/common/hooks/useMouseInteractions.d.ts +0 -41
  26. package/dist/common/hooks/useMouseTracking.d.ts +0 -6
  27. package/dist/common/hooks/useSize.d.ts +0 -7
  28. package/dist/common/index.d.ts +0 -5
  29. package/dist/common/layers/TimeCaptions.d.ts +0 -1
  30. package/dist/common/layers/TimeGraduations.d.ts +0 -2
  31. package/dist/common/types.d.ts +0 -104
  32. package/dist/index.esm.js +0 -6391
  33. package/dist/index.esm.js.map +0 -1
  34. package/dist/manchette/assets/sampleData.d.ts +0 -2
  35. package/dist/manchette/components/Manchette.d.ts +0 -23
  36. package/dist/manchette/components/ManchetteWithSpaceTimeChart.d.ts +0 -23
  37. package/dist/manchette/components/Waypoint.d.ts +0 -14
  38. package/dist/manchette/consts.d.ts +0 -15
  39. package/dist/manchette/hooks/useManchetteWithSpaceTimeChart.d.ts +0 -49
  40. package/dist/manchette/hooks/useSyncManchette.d.ts +0 -94
  41. package/dist/manchette/index.d.ts +0 -11
  42. package/dist/manchette/types.d.ts +0 -34
  43. package/dist/manchette/utils/__tests__/helpers.spec.d.ts +0 -1
  44. package/dist/manchette/utils/helpers.d.ts +0 -44
  45. package/dist/manchette/utils/index.d.ts +0 -13
  46. package/dist/spaceTimeChart/__tests__/canvas.spec.d.ts +0 -1
  47. package/dist/spaceTimeChart/__tests__/geometry.spec.d.ts +0 -1
  48. package/dist/spaceTimeChart/__tests__/paths.spec.d.ts +0 -1
  49. package/dist/spaceTimeChart/__tests__/scales.spec.d.ts +0 -1
  50. package/dist/spaceTimeChart/__tests__/snapping.spec.d.ts +0 -1
  51. package/dist/spaceTimeChart/components/ConflictLayer.d.ts +0 -16
  52. package/dist/spaceTimeChart/components/ConflictTooltip.d.ts +0 -13
  53. package/dist/spaceTimeChart/components/OccupancyBlockLayer.d.ts +0 -12
  54. package/dist/spaceTimeChart/components/PathLayer.d.ts +0 -37
  55. package/dist/spaceTimeChart/components/PatternRect.d.ts +0 -8
  56. package/dist/spaceTimeChart/components/Quadrilateral.d.ts +0 -26
  57. package/dist/spaceTimeChart/components/SpaceGraduations.d.ts +0 -2
  58. package/dist/spaceTimeChart/components/SpaceTimeChart.d.ts +0 -3
  59. package/dist/spaceTimeChart/components/Tooltip.d.ts +0 -7
  60. package/dist/spaceTimeChart/components/WorkScheduleLayer.d.ts +0 -19
  61. package/dist/spaceTimeChart/components/ZoomRect.d.ts +0 -2
  62. package/dist/spaceTimeChart/config.d.ts +0 -4
  63. package/dist/spaceTimeChart/index.d.ts +0 -17
  64. package/dist/spaceTimeChart/lib/consts.d.ts +0 -17
  65. package/dist/spaceTimeChart/lib/context.d.ts +0 -13
  66. package/dist/spaceTimeChart/lib/theme.d.ts +0 -2
  67. package/dist/spaceTimeChart/lib/types.d.ts +0 -129
  68. package/dist/spaceTimeChart/utils/__tests__/canvas.spec.d.ts +0 -1
  69. package/dist/spaceTimeChart/utils/__tests__/scales.spec.d.ts +0 -1
  70. package/dist/spaceTimeChart/utils/canvas.d.ts +0 -43
  71. package/dist/spaceTimeChart/utils/events.d.ts +0 -12
  72. package/dist/spaceTimeChart/utils/geometry.d.ts +0 -13
  73. package/dist/spaceTimeChart/utils/paths.d.ts +0 -16
  74. package/dist/spaceTimeChart/utils/scales.d.ts +0 -73
  75. package/dist/spaceTimeChart/utils/snapping.d.ts +0 -10
  76. package/dist/spaceTimeChart/utils/vectors.d.ts +0 -2
  77. package/dist/speedSpaceChart/__tests__/utils.spec.d.ts +0 -1
  78. package/dist/speedSpaceChart/components/SpeedSpaceChart.d.ts +0 -50
  79. package/dist/speedSpaceChart/components/common/DetailsBox.d.ts +0 -22
  80. package/dist/speedSpaceChart/components/common/InteractionButtons.d.ts +0 -10
  81. package/dist/speedSpaceChart/components/common/SettingsPanel.d.ts +0 -15
  82. package/dist/speedSpaceChart/components/common/Tooltip.d.ts +0 -9
  83. package/dist/speedSpaceChart/components/const.d.ts +0 -74
  84. package/dist/speedSpaceChart/components/helpers/drawElements/axisY.d.ts +0 -2
  85. package/dist/speedSpaceChart/components/helpers/drawElements/curve.d.ts +0 -2
  86. package/dist/speedSpaceChart/components/helpers/drawElements/declivity.d.ts +0 -2
  87. package/dist/speedSpaceChart/components/helpers/drawElements/electricalProfile.d.ts +0 -2
  88. package/dist/speedSpaceChart/components/helpers/drawElements/powerRestrictions.d.ts +0 -2
  89. package/dist/speedSpaceChart/components/helpers/drawElements/reticle.d.ts +0 -14
  90. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimitTags.d.ts +0 -3
  91. package/dist/speedSpaceChart/components/helpers/drawElements/speedLimits.d.ts +0 -2
  92. package/dist/speedSpaceChart/components/helpers/drawElements/steps.d.ts +0 -2
  93. package/dist/speedSpaceChart/components/helpers/drawElements/tickX.d.ts +0 -2
  94. package/dist/speedSpaceChart/components/helpers/drawElements/tickYRight.d.ts +0 -2
  95. package/dist/speedSpaceChart/components/helpers/frontFrame.d.ts +0 -2
  96. package/dist/speedSpaceChart/components/helpers/layersManager.d.ts +0 -5
  97. package/dist/speedSpaceChart/components/hooks.d.ts +0 -11
  98. package/dist/speedSpaceChart/components/layers/CurveLayer.d.ts +0 -9
  99. package/dist/speedSpaceChart/components/layers/DeclivityLayer.d.ts +0 -9
  100. package/dist/speedSpaceChart/components/layers/ElectricalProfileLayer.d.ts +0 -9
  101. package/dist/speedSpaceChart/components/layers/FrontInteractivityLayer.d.ts +0 -10
  102. package/dist/speedSpaceChart/components/layers/PowerRestrictionsLayer.d.ts +0 -9
  103. package/dist/speedSpaceChart/components/layers/ReticleLayer.d.ts +0 -11
  104. package/dist/speedSpaceChart/components/layers/SpeedLimitTagsLayer.d.ts +0 -9
  105. package/dist/speedSpaceChart/components/layers/SpeedLimitsLayer.d.ts +0 -9
  106. package/dist/speedSpaceChart/components/layers/StepsLayer.d.ts +0 -9
  107. package/dist/speedSpaceChart/components/layers/TickLayerX.d.ts +0 -9
  108. package/dist/speedSpaceChart/components/layers/TickLayerY.d.ts +0 -9
  109. package/dist/speedSpaceChart/components/layers/TickLayerYRight.d.ts +0 -9
  110. package/dist/speedSpaceChart/components/layers/index.d.ts +0 -12
  111. package/dist/speedSpaceChart/components/utils.d.ts +0 -112
  112. package/dist/speedSpaceChart/index.d.ts +0 -5
  113. package/dist/speedSpaceChart/types.d.ts +0 -155
  114. package/dist/theme.css.map +0 -1
  115. package/dist/trackOccupancyDiagram/__tests__/utils.spec.d.ts +0 -1
  116. package/dist/trackOccupancyDiagram/components/TrackOccupancyCanvas.d.ts +0 -12
  117. package/dist/trackOccupancyDiagram/components/TrackOccupancyManchette.d.ts +0 -6
  118. package/dist/trackOccupancyDiagram/components/TrackOccupancyStandalone.d.ts +0 -10
  119. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZones.d.ts +0 -20
  120. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawOccupancyZonesTexts.d.ts +0 -10
  121. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTrack.d.ts +0 -11
  122. package/dist/trackOccupancyDiagram/components/helpers/drawElements/drawTracks.d.ts +0 -8
  123. package/dist/trackOccupancyDiagram/components/layers/OccupancyZonesLayer.d.ts +0 -11
  124. package/dist/trackOccupancyDiagram/components/layers/TracksLayer.d.ts +0 -8
  125. package/dist/trackOccupancyDiagram/components/utils.d.ts +0 -24
  126. package/dist/trackOccupancyDiagram/index.d.ts +0 -7
  127. package/dist/trackOccupancyDiagram/lib/consts.d.ts +0 -32
  128. package/dist/trackOccupancyDiagram/lib/types.d.ts +0 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osrd-project/ui-charts",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "bugs": "https://github.com/OpenRailAssociation/osrd/issues",
6
6
  "repository": {
@@ -12,9 +12,9 @@
12
12
  "access": "public"
13
13
  },
14
14
  "type": "module",
15
- "module": "dist/index.esm.js",
15
+ "module": "dist/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "main": "dist/index.esm.js",
17
+ "main": "dist/index.js",
18
18
  "style": "dist/theme.css",
19
19
  "files": [
20
20
  "/dist"
@@ -23,17 +23,17 @@
23
23
  "./dist/theme.css": "./dist/theme.css",
24
24
  ".": {
25
25
  "types": "./dist/index.d.ts",
26
- "default": "./dist/index.esm.js"
26
+ "default": "./dist/index.js"
27
27
  }
28
28
  },
29
29
  "scripts": {
30
30
  "clean": "rimraf dist",
31
- "build": "rollup -c --failAfterWarnings",
32
- "watch": "rollup -c -w",
31
+ "build": "tsdown --fail-on-warn",
32
+ "watch": "tsdown -w",
33
33
  "test": "vitest run",
34
34
  "prepublishOnly": "npm run clean && npm run build",
35
- "lint": "eslint src --max-warnings 0 && oxfmt . --check",
36
- "lint:fix": "eslint src --fix && oxfmt . --write"
35
+ "lint": "stylelint '**/*.css' && oxlint . --max-warnings 0 && oxfmt . --check",
36
+ "lint:fix": "stylelint '**/*.css' --fix && oxlint . --fix && oxfmt . --write"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "classnames": ">=2.5",
@@ -42,19 +42,20 @@
42
42
  "tailwindcss": ">=4.1"
43
43
  },
44
44
  "dependencies": {
45
- "@osrd-project/ui-core": "0.0.83",
46
- "@osrd-project/ui-icons": "0.0.83",
45
+ "@osrd-project/ui-core": "0.0.85",
46
+ "@osrd-project/ui-icons": "0.0.85",
47
47
  "chroma-js": "^3.2.0",
48
- "d3-selection": "^3.0.0",
49
- "d3-zoom": "^3.0.0",
48
+ "d3-selection": "^3.0.1",
49
+ "d3-zoom": "^3.0.1",
50
50
  "lodash": "^4.18.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/chroma-js": "^3.1.2",
54
- "@types/d3-selection": "^3.0.11",
55
- "@types/d3-zoom": "^3.0.0",
53
+ "@testing-library/react": "^16.3.3",
54
+ "@types/chroma-js": "^3.1.3",
55
+ "@types/d3-selection": "^3.0.12",
56
+ "@types/d3-zoom": "^3.0.9",
56
57
  "@types/file-saver": "^2.0.7",
57
58
  "file-saver": "^2.0.5",
58
- "vitest": "^4.1.5"
59
+ "vitest": "^5.1.0"
59
60
  }
60
61
  }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { ChronogramProps } from '../lib/types';
3
- export declare const Chronogram: ({ levelCrossingData, timeOrigin, height, }: ChronogramProps) => React.JSX.Element;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import type { ChronogramCanvasProps } from '../lib/types';
3
- export declare const ChronogramCanvas: (props: ChronogramCanvasProps) => React.JSX.Element;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- export type ChronogramManchetteProps = {
3
- levelCrossingsNames: string[];
4
- height: number;
5
- width?: number;
6
- onDelete: (name: string) => void;
7
- };
8
- declare const ChronogramManchette: ({ levelCrossingsNames, height, width, onDelete, }: ChronogramManchetteProps) => React.JSX.Element;
9
- export default ChronogramManchette;
@@ -1 +0,0 @@
1
- export declare const OccupancyBlocksLayer: () => null;
@@ -1,35 +0,0 @@
1
- import type { Point } from '../../common/types';
2
- export type UseChronogramProps = {
3
- itemCount: number;
4
- chronogramManchetteRef: React.RefObject<HTMLDivElement | null>;
5
- chronogramChartRef: React.RefObject<HTMLDivElement | null>;
6
- chronogramHeight: number;
7
- };
8
- export type ChronogramState = {
9
- height: number;
10
- xOffset: number;
11
- yOffset: number;
12
- panning: {
13
- initialOffset: {
14
- x: number;
15
- y: number;
16
- };
17
- } | null;
18
- xZoom: number;
19
- };
20
- declare const useChronogram: ({ itemCount, chronogramManchetteRef, chronogramChartRef, chronogramHeight, }: UseChronogramProps) => {
21
- handleVerticalScroll: () => void;
22
- handleXZoom: (newXZoom: number, xPosition?: number) => void;
23
- handleXZoomOnWheelEvent: (wheelEvent: WheelEvent, newXZoom: number, xPosition: number) => void;
24
- height: number;
25
- onPan: (payload: {
26
- initialPosition: Point;
27
- position: Point;
28
- isPanning: boolean;
29
- }) => void;
30
- setHeight: (newHeight: number) => void;
31
- xOffset: number;
32
- xZoom: number;
33
- yOffset: number;
34
- };
35
- export default useChronogram;
@@ -1,9 +0,0 @@
1
- import '../spaceTimeChart/styles/main.css';
2
- import './styles/main.css';
3
- export * from './components/Chronogram';
4
- export * from './components/ChronogramCanvas';
5
- export * from './components/ChronogramManchette';
6
- export * from './components/OccupancyBlocksLayer';
7
- export * from './hooks/useChronogram';
8
- export type { ChronogramProps, ChronogramContextType, LevelCrossingData, LevelCrossingOccupancies, } from './lib/types';
9
- export { ChronogramContext } from './lib/context';
@@ -1,5 +0,0 @@
1
- export declare const CHRONOGRAM_HEADER_HEIGHT = 33;
2
- export declare const CHRONOGRAM_BOTTOM_PADDING = 40;
3
- export declare const INITIAL_CHRONOGRAM_HEIGHT = 600;
4
- export declare const LEVEL_CROSSING_ITEM_HEIGHT = 48;
5
- export declare const CHRONOGRAM_SLIDER_WIDTH = 122;
@@ -1,6 +0,0 @@
1
- import { type ChronogramContextType } from './types';
2
- /**
3
- * This context exports everything necessary to draw the chart.
4
- * It is updated anytime the scales are updated.
5
- */
6
- export declare const ChronogramContext: import("react").Context<ChronogramContextType>;
@@ -1,30 +0,0 @@
1
- import type { ChartEventHandlers, TimeChartContextType } from '../../common/types';
2
- import type { SpaceTimeChartTheme } from '../../spaceTimeChart';
3
- export type OccupancyBlock = {
4
- startTime: number;
5
- endTime: number;
6
- trainNames: string[];
7
- };
8
- export type LevelCrossingOccupancies = OccupancyBlock[][];
9
- export type LevelCrossingData = {
10
- name: string;
11
- occupancies: LevelCrossingOccupancies;
12
- };
13
- export type ChronogramContextType = TimeChartContextType & {
14
- levelCrossingsOccupancies: LevelCrossingOccupancies[];
15
- };
16
- export type ChronogramCanvasProps = {
17
- levelCrossingsOccupancies: LevelCrossingOccupancies[];
18
- /** The time origin (i.e. the time value for the most left point) */
19
- timeOrigin: number;
20
- /** The timescale (in ms/px) */
21
- timeScale: number;
22
- xOffset?: number;
23
- yOffset?: number;
24
- theme?: Partial<SpaceTimeChartTheme>;
25
- } & ChartEventHandlers<ChronogramContextType>;
26
- export type ChronogramProps = {
27
- levelCrossingData: LevelCrossingData[];
28
- timeOrigin: number;
29
- height?: number;
30
- };
@@ -1 +0,0 @@
1
- export declare function formatDuration(start: number, end: number): string;
@@ -1,5 +0,0 @@
1
- export declare const PICKING_LAYERS: readonly ["paths", "overlay"];
2
- export declare const LAYERS: readonly ["background", "graduations", "paths", "overlay", "captions"];
3
- export declare const SECOND = 1000;
4
- export declare const MINUTE: number;
5
- export declare const HOUR: number;
@@ -1,2 +0,0 @@
1
- import type { CanvasContextType, TimeChartContextType } from './types';
2
- export declare const TimeChartCanvasContext: import("react").Context<CanvasContextType<TimeChartContextType>>;
@@ -1,21 +0,0 @@
1
- import type { RGBAColor } from '../types';
2
- export declare const BLACK_100 = "rgb(0, 0, 0)";
3
- export declare const BLACK_ALPHA_25 = "rgba(0, 0, 0, 0.25)";
4
- export declare const GREY_90 = "rgb(31, 27, 23)";
5
- export declare const GREY_50 = "rgb(121, 118, 113)";
6
- export declare const GREY_30 = "rgb(182, 178, 175)";
7
- export declare const RED_100 = "rgb(221, 34, 34)";
8
- export declare const WHITE_100 = "rgb(255, 255, 255)";
9
- export declare const WHITE_ALPHA_75 = "rgba(255, 255, 255, 0.75)";
10
- /**
11
- * This function returns a unique hex color corresponding to the given index. The colors are
12
- * generated as #000001, #000002 ... #0000ff, #000100 etc.
13
- * These colors aim at representing the given indices on the picking layer.
14
- */
15
- export declare function indexToColor(index: number): string;
16
- /**
17
- * This function returns the index corresponding to the given color.
18
- */
19
- export declare function colorToIndex(color: string): number;
20
- export declare function rgbToHex(r: number, g: number, b: number): string;
21
- export declare function hexToRgb(color: string): RGBAColor;
@@ -1,5 +0,0 @@
1
- /**
2
- * This function captures a list of canvas layers into a PNG image, and returns a blob with the
3
- * PNG data if possible.
4
- */
5
- export default function getPNGBlob(canvases: Record<string, HTMLCanvasElement>, layers: readonly string[], backgroundColor?: string): Promise<Blob>;
@@ -1,31 +0,0 @@
1
- import type { TimeToPixel, PixelToTime } from '../types';
2
- /**
3
- * @param minT number timestamp
4
- * @param maxT number timestamp
5
- * @param timeRanges time frames (24h, 12h, 6h, …)
6
- * @param gridlinesLevels width of the lines for each time frame
7
- * @param formatter function to format de values inside the output object
8
- * Keys are times in ms
9
- * Values are the highest level on each time
10
- */
11
- export declare function computeVisibleTimeMarkers<T extends object = {
12
- level: number;
13
- }>(minT: number, maxT: number, timeRanges: number[], gridlinesLevels: number[], formatter?: (level: number, i: number) => T): (T & {
14
- time: number;
15
- })[];
16
- /**
17
- * To get crisp horizontal or vertical lines on a canvas, we must draw them as thin as possible, in
18
- * terms of actual pixels on screen.
19
- * The best way for this is:
20
- * - To center lines 1, 3, 5... pixels wide in the middle of a pixel (0.5, 1.5, 2.5...)
21
- * - To center lines 2, 4, 6... pixels wide between two pixels (0, 1, 2, 3...)
22
- * Also, for HiDPi screens:
23
- * - To center lines of "integer thicknesses" between two screen pixels (0, 0.5, 1, 1.5, 2...)
24
- * - To center lines with `n + 0.5` thicknesses in the middle of a screen pixel (0.25, 0.75, 1.25, 1.75...)
25
- * @param rawCoordinate Any input coordinate to fix
26
- * @param lineWidth The width of the line to draw
27
- * @param devicePixelRatio
28
- */
29
- export declare function getCrispLineCoordinate(rawCoordinate: number, lineWidth: number, devicePixelRatio?: number): number;
30
- export declare function getTimeToPixel(timeOrigin: number, pixelOffset: number, timeScale: number): TimeToPixel;
31
- export declare function getPixelToTime(timeOrigin: number, pixelOffset: number, timeScale: number): PixelToTime;
@@ -1,8 +0,0 @@
1
- /**
2
- * This function returns the picking layers scaling ratio. We basically take the min of the screen
3
- * pixels and the "HTML pixels", and divide it by two.
4
- *
5
- * This allows having a smaller picking stage to fill (so it's faster), while keeping a "good enough
6
- * precision".
7
- */
8
- export declare function getPickingScalingRatio(): number;
@@ -1,16 +0,0 @@
1
- import type { BaseChartContextType, CanvasContextType, DrawingFunction, HoveredItem, LayerType, PickingDrawingFunction, PickingLayerType, Point } from '../types';
2
- /**
3
- * This hook handles the internal canvas drawing logic of a chart component.
4
- */
5
- export declare function useCanvas<T extends BaseChartContextType>(dom: HTMLElement | null, chartContext: T, position?: Point): {
6
- canvasContext: CanvasContextType<T>;
7
- hoveredItem: HoveredItem | null;
8
- };
9
- /**
10
- * This hook helps to bind a picking function to a layer in a Chart.
11
- */
12
- export declare function usePicking<T>(contextKey: React.Context<CanvasContextType<T>>, layer: PickingLayerType, fn: PickingDrawingFunction<T>): void;
13
- /**
14
- * This hook helps to bind a drawing function to a layer in a chart.
15
- */
16
- export declare function useDraw<T>(contextKey: React.Context<CanvasContextType<T>>, layer: LayerType, fn: DrawingFunction<T>): void;
@@ -1 +0,0 @@
1
- export declare function useDevicePixelRatio(): number;
@@ -1,41 +0,0 @@
1
- import type { HoveredItem, Point } from '../../common/types';
2
- import { type DataPoint, type Handler, type MouseContextType, type PointToData } from '../../spaceTimeChart/lib/types';
3
- type Handlers<T> = {
4
- onPan?: Handler<{
5
- isPanning: boolean;
6
- initialPosition: Point;
7
- position: Point;
8
- initialData: DataPoint;
9
- data: DataPoint;
10
- context: T;
11
- }>;
12
- onZoom?: Handler<{
13
- delta: number;
14
- position: Point;
15
- event: WheelEvent;
16
- context: T;
17
- }>;
18
- onClick?: Handler<{
19
- position: Point;
20
- data: DataPoint;
21
- event: MouseEvent;
22
- hoveredItem: HoveredItem | null;
23
- context: T;
24
- }>;
25
- onMouseMove?: Handler<{
26
- position: Point;
27
- data: DataPoint;
28
- isHover: boolean;
29
- hoveredItem: HoveredItem | null;
30
- context: T;
31
- }>;
32
- };
33
- /**
34
- * This hook handles SpaceTimeChart mouse interactions.
35
- * It is an internal hook, and should only be used inside SpaceTimeChart.
36
- */
37
- export declare function useMouseInteractions<T extends {
38
- fingerprint: string;
39
- getData: PointToData;
40
- }>(dom: HTMLElement | null, { position, hoveredItem, down, isHover }: MouseContextType, handlers: Handlers<T>, context: T): void;
41
- export {};
@@ -1,6 +0,0 @@
1
- import { type MouseState } from '../../spaceTimeChart/lib/types';
2
- /**
3
- * This hook handles SpaceTimeChart mouse tracking.
4
- * It is an internal hook, and should only be used inside SpaceTimeChart.
5
- */
6
- export declare function useMouseTracking(dom: HTMLElement | null): MouseState;
@@ -1,7 +0,0 @@
1
- /**
2
- * This hook takes a DOM element reference as input, and returns always updated width and height.
3
- */
4
- export declare function useSize(dom?: HTMLElement | null): {
5
- width: number;
6
- height: number;
7
- };
@@ -1,5 +0,0 @@
1
- export * from './layers/TimeCaptions';
2
- export { default as TimeGraduations } from './layers/TimeGraduations';
3
- export { usePicking, useDraw } from './hooks/useCanvas';
4
- export { getCrispLineCoordinate } from './helpers/time';
5
- export type { HoveredItem, DrawingFunction, PickingDrawingFunction, PickingElement, Point, } from './types';
@@ -1 +0,0 @@
1
- export declare const TimeCaptions: () => null;
@@ -1,2 +0,0 @@
1
- declare const TimeGraduations: () => null;
2
- export default TimeGraduations;
@@ -1,104 +0,0 @@
1
- import { type HTMLProps } from 'react';
2
- import { type SpaceTimeChartTheme } from '../spaceTimeChart';
3
- import type { DataPoint, Handler, PointToData, DataToPoint } from '../spaceTimeChart/lib/types';
4
- import type { LAYERS, PICKING_LAYERS } from './consts';
5
- export type BaseChartContextType = {
6
- fingerprint: string;
7
- pickingElements: PickingElement[];
8
- resetPickingElements: () => void;
9
- registerPickingElement: (element: PickingElement) => number;
10
- theme: {
11
- background: string;
12
- };
13
- };
14
- export type Point = {
15
- x: number;
16
- y: number;
17
- };
18
- export type RGBAColor = [number, number, number, number];
19
- export type PickingLayerType = (typeof PICKING_LAYERS)[number];
20
- export type LayerType = (typeof LAYERS)[number];
21
- export type PickingElement = {
22
- type: string;
23
- };
24
- export type HoveredItem = {
25
- layer: PickingLayerType;
26
- element: PickingElement;
27
- };
28
- export type DrawingFunction<T> = (canvasContext: CanvasRenderingContext2D, stcContext: T) => void;
29
- export type PickingDrawingFunction<T> = (imageData: ImageData, stcContext: T, scalingRatio: number) => void;
30
- export type DrawingFunctionHandler<T> = (arg: {
31
- type: 'picking';
32
- layer: PickingLayerType;
33
- fn: PickingDrawingFunction<T>;
34
- } | {
35
- type: 'rendering';
36
- layer: LayerType;
37
- fn: DrawingFunction<T>;
38
- }) => void;
39
- export type CanvasContextType<T> = {
40
- register: DrawingFunctionHandler<T>;
41
- unregister: DrawingFunctionHandler<T>;
42
- captureCanvases: () => Promise<Blob>;
43
- };
44
- export type TimeToPixel = (time: number) => number;
45
- export type PixelToTime = (x: number) => number;
46
- type BaseTimeChartContextType = BaseChartContextType & {
47
- width: number;
48
- height: number;
49
- timePixelOffset: number;
50
- timeOrigin: number;
51
- timeScale: number;
52
- yPixelOffset: number;
53
- getTimePixel: TimeToPixel;
54
- getTime: PixelToTime;
55
- getPoint: DataToPoint;
56
- getData: PointToData;
57
- theme: SpaceTimeChartTheme;
58
- };
59
- export type ChartOptions = {
60
- captionSize?: number;
61
- enableSnapping?: boolean;
62
- hideDates?: boolean;
63
- hideGrid?: boolean;
64
- hidePathsLabels?: boolean;
65
- hideTimeCaptions?: boolean;
66
- showTicks?: boolean;
67
- swapAxis?: boolean;
68
- };
69
- export type TimeChartContextType = BaseTimeChartContextType & ChartOptions;
70
- export type ChartEventHandlers<T> = {
71
- onPan?: Handler<{
72
- isPanning: boolean;
73
- initialPosition: Point;
74
- position: Point;
75
- initialData: DataPoint;
76
- data: DataPoint;
77
- context: T;
78
- }>;
79
- onZoom?: Handler<{
80
- delta: number;
81
- position: Point;
82
- event: WheelEvent;
83
- context: T;
84
- }>;
85
- onClick?: Handler<{
86
- position: Point;
87
- data: DataPoint;
88
- event: MouseEvent;
89
- hoveredItem: HoveredItem | null;
90
- context: T;
91
- }>;
92
- onMouseMove?: Handler<{
93
- position: Point;
94
- data: DataPoint;
95
- isHover: boolean;
96
- hoveredItem: HoveredItem | null;
97
- context: T;
98
- }>;
99
- onHoveredChildUpdate?: Handler<{
100
- item: HoveredItem | null;
101
- context: T;
102
- }>;
103
- } & Omit<HTMLProps<HTMLDivElement>, 'onClick' | 'onMouseMove'>;
104
- export {};