@centreon/ui 25.1.2 → 25.1.3
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,42 +1,45 @@
|
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
1
2
|
import { Zoom as VisxZoom } from '@visx/zoom';
|
|
3
|
+
import { TransformMatrix } from '@visx/zoom/lib/types';
|
|
2
4
|
|
|
3
5
|
import { ParentSize } from '../..';
|
|
4
6
|
|
|
5
7
|
import ZoomContent from './ZoomContent';
|
|
6
|
-
import type {
|
|
8
|
+
import type { MinimapPosition, ZoomChildren } from './models';
|
|
7
9
|
|
|
8
|
-
export interface ZoomProps {
|
|
9
|
-
children: (args: ChildrenProps) => JSX.Element;
|
|
10
|
+
export interface ZoomProps extends ZoomChildren {
|
|
10
11
|
id?: number | string;
|
|
11
12
|
minimapPosition?: MinimapPosition;
|
|
12
13
|
scaleMax?: number;
|
|
13
14
|
scaleMin?: number;
|
|
14
15
|
showMinimap?: boolean;
|
|
16
|
+
contentRef?: MutableRefObject<SVGGElement | null>;
|
|
17
|
+
transformMatrix?: TransformMatrix;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
const initialTransform = {
|
|
18
|
-
scaleX: 1,
|
|
19
|
-
scaleY: 1,
|
|
20
|
-
skewX: 0,
|
|
21
|
-
skewY: 0,
|
|
22
|
-
translateX: 0,
|
|
23
|
-
translateY: 0
|
|
24
|
-
};
|
|
25
|
-
|
|
26
20
|
const Zoom = ({
|
|
27
21
|
children,
|
|
28
22
|
scaleMin = 0.5,
|
|
29
23
|
scaleMax = 4,
|
|
30
24
|
showMinimap = false,
|
|
31
25
|
minimapPosition = 'top-left',
|
|
32
|
-
id = 0
|
|
26
|
+
id = 0,
|
|
27
|
+
contentRef,
|
|
28
|
+
transformMatrix = {
|
|
29
|
+
scaleX: 1,
|
|
30
|
+
scaleY: 1,
|
|
31
|
+
skewX: 0,
|
|
32
|
+
skewY: 0,
|
|
33
|
+
translateX: 0,
|
|
34
|
+
translateY: 0
|
|
35
|
+
}
|
|
33
36
|
}: ZoomProps): JSX.Element => {
|
|
34
37
|
return (
|
|
35
38
|
<ParentSize>
|
|
36
39
|
{({ width, height }) => (
|
|
37
40
|
<VisxZoom<SVGSVGElement>
|
|
38
41
|
height={height}
|
|
39
|
-
initialTransformMatrix={
|
|
42
|
+
initialTransformMatrix={transformMatrix}
|
|
40
43
|
scaleXMax={scaleMax}
|
|
41
44
|
scaleXMin={scaleMin}
|
|
42
45
|
scaleYMax={scaleMax}
|
|
@@ -51,6 +54,7 @@ const Zoom = ({
|
|
|
51
54
|
showMinimap={showMinimap}
|
|
52
55
|
width={width}
|
|
53
56
|
zoom={zoom}
|
|
57
|
+
ref={contentRef}
|
|
54
58
|
>
|
|
55
59
|
{children}
|
|
56
60
|
</ZoomContent>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { type ForwardedRef, forwardRef, MutableRefObject, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { RectClipPath } from '@visx/clip-path';
|
|
4
4
|
|
|
@@ -8,38 +8,38 @@ import ReplayIcon from '@mui/icons-material/Replay';
|
|
|
8
8
|
|
|
9
9
|
import { IconButton } from '../Button';
|
|
10
10
|
|
|
11
|
-
import Minimap from './Minimap';
|
|
12
|
-
import { useZoomStyles } from './Zoom.styles';
|
|
13
11
|
import { minimapScale, radius } from './constants';
|
|
14
|
-
import type { ChildrenProps, MinimapPosition, ZoomInterface } from './models';
|
|
15
12
|
import { useZoom } from './useZoom';
|
|
13
|
+
import { useZoomStyles } from './Zoom.styles';
|
|
14
|
+
import Minimap from './Minimap';
|
|
15
|
+
import { ZoomChildren, type Dimension, type MinimapPosition, type ZoomInterface } from './models';
|
|
16
16
|
|
|
17
|
-
export interface Props extends ZoomInterface {
|
|
18
|
-
children: (args: ChildrenProps) => JSX.Element;
|
|
19
|
-
height: number;
|
|
17
|
+
export interface Props extends Dimension, ZoomInterface, ZoomChildren {
|
|
20
18
|
id?: number | string;
|
|
21
19
|
minimapPosition: MinimapPosition;
|
|
22
20
|
showMinimap?: boolean;
|
|
23
|
-
width: number;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
const ZoomContent = (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const ZoomContent = forwardRef(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
zoom,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
children,
|
|
30
|
+
showMinimap,
|
|
31
|
+
minimapPosition,
|
|
32
|
+
id
|
|
33
|
+
}: Props,
|
|
34
|
+
ref?: ForwardedRef<SVGGElement | null>
|
|
35
|
+
) : JSX.Element => {
|
|
35
36
|
const { classes } = useZoomStyles();
|
|
36
|
-
|
|
37
|
+
|
|
38
|
+
const fallbackRef = useRef<SVGGElement | null>(null)
|
|
39
|
+
const contentRef = (ref || fallbackRef) as MutableRefObject<SVGGElement | null>;
|
|
37
40
|
const minimapSvgRef = useRef<SVGSVGElement | null>(null);
|
|
38
41
|
const minimapContentRef = useRef<SVGSVGElement | null>(null);
|
|
39
|
-
const [contentClientRect, setContentClientRect] = useState<
|
|
40
|
-
height: number;
|
|
41
|
-
width: number;
|
|
42
|
-
} | null>(null);
|
|
42
|
+
const [contentClientRect, setContentClientRect] = useState<Dimension | null>(null);
|
|
43
43
|
|
|
44
44
|
const resizeObserver = new ResizeObserver(() => {
|
|
45
45
|
const contentBoundingClientRect = (
|
|
@@ -105,8 +105,8 @@ const ZoomContent = ({
|
|
|
105
105
|
contentClientRect,
|
|
106
106
|
height,
|
|
107
107
|
transformMatrix: zoom.transformMatrix,
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
width,
|
|
109
|
+
zoom
|
|
110
110
|
})}
|
|
111
111
|
</g>
|
|
112
112
|
</svg>
|
|
@@ -135,8 +135,8 @@ const ZoomContent = ({
|
|
|
135
135
|
contentClientRect,
|
|
136
136
|
height,
|
|
137
137
|
transformMatrix: zoom.transformMatrix,
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
width,
|
|
139
|
+
zoom
|
|
140
140
|
})}
|
|
141
141
|
</g>
|
|
142
142
|
</Minimap>
|
|
@@ -165,6 +165,6 @@ const ZoomContent = ({
|
|
|
165
165
|
</div>
|
|
166
166
|
</div>
|
|
167
167
|
);
|
|
168
|
-
};
|
|
168
|
+
});
|
|
169
169
|
|
|
170
170
|
export default ZoomContent;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProvidedZoom, TransformMatrix } from '@visx/zoom/lib/types';
|
|
2
2
|
|
|
3
3
|
export interface ZoomState {
|
|
4
|
-
transformMatrix:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
translateY: number;
|
|
11
|
-
};
|
|
12
|
-
setTransformMatrix?: ProvidedZoom<SVGSVGElement>['setTransformMatrix'];
|
|
4
|
+
transformMatrix: TransformMatrix;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Dimension {
|
|
8
|
+
height: number;
|
|
9
|
+
width: number;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
export type MinimapPosition =
|
|
@@ -22,11 +19,12 @@ export interface ZoomInterface {
|
|
|
22
19
|
zoom: ProvidedZoom<SVGSVGElement> & ZoomState;
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
export interface ChildrenProps extends ZoomState {
|
|
26
|
-
contentClientRect:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
width: number;
|
|
22
|
+
export interface ChildrenProps extends ZoomState, Dimension, ZoomInterface {
|
|
23
|
+
contentClientRect: Dimension | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ZoomChildren {
|
|
27
|
+
children: (args: ChildrenProps) => JSX.Element;
|
|
32
28
|
}
|
|
29
|
+
|
|
30
|
+
|