@centreon/ui 25.11.7 → 25.11.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "25.11.7",
3
+ "version": "25.11.9",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -2,7 +2,7 @@ import { RefObject, useEffect, useState } from 'react';
2
2
 
3
3
  import { Event } from '@visx/visx';
4
4
  import { ScaleTime } from 'd3-scale';
5
- import { useAtomValue, useSetAtom } from 'jotai';
5
+ import { useAtom, useAtomValue } from 'jotai';
6
6
  import { equals, gte, isNil, lt } from 'ramda';
7
7
  import { Interval } from '../../models';
8
8
  import {
@@ -37,10 +37,10 @@ const useZoomPreview = ({
37
37
  graphMarginLeft
38
38
  }: Props): ZoomPreview => {
39
39
  const [zoomBoundaries, setZoomBoundaries] = useState<Boundaries | null>(null);
40
+ const [isApplyingZoom, setApplyingZoom] = useAtom(applyingZoomAtomAtom);
40
41
  const eventMouseDown = useAtomValue(eventMouseDownAtom);
41
42
  const eventMouseUp = useAtomValue(eventMouseUpAtom);
42
43
  const mousePosition = useAtomValue(mousePositionAtom);
43
- const setApplyingZoom = useSetAtom(applyingZoomAtomAtom);
44
44
 
45
45
  const mousePointDown =
46
46
  eventMouseDown && graphSvgRef.current
@@ -86,7 +86,6 @@ const useZoomPreview = ({
86
86
  }
87
87
  applyZoom();
88
88
  setApplyingZoom(false);
89
- setZoomBoundaries(null);
90
89
  }, [eventMouseUp]);
91
90
 
92
91
  useEffect(() => {
@@ -99,6 +98,13 @@ const useZoomPreview = ({
99
98
  setApplyingZoom(true);
100
99
  }, [zoomBoundaries]);
101
100
 
101
+ useEffect(() => {
102
+ if (isApplyingZoom) {
103
+ return;
104
+ }
105
+ setZoomBoundaries(null);
106
+ }, [isApplyingZoom]);
107
+
102
108
  const zoomBarWidth = Math.abs(
103
109
  (zoomBoundaries?.end || 0) - (zoomBoundaries?.start || 0)
104
110
  );
@@ -1,8 +1,13 @@
1
- import { type MutableRefObject, ReactElement, useMemo } from 'react';
1
+ import {
2
+ MouseEvent,
3
+ type MutableRefObject,
4
+ ReactElement,
5
+ useMemo
6
+ } from 'react';
2
7
 
3
8
  import { Event } from '@visx/visx';
4
9
  import type { ScaleLinear, ScaleTime } from 'd3-scale';
5
- import { useSetAtom } from 'jotai';
10
+ import { useAtom, useSetAtom } from 'jotai';
6
11
  import {
7
12
  all,
8
13
  equals,
@@ -48,6 +53,7 @@ import type { TimelineEvent } from './Annotations/models';
48
53
  import Bar from './Bar';
49
54
  import TimeShiftZones from './TimeShiftZones';
50
55
  import ZoomPreview from './ZoomPreview';
56
+ import { applyingZoomAtomAtom } from './ZoomPreview/zoomPreviewAtoms';
51
57
  import {
52
58
  type MousePosition,
53
59
  changeMousePositionDerivedAtom,
@@ -103,6 +109,7 @@ const InteractionWithGraph = ({
103
109
  }: Props): ReactElement => {
104
110
  const { classes } = useStyles();
105
111
 
112
+ const [isApplyingZoom, setIsApplyingZoom] = useAtom(applyingZoomAtomAtom);
106
113
  const setEventMouseDown = useSetAtom(eventMouseDownAtom);
107
114
  const setEventMouseUp = useSetAtom(eventMouseUpAtom);
108
115
  const setEventMouseLeave = useSetAtom(eventMouseLeaveAtom);
@@ -136,7 +143,7 @@ const InteractionWithGraph = ({
136
143
  setEventMouseDown(null);
137
144
  };
138
145
 
139
- const mouseMove = (event): void => {
146
+ const mouseMove = (event: MouseEvent): void => {
140
147
  const mousePoint = Event.localPoint(
141
148
  graphSvgRef?.current as SVGSVGElement,
142
149
  event
@@ -150,6 +157,15 @@ const InteractionWithGraph = ({
150
157
  ]);
151
158
  };
152
159
 
160
+ const mouseEnter = (event: MouseEvent): void => {
161
+ if (event.buttons === 1 && isApplyingZoom) {
162
+ mouseDown(event);
163
+ }
164
+ if (event.buttons === 0 && isApplyingZoom) {
165
+ setIsApplyingZoom(false);
166
+ }
167
+ };
168
+
153
169
  const mouseDown = (event): void => {
154
170
  setEventMouseDown(event);
155
171
  };
@@ -336,6 +352,7 @@ const InteractionWithGraph = ({
336
352
  onMouseLeave={mouseLeave}
337
353
  onMouseMove={mouseMove}
338
354
  onMouseUp={mouseUp}
355
+ onMouseEnter={mouseEnter}
339
356
  />
340
357
  </g>
341
358
  );