@spider-analyzer/timeline 4.0.3 → 5.0.1
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/CHANGELOG.md +80 -1
- package/README.md +275 -637
- package/dist/index.d.mts +132 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.js +2913 -22
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2906 -0
- package/dist/index.mjs.map +1 -0
- package/dist/timeline.css +139 -0
- package/package.json +52 -15
- package/src/Cursor.jsx +5 -13
- package/src/TimeLine.tsx +994 -0
- package/src/TimeLineResizer.jsx +2 -8
- package/src/ToolTip.jsx +7 -7
- package/src/cursorElements/CursorIcon.jsx +6 -29
- package/src/cursorElements/CursorSelection.jsx +4 -19
- package/src/cursorElements/DragOverlay.jsx +2 -12
- package/src/cursorElements/LeftHandle.jsx +3 -19
- package/src/cursorElements/LeftToolTip.jsx +2 -7
- package/src/cursorElements/RightHandle.jsx +3 -19
- package/src/cursorElements/RightToolTip.jsx +4 -13
- package/src/cursorElements/ZoomIn.jsx +5 -25
- package/src/cursorElements/ZoomOut.jsx +4 -21
- package/src/cursorElements/utils.js +1 -1
- package/src/index.js +6 -0
- package/src/index.ts +158 -0
- package/src/moment-shim.ts +169 -0
- package/src/styles.ts +15 -0
- package/src/time.ts +52 -0
- package/src/timeLineElements/Button.jsx +5 -30
- package/src/timeLineElements/HistoToolTip.jsx +3 -17
- package/src/timeLineElements/Histogram.jsx +4 -16
- package/src/timeLineElements/Legend.jsx +2 -16
- package/src/timeLineElements/QualityLine.jsx +4 -11
- package/src/timeLineElements/Tools.jsx +1 -1
- package/src/timeLineElements/XAxis.jsx +5 -8
- package/src/timeLineElements/XGrid.jsx +3 -7
- package/src/timeLineElements/YAxis.jsx +4 -7
- package/src/timeLineElements/YGrid.jsx +2 -6
- package/src/timeLineElements/axesStyles.jsx +0 -49
- package/src/timeline.css +139 -0
- package/src/utils.ts +60 -0
- package/.babelrc +0 -8
- package/.gitlab-ci.yml +0 -27
- package/Makefile +0 -20
- package/dist/Cursor.js +0 -290
- package/dist/TimeLine.js +0 -1177
- package/dist/TimeLineResizer.js +0 -70
- package/dist/ToolTip.js +0 -43
- package/dist/cursorElements/CursorIcon.js +0 -98
- package/dist/cursorElements/CursorSelection.js +0 -179
- package/dist/cursorElements/DragOverlay.js +0 -168
- package/dist/cursorElements/LeftHandle.js +0 -95
- package/dist/cursorElements/LeftToolTip.js +0 -70
- package/dist/cursorElements/RightHandle.js +0 -95
- package/dist/cursorElements/RightToolTip.js +0 -75
- package/dist/cursorElements/ZoomIn.js +0 -93
- package/dist/cursorElements/ZoomOut.js +0 -67
- package/dist/cursorElements/commonStyles.js +0 -28
- package/dist/cursorElements/handleHistoHovering.js +0 -79
- package/dist/cursorElements/utils.js +0 -30
- package/dist/theme.js +0 -59
- package/dist/timeLineElements/Button.js +0 -101
- package/dist/timeLineElements/HistoToolTip.js +0 -78
- package/dist/timeLineElements/Histogram.js +0 -110
- package/dist/timeLineElements/Legend.js +0 -70
- package/dist/timeLineElements/QualityLine.js +0 -81
- package/dist/timeLineElements/Tools.js +0 -115
- package/dist/timeLineElements/XAxis.js +0 -76
- package/dist/timeLineElements/XGrid.js +0 -47
- package/dist/timeLineElements/YAxis.js +0 -60
- package/dist/timeLineElements/YGrid.js +0 -46
- package/dist/timeLineElements/axesStyles.js +0 -57
- package/src/TimeLine.jsx +0 -1163
- package/src/cursorElements/commonStyles.js +0 -21
package/src/TimeLineResizer.jsx
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, forwardRef } from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/styles';
|
|
3
2
|
|
|
4
3
|
import TimeLine from './TimeLine';
|
|
4
|
+
import './timeline.css';
|
|
5
5
|
|
|
6
6
|
const defaultWidth = 900;
|
|
7
7
|
const defaultHeight = 100;
|
|
8
8
|
|
|
9
|
-
const useStyles = makeStyles((theme) => ({
|
|
10
|
-
timelineContainer: {
|
|
11
|
-
width: '100%', height: '100%'
|
|
12
|
-
}
|
|
13
|
-
}));
|
|
14
9
|
|
|
15
10
|
function TimeLineResizer(props){
|
|
16
11
|
|
|
@@ -37,12 +32,11 @@ function TimeLineResizer(props){
|
|
|
37
32
|
}
|
|
38
33
|
}, [container.current]);
|
|
39
34
|
|
|
40
|
-
const classes = useStyles();
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
37
|
<div
|
|
44
38
|
ref={container}
|
|
45
|
-
className=
|
|
39
|
+
className="tl-root tl-timelineContainer"
|
|
46
40
|
>
|
|
47
41
|
<TimeLine
|
|
48
42
|
ref={props.forwardedRef}
|
package/src/ToolTip.jsx
CHANGED
|
@@ -5,10 +5,14 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import './tipDark.css';
|
|
6
6
|
import theme from './theme';
|
|
7
7
|
|
|
8
|
-
export default function ToolTip({overlay, placement, mouseEnterDelay, prefixCls, align, visible, hidden, children}){
|
|
8
|
+
export default function ToolTip({overlay, placement = 'top', mouseEnterDelay = 0.5, prefixCls, align, visible, hidden, children}){
|
|
9
|
+
// rc-tooltip v6 keeps `visible` as the controlled prop; pass it only
|
|
10
|
+
// when explicitly controlled so uncontrolled hover behavior still works
|
|
11
|
+
// (an explicit `visible={false}` would otherwise pin the tooltip shut
|
|
12
|
+
// and block the mouseEnterDelay-based reveal).
|
|
9
13
|
const extraProps = {};
|
|
10
|
-
if(visible) extraProps.visible = true;
|
|
11
|
-
if(hidden) extraProps.visible = false;
|
|
14
|
+
if (visible) extraProps.visible = true;
|
|
15
|
+
if (hidden) extraProps.visible = false;
|
|
12
16
|
|
|
13
17
|
return (
|
|
14
18
|
<ToolTipBase
|
|
@@ -31,7 +35,3 @@ ToolTip.propTypes = {
|
|
|
31
35
|
mouseEnterDelay: PropTypes.number,
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
ToolTip.defaultProps = {
|
|
35
|
-
placement: 'top',
|
|
36
|
-
mouseEnterDelay: 0.5,
|
|
37
|
-
}
|
|
@@ -1,37 +1,14 @@
|
|
|
1
1
|
import React, {useState} from 'react';
|
|
2
2
|
import ToolTip from '../ToolTip';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {makeStyles} from '@material-ui/styles';
|
|
5
4
|
|
|
6
|
-
import theme from '../theme';
|
|
7
5
|
import clsx from 'clsx';
|
|
8
6
|
|
|
9
|
-
const useStyles = makeStyles({
|
|
10
|
-
cursorIconRect: {
|
|
11
|
-
fill: '#00bcd4',
|
|
12
|
-
fillOpacity: 0.25,
|
|
13
|
-
stroke: '#00bcd4',
|
|
14
|
-
strokeWidth: 0.42,
|
|
15
|
-
},
|
|
16
|
-
cursorIconCircle:{
|
|
17
|
-
fill: '#ffffff',
|
|
18
|
-
stroke: '#00bcd4',
|
|
19
|
-
strokeWidth: 0.52,
|
|
20
|
-
},
|
|
21
|
-
cursorIconRectOver: {
|
|
22
|
-
fill: theme.colors.itemFillSelected,
|
|
23
|
-
stroke: theme.colors.itemStrokeSelected,
|
|
24
|
-
},
|
|
25
|
-
cursorIconCircleOver:{
|
|
26
|
-
stroke: theme.colors.itemStrokeSelected,
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
7
|
|
|
30
8
|
export default function CursorIcon({ classes, rcToolTipPrefixCls, origin,
|
|
31
9
|
position, gotoCursorLabel, onGotoCursor
|
|
32
10
|
}){
|
|
33
11
|
|
|
34
|
-
const defaultClasses = useStyles();
|
|
35
12
|
const [isOver, setIsOver] = useState(false);
|
|
36
13
|
|
|
37
14
|
return (
|
|
@@ -48,9 +25,9 @@ export default function CursorIcon({ classes, rcToolTipPrefixCls, origin,
|
|
|
48
25
|
>
|
|
49
26
|
<rect
|
|
50
27
|
className={clsx(
|
|
51
|
-
|
|
28
|
+
"tl-cursorIconRect",
|
|
52
29
|
classes.cursorIconRect,
|
|
53
|
-
isOver &&
|
|
30
|
+
isOver && "tl-cursorIconRectOver",
|
|
54
31
|
isOver && classes.cursorIconRectOver,
|
|
55
32
|
)}
|
|
56
33
|
width="5.5"
|
|
@@ -59,9 +36,9 @@ export default function CursorIcon({ classes, rcToolTipPrefixCls, origin,
|
|
|
59
36
|
y="4.76" />
|
|
60
37
|
<circle
|
|
61
38
|
className={clsx(
|
|
62
|
-
|
|
39
|
+
"tl-cursorIconCircle",
|
|
63
40
|
classes.cursorIconCircle,
|
|
64
|
-
isOver &&
|
|
41
|
+
isOver && "tl-cursorIconCircleOver",
|
|
65
42
|
isOver && classes.cursorIconCircleOver,
|
|
66
43
|
)}
|
|
67
44
|
cx="9.63"
|
|
@@ -69,9 +46,9 @@ export default function CursorIcon({ classes, rcToolTipPrefixCls, origin,
|
|
|
69
46
|
r="1.4" />
|
|
70
47
|
<circle
|
|
71
48
|
className={clsx(
|
|
72
|
-
|
|
49
|
+
"tl-cursorIconCircle",
|
|
73
50
|
classes.cursorIconCircle,
|
|
74
|
-
isOver &&
|
|
51
|
+
isOver && "tl-cursorIconCircleOver",
|
|
75
52
|
isOver && classes.cursorIconCircleOver,
|
|
76
53
|
)}
|
|
77
54
|
cx="15"
|
|
@@ -1,27 +1,13 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {forwardRef, useCallback, useEffect, useRef, useState} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
import {pointer, select} from 'd3-selection';
|
|
5
5
|
import {drag} from 'd3-drag';
|
|
6
6
|
|
|
7
|
-
import theme from '../theme';
|
|
8
7
|
import clsx from 'clsx';
|
|
9
|
-
import moment from 'moment-
|
|
8
|
+
import moment from '../moment-shim';
|
|
10
9
|
import {handleHistoOver, handleHistoOut} from './handleHistoHovering';
|
|
11
10
|
|
|
12
|
-
const useStyles = makeStyles({
|
|
13
|
-
cursorArea: {
|
|
14
|
-
fill: theme.colors.cursorFill,
|
|
15
|
-
fillOpacity: 0.2,
|
|
16
|
-
stroke: ({maxSize}) => maxSize ? theme.colors.maxSizeStroke : theme.colors.cursorStroke,
|
|
17
|
-
strokeWidth: '1px',
|
|
18
|
-
strokeLinecap: 'butt',
|
|
19
|
-
strokeLinejoin: 'miter',
|
|
20
|
-
strokeOpacity: 1,
|
|
21
|
-
cursor: 'move',
|
|
22
|
-
transition: 'fill stroke 0.5s'
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
11
|
|
|
26
12
|
export function CursorSelection({
|
|
27
13
|
classes, cursor,
|
|
@@ -34,8 +20,7 @@ export function CursorSelection({
|
|
|
34
20
|
dragging, barHovered, marginBottom,
|
|
35
21
|
setDragging, setBarHovered, setToolTipVisible,
|
|
36
22
|
}) {
|
|
37
|
-
const
|
|
38
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
23
|
+
const className = (n) => cn(n, classes);
|
|
39
24
|
|
|
40
25
|
const [timer, setTimer] = useState(null);
|
|
41
26
|
|
|
@@ -91,7 +76,7 @@ export function CursorSelection({
|
|
|
91
76
|
return (
|
|
92
77
|
<rect
|
|
93
78
|
ref={cursor}
|
|
94
|
-
className={className('cursorArea')}
|
|
79
|
+
className={clsx(className('cursorArea'), maxSize && 'tl--maxSize')}
|
|
95
80
|
x={0}
|
|
96
81
|
y={-3}
|
|
97
82
|
width={width}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import React, {forwardRef, useCallback, useEffect, useRef, useState} from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
3
|
import {pointer, select} from 'd3-selection';
|
|
5
4
|
import {drag} from 'd3-drag';
|
|
6
|
-
import moment from 'moment-
|
|
5
|
+
import moment from '../moment-shim';
|
|
7
6
|
|
|
8
7
|
import {handleHistoOver, handleHistoOut} from './handleHistoHovering';
|
|
9
8
|
|
|
10
|
-
const useStyles = makeStyles({
|
|
11
|
-
dragOverlay: {
|
|
12
|
-
fill: 'transparent',
|
|
13
|
-
fillOpacity : 1,
|
|
14
|
-
stroke: 'none',
|
|
15
|
-
cursor: 'crosshair',
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
9
|
|
|
19
10
|
function DragOverlay({
|
|
20
11
|
width, height, marginBottom,
|
|
@@ -29,7 +20,6 @@ function DragOverlay({
|
|
|
29
20
|
const dragOverlayContainer = useRef();
|
|
30
21
|
const [timer, setTimer] = useState(null);
|
|
31
22
|
|
|
32
|
-
const classes = useStyles();
|
|
33
23
|
const setOverlayCursor = event => {
|
|
34
24
|
if(event.ctrlKey){
|
|
35
25
|
dragOverlayRef.current.style.cursor = 'move';
|
|
@@ -95,7 +85,7 @@ function DragOverlay({
|
|
|
95
85
|
<g ref={dragOverlayContainer}>
|
|
96
86
|
<rect
|
|
97
87
|
ref={dragOverlayRef}
|
|
98
|
-
className=
|
|
88
|
+
className="tl-dragOverlay"
|
|
99
89
|
x={0}
|
|
100
90
|
y={0}
|
|
101
91
|
width={width}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {useRef, useEffect} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
import {pointer, select} from 'd3-selection';
|
|
5
5
|
import {drag} from 'd3-drag';
|
|
6
6
|
|
|
7
|
-
import theme from '../theme';
|
|
8
7
|
import clsx from 'clsx';
|
|
9
8
|
|
|
10
|
-
const useStyles = makeStyles({
|
|
11
|
-
cursorLeftHandle: {
|
|
12
|
-
fillOpacity: 1,
|
|
13
|
-
strokeWidth: '1px',
|
|
14
|
-
transition: 'r 0.5s',
|
|
15
|
-
r: 4,
|
|
16
|
-
'&:hover':{
|
|
17
|
-
r: 8
|
|
18
|
-
},
|
|
19
|
-
cursor: ({maxSize}) => maxSize ? 'e-resize' : 'ew-resize',
|
|
20
|
-
fill: ({startIsOutOfView}) => startIsOutOfView ? theme.colors.outsideViewFill : theme.colors.cursorHandleFill,
|
|
21
|
-
stroke: ({startIsOutOfView}) => startIsOutOfView ? theme.colors.outsideViewStroke : theme.colors.cursorStroke
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
9
|
|
|
25
10
|
export default function LeftHandle({
|
|
26
11
|
classes, maxSize,
|
|
@@ -28,8 +13,7 @@ export default function LeftHandle({
|
|
|
28
13
|
dragOverlay, showToolTipLeft,
|
|
29
14
|
origin, startIsOutOfView, setDragging
|
|
30
15
|
}) {
|
|
31
|
-
const
|
|
32
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
16
|
+
const className = (n) => cn(n, classes);
|
|
33
17
|
|
|
34
18
|
const cursorLeftHandle = useRef();
|
|
35
19
|
|
|
@@ -55,7 +39,7 @@ export default function LeftHandle({
|
|
|
55
39
|
return (
|
|
56
40
|
<circle
|
|
57
41
|
ref={cursorLeftHandle}
|
|
58
|
-
className={className('cursorLeftHandle')}
|
|
42
|
+
className={clsx(className('cursorLeftHandle'), maxSize && 'tl--maxSize', startIsOutOfView && 'tl--outOfView')}
|
|
59
43
|
r='4'
|
|
60
44
|
cx={origin.x}
|
|
61
45
|
cy={origin.y}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {useRef, useEffect} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import {hide, show, resizeToolTip, resizeToolTipText} from './utils';
|
|
7
|
-
import {toolTipStyles} from './commonStyles';
|
|
8
7
|
|
|
9
|
-
const useStyles = makeStyles({
|
|
10
|
-
...toolTipStyles,
|
|
11
|
-
});
|
|
12
8
|
|
|
13
9
|
export default function LeftToolTip({
|
|
14
10
|
classes, height, origin,
|
|
15
11
|
isVisibleTooltipLeft,
|
|
16
12
|
startText,
|
|
17
13
|
}) {
|
|
18
|
-
const
|
|
19
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
14
|
+
const className = (n) => cn(n, classes);
|
|
20
15
|
|
|
21
16
|
const toolTipLeft = useRef();
|
|
22
17
|
|
|
@@ -1,34 +1,18 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {useRef, useEffect} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
import {pointer, select} from 'd3-selection';
|
|
5
5
|
import {drag} from 'd3-drag';
|
|
6
6
|
|
|
7
|
-
import theme from '../theme';
|
|
8
7
|
import clsx from 'clsx';
|
|
9
8
|
|
|
10
|
-
const useStyles = makeStyles({
|
|
11
|
-
cursorRightHandle: {
|
|
12
|
-
fillOpacity: 1,
|
|
13
|
-
strokeWidth: '1px',
|
|
14
|
-
transition: 'r 0.5s',
|
|
15
|
-
r: 4,
|
|
16
|
-
'&:hover':{
|
|
17
|
-
r: 8
|
|
18
|
-
},
|
|
19
|
-
cursor: ({maxSize}) => maxSize ? 'w-resize' : 'ew-resize',
|
|
20
|
-
fill: ({endIsOutOfView}) => endIsOutOfView ? theme.colors.outsideViewFill : theme.colors.cursorHandleFill,
|
|
21
|
-
stroke: ({endIsOutOfView}) => endIsOutOfView ? theme.colors.outsideViewStroke : theme.colors.cursorStroke
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
9
|
|
|
25
10
|
export default function RightHandle({
|
|
26
11
|
classes, maxSize, origin,
|
|
27
12
|
onResizeRightCursor, onEndResizeCursor,
|
|
28
13
|
dragOverlay, showToolTipRight, endIsOutOfView, setDragging
|
|
29
14
|
}) {
|
|
30
|
-
const
|
|
31
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
15
|
+
const className = (n) => cn(n, classes);
|
|
32
16
|
|
|
33
17
|
const cursorRightHandle = useRef();
|
|
34
18
|
|
|
@@ -54,7 +38,7 @@ export default function RightHandle({
|
|
|
54
38
|
return (
|
|
55
39
|
<circle
|
|
56
40
|
ref={cursorRightHandle}
|
|
57
|
-
className={className('cursorRightHandle')}
|
|
41
|
+
className={clsx(className('cursorRightHandle'), maxSize && 'tl--maxSize', endIsOutOfView && 'tl--outOfView')}
|
|
58
42
|
r='4'
|
|
59
43
|
cx={origin.x}
|
|
60
44
|
cy={origin.y}
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {useRef, useEffect} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import {hide, show, resizeToolTip, resizeToolTipText, resizeToolTipRightDelta} from './utils';
|
|
7
|
-
import {toolTipStyles} from './commonStyles';
|
|
8
7
|
|
|
9
|
-
const useStyles = makeStyles({
|
|
10
|
-
...toolTipStyles,
|
|
11
|
-
toolTipTextRight: {
|
|
12
|
-
textAlign: 'end',
|
|
13
|
-
textAnchor: 'end'
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
8
|
|
|
17
9
|
export default function RightToolTip({
|
|
18
10
|
classes, origin,
|
|
19
11
|
isVisibleTooltipRight,
|
|
20
12
|
stopText, height
|
|
21
13
|
}) {
|
|
22
|
-
const
|
|
23
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
14
|
+
const className = (n) => cn(n, classes);
|
|
24
15
|
|
|
25
16
|
const toolTipRight = useRef();
|
|
26
17
|
|
|
@@ -52,9 +43,9 @@ export default function RightToolTip({
|
|
|
52
43
|
</g>
|
|
53
44
|
<text
|
|
54
45
|
className={clsx(
|
|
55
|
-
|
|
46
|
+
"tl-toolTipText",
|
|
56
47
|
classes.toolTipText,
|
|
57
|
-
|
|
48
|
+
"tl-toolTipTextRight",
|
|
58
49
|
classes.toolTipTextRight,
|
|
59
50
|
)}
|
|
60
51
|
style={{
|
|
@@ -1,40 +1,20 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React, {forwardRef} from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
import ToolTip from '../ToolTip';
|
|
5
5
|
|
|
6
|
-
import theme from '../theme';
|
|
7
6
|
import clsx from 'clsx';
|
|
8
7
|
|
|
9
8
|
const zoomIcon = 'M 15.5 14 h -0.79 l -0.28 -0.27 C 15.41 12.59 16 11.11 16 9.5 C 16 5.91 13.09 3 9.5 3 S 3 5.91 3 9.5 S 5.91 16 9.5 16 c 1.61 0 3.09 -0.59 4.23 -1.57 l 0.27 0.28 v 0.79 l 5 4.99 L 20.49 19 l -4.99 -5 Z m -6 0 C 7.01 14 5 11.99 5 9.5 S 7.01 5 9.5 5 S 14 7.01 14 9.5 S 11.99 14 9.5 14 Z'
|
|
10
9
|
const plusSign = "M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z";
|
|
11
10
|
|
|
12
|
-
const useStyles = makeStyles({
|
|
13
|
-
zoomIn: {
|
|
14
|
-
fill: theme.colors.zoomInIcon,
|
|
15
|
-
fillOpacity : 1,
|
|
16
|
-
stroke: 'none'
|
|
17
|
-
},
|
|
18
|
-
zoomArea: {
|
|
19
|
-
fill: 'transparent',
|
|
20
|
-
fillOpacity : 1,
|
|
21
|
-
stroke: 'none',
|
|
22
|
-
},
|
|
23
|
-
zoomInContainer: {
|
|
24
|
-
opacity: 0,
|
|
25
|
-
visibility: 'hidden',
|
|
26
|
-
transition: 'opacity visibility 0.5s',
|
|
27
|
-
cursor: 'pointer'
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
11
|
|
|
31
12
|
function ZoomIn({
|
|
32
13
|
classes, origin,
|
|
33
14
|
zoomInLabel, onZoomIn, rcToolTipPrefixCls,
|
|
34
15
|
forwardedRef
|
|
35
16
|
}){
|
|
36
|
-
const
|
|
37
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
17
|
+
const className = (n) => cn(n, classes);
|
|
38
18
|
|
|
39
19
|
return (
|
|
40
20
|
<ToolTip
|
|
@@ -42,13 +22,13 @@ function ZoomIn({
|
|
|
42
22
|
overlay={zoomInLabel}
|
|
43
23
|
>
|
|
44
24
|
<g
|
|
45
|
-
className={
|
|
25
|
+
className={"tl-zoomInContainer"}
|
|
46
26
|
ref={forwardedRef}
|
|
47
27
|
transform={`translate(${origin.x}, ${origin.y})`}
|
|
48
28
|
onClick={onZoomIn}
|
|
49
29
|
>
|
|
50
30
|
<rect
|
|
51
|
-
className={
|
|
31
|
+
className={"tl-zoomArea"}
|
|
52
32
|
x={0}
|
|
53
33
|
y={0}
|
|
54
34
|
width={23}
|
|
@@ -63,7 +43,7 @@ function ZoomIn({
|
|
|
63
43
|
d={plusSign}
|
|
64
44
|
/>
|
|
65
45
|
<rect
|
|
66
|
-
className={
|
|
46
|
+
className={"tl-zoomArea"}
|
|
67
47
|
x={0}
|
|
68
48
|
y={0}
|
|
69
49
|
width={23}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
+
import { cn } from "../styles";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {makeStyles} from '@material-ui/styles';
|
|
4
4
|
import ToolTip from '../ToolTip';
|
|
5
5
|
|
|
6
|
-
import theme from '../theme';
|
|
7
6
|
import clsx from 'clsx';
|
|
8
7
|
|
|
9
8
|
const zoomOutIcon = 'M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z';
|
|
10
9
|
|
|
11
|
-
const useStyles = makeStyles({
|
|
12
|
-
zoomOut: {
|
|
13
|
-
fill: theme.colors.zoomOutIcon,
|
|
14
|
-
fillOpacity : 1,
|
|
15
|
-
stroke: 'none'
|
|
16
|
-
},
|
|
17
|
-
zoomArea: {
|
|
18
|
-
fill: 'transparent',
|
|
19
|
-
fillOpacity : 1,
|
|
20
|
-
stroke: 'none',
|
|
21
|
-
},
|
|
22
|
-
zoomOutContainer: {
|
|
23
|
-
cursor: 'pointer'
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
10
|
|
|
27
11
|
export default function ZoomOut({classes, origin, zoomOutLabel, onZoomOut, rcToolTipPrefixCls}){
|
|
28
12
|
|
|
29
|
-
const
|
|
30
|
-
const className = (className) => clsx(defaultClasses[className], classes[className]);
|
|
13
|
+
const className = (n) => cn(n, classes);
|
|
31
14
|
|
|
32
15
|
return (
|
|
33
16
|
<ToolTip
|
|
@@ -35,12 +18,12 @@ export default function ZoomOut({classes, origin, zoomOutLabel, onZoomOut, rcToo
|
|
|
35
18
|
overlay={zoomOutLabel}
|
|
36
19
|
>
|
|
37
20
|
<g
|
|
38
|
-
className={
|
|
21
|
+
className={"tl-zoomOutContainer"}
|
|
39
22
|
transform={`translate(${origin.x}, ${origin.y})`}
|
|
40
23
|
onClick={onZoomOut}
|
|
41
24
|
>
|
|
42
25
|
<rect
|
|
43
|
-
className={
|
|
26
|
+
className={"tl-zoomArea"}
|
|
44
27
|
x={0}
|
|
45
28
|
y={0}
|
|
46
29
|
width={23}
|
package/src/index.js
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode, Ref } from 'react';
|
|
2
|
+
|
|
3
|
+
import TimeLineResizer from './TimeLineResizer';
|
|
4
|
+
import Cursor from './Cursor';
|
|
5
|
+
import TimeLine from './TimeLine';
|
|
6
|
+
|
|
7
|
+
// --- Public data shapes ------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export interface Domain {
|
|
10
|
+
min: Date;
|
|
11
|
+
max: Date;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TimeSpan {
|
|
15
|
+
start: Date;
|
|
16
|
+
stop: Date;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface HistoItem {
|
|
20
|
+
time: Date;
|
|
21
|
+
metrics: number[];
|
|
22
|
+
total: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Histo {
|
|
26
|
+
items: HistoItem[];
|
|
27
|
+
intervalMs: number | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface QualityItem {
|
|
31
|
+
time: Date;
|
|
32
|
+
quality: number;
|
|
33
|
+
tip?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Quality {
|
|
37
|
+
items: QualityItem[];
|
|
38
|
+
intervalMin?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface MetricsDefinition {
|
|
42
|
+
count: number;
|
|
43
|
+
legends: string[];
|
|
44
|
+
colors: Array<{ fill: string; stroke: string; text: string }>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface TimeLineTools {
|
|
48
|
+
slideForward?: boolean;
|
|
49
|
+
slideBackward?: boolean;
|
|
50
|
+
resetTimeline?: boolean;
|
|
51
|
+
gotoNow?: boolean;
|
|
52
|
+
cursor?: boolean;
|
|
53
|
+
zoomIn?: boolean;
|
|
54
|
+
zoomOut?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface AxisConfig {
|
|
58
|
+
spaceBetweenTicks?: number;
|
|
59
|
+
barsBetweenTicks?: number;
|
|
60
|
+
height?: number;
|
|
61
|
+
showGrid?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface MarginConfig {
|
|
65
|
+
top?: number;
|
|
66
|
+
bottom?: number;
|
|
67
|
+
left?: number;
|
|
68
|
+
right?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --- Imperative handle -------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
export interface TimeLineHandle {
|
|
74
|
+
zoomIn(): void;
|
|
75
|
+
zoomOut(): void;
|
|
76
|
+
shiftTimeLine(delta: number): void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// --- Props -------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
export interface TimeLineProps {
|
|
82
|
+
className?: string;
|
|
83
|
+
classes?: Record<string, string>;
|
|
84
|
+
rcToolTipPrefixCls?: string;
|
|
85
|
+
|
|
86
|
+
timeSpan: TimeSpan;
|
|
87
|
+
histo: Histo;
|
|
88
|
+
quality?: Quality;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The currently-visible window, controlled by the host.
|
|
92
|
+
* Pass `null` on first render if you don't have a default yet — the
|
|
93
|
+
* component will call `onLoadDefaultDomain()` and wait for its result.
|
|
94
|
+
*
|
|
95
|
+
* Zoom-out undo is handled internally; the host only needs to observe
|
|
96
|
+
* `onDomainChange` and re-render with whatever domain it wants.
|
|
97
|
+
*/
|
|
98
|
+
domain: Domain | null;
|
|
99
|
+
maxDomain?: Domain;
|
|
100
|
+
|
|
101
|
+
metricsDefinition: MetricsDefinition;
|
|
102
|
+
|
|
103
|
+
/** IANA time-zone name (e.g. "UTC", "Europe/Paris"). Required. */
|
|
104
|
+
timeZone?: string;
|
|
105
|
+
|
|
106
|
+
zoomOutFactor?: number;
|
|
107
|
+
/** Maximum visible duration, in milliseconds. */
|
|
108
|
+
biggestVisibleDomain?: number;
|
|
109
|
+
/** Maximum selectable duration, in milliseconds. */
|
|
110
|
+
biggestTimeSpan?: number;
|
|
111
|
+
/** Smallest zoom step (15 px == this value), in milliseconds. */
|
|
112
|
+
smallestResolution?: number;
|
|
113
|
+
|
|
114
|
+
tools?: TimeLineTools;
|
|
115
|
+
fetchWhileSliding?: boolean;
|
|
116
|
+
selectBarOnClick?: boolean;
|
|
117
|
+
showHistoToolTip?: boolean;
|
|
118
|
+
|
|
119
|
+
xAxis?: AxisConfig;
|
|
120
|
+
yAxis?: AxisConfig;
|
|
121
|
+
margin?: MarginConfig;
|
|
122
|
+
|
|
123
|
+
labels?: Record<string, unknown>;
|
|
124
|
+
|
|
125
|
+
/** Called on mount when `domain` is null. Return (sync or Promise) the
|
|
126
|
+
* default domain; the component seeds its internal stack from it and
|
|
127
|
+
* fires `onDomainChange` once resolved.
|
|
128
|
+
*/
|
|
129
|
+
onLoadDefaultDomain(): Domain | Promise<Domain> | void;
|
|
130
|
+
/** Called whenever the component needs histogram data for a window. */
|
|
131
|
+
onLoadHisto(args: { intervalMs: number; start: Date; end: Date }): void;
|
|
132
|
+
/** Called when the cursor selection changes (resize, drag, draw, goto). */
|
|
133
|
+
onTimeSpanChange(span: TimeSpan): void;
|
|
134
|
+
onShowMessage(message: ReactNode): void;
|
|
135
|
+
/** Called when the visible domain changes — zoom in/out, pan, or edge shift. */
|
|
136
|
+
onDomainChange(domain: Domain): void;
|
|
137
|
+
onResetTime(): void;
|
|
138
|
+
onFormatTimeToolTips(time: Date): ReactNode;
|
|
139
|
+
onFormatTimeLegend(time: Date): string;
|
|
140
|
+
onFormatMetricLegend(value: number): string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface TimeLineResizerProps extends TimeLineProps {
|
|
144
|
+
// Resizer measures the container and injects `width`/`height` itself.
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// --- Exports -----------------------------------------------------------------
|
|
148
|
+
|
|
149
|
+
// TimeLine and TimeLineResizer accept a ref forwarding to TimeLineHandle.
|
|
150
|
+
type TimeLineComponent = ComponentType<TimeLineProps & { ref?: Ref<TimeLineHandle> }>;
|
|
151
|
+
type TimeLineResizerComponent = ComponentType<TimeLineResizerProps & { ref?: Ref<TimeLineHandle> }>;
|
|
152
|
+
|
|
153
|
+
const _TimeLine = TimeLine as unknown as TimeLineComponent;
|
|
154
|
+
const _TimeLineResizer = TimeLineResizer as unknown as TimeLineResizerComponent;
|
|
155
|
+
const _Cursor = Cursor as unknown as ComponentType<Record<string, unknown>>;
|
|
156
|
+
|
|
157
|
+
export { _TimeLine as TimeLine, _Cursor as Cursor };
|
|
158
|
+
export default _TimeLineResizer;
|