@pie-lib/graphing 2.34.3-next.2 → 2.34.3-next.205
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 +13 -67
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +106 -194
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +1 -6
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +21 -49
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js +2 -8
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js +14 -59
- package/lib/container/index.js.map +1 -1
- package/lib/container/marks.js +1 -6
- package/lib/container/marks.js.map +1 -1
- package/lib/container/middleware.js +2 -8
- package/lib/container/middleware.js.map +1 -1
- package/lib/container/reducer.js +1 -8
- package/lib/container/reducer.js.map +1 -1
- package/lib/coordinates-label.js +24 -54
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +120 -184
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +59 -116
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +169 -225
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +29 -74
- package/lib/grid.js.map +1 -1
- package/lib/index.js +1 -13
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +40 -85
- package/lib/key-legend.js.map +1 -1
- package/lib/label-svg-icon.js +1 -7
- package/lib/label-svg-icon.js.map +1 -1
- package/lib/labels.js +66 -122
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +120 -163
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +155 -243
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +16 -50
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/component.js +4 -10
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/absolute/index.js +3 -16
- package/lib/tools/absolute/index.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +42 -92
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +78 -165
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +3 -13
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/exponential/component.js +4 -10
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/exponential/index.js +3 -18
- package/lib/tools/exponential/index.js.map +1 -1
- package/lib/tools/index.js +3 -16
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +27 -48
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/line/index.js +1 -6
- package/lib/tools/line/index.js.map +1 -1
- package/lib/tools/parabola/component.js +4 -10
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +3 -16
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +24 -71
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +3 -11
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js +83 -184
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +6 -23
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +48 -91
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +65 -98
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +41 -60
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/ray/index.js +1 -6
- package/lib/tools/ray/index.js.map +1 -1
- package/lib/tools/segment/component.js +25 -43
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/segment/index.js +1 -6
- package/lib/tools/segment/index.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +69 -28
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +12 -8
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +12 -8
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +12 -8
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/index.js +140 -193
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +70 -101
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +22 -56
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +21 -62
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +23 -52
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +54 -72
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +22 -57
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +10 -38
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +2 -9
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js +8 -19
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +3 -16
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +24 -44
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/tools/vector/index.js +1 -6
- package/lib/tools/vector/index.js.map +1 -1
- package/lib/undo-redo.js +29 -69
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +4 -11
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +51 -128
- package/lib/utils.js.map +1 -1
- package/package.json +25 -29
- package/src/__tests__/graph-with-controls.test.jsx +28 -11
- package/src/__tests__/graph.test.jsx +104 -168
- package/src/__tests__/grid.test.jsx +8 -6
- package/src/__tests__/labels.test.jsx +25 -8
- package/src/__tests__/mark-label.test.jsx +12 -17
- package/src/__tests__/toggle-bar.test.jsx +92 -17
- package/src/__tests__/tool-menu.test.jsx +61 -12
- package/src/__tests__/undo-redo.test.jsx +7 -8
- package/src/__tests__/utils.js +3 -0
- package/src/axis/__tests__/arrow.test.jsx +16 -17
- package/src/axis/__tests__/axes.test.jsx +118 -122
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +45 -55
- package/src/coordinates-label.jsx +14 -18
- package/src/graph-with-controls.jsx +52 -59
- package/src/grid-setup.jsx +203 -205
- package/src/grid.jsx +2 -4
- package/src/key-legend.jsx +52 -56
- package/src/labels.jsx +24 -31
- package/src/mark-label.jsx +92 -81
- package/src/toggle-bar.jsx +135 -164
- package/src/tool-menu.jsx +1 -1
- package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
- package/src/tools/circle/__tests__/component.test.jsx +17 -189
- package/src/tools/circle/bg-circle.jsx +20 -28
- package/src/tools/circle/component.jsx +28 -63
- package/src/tools/line/__tests__/component.test.jsx +7 -7
- package/src/tools/line/component.jsx +22 -15
- package/src/tools/point/__tests__/component.test.jsx +18 -43
- package/src/tools/point/component.jsx +1 -1
- package/src/tools/polygon/__tests__/component.test.jsx +18 -162
- package/src/tools/polygon/__tests__/line.test.jsx +7 -10
- package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
- package/src/tools/polygon/component.jsx +3 -4
- package/src/tools/polygon/line.jsx +30 -33
- package/src/tools/polygon/polygon.jsx +52 -45
- package/src/tools/ray/__tests__/component.test.jsx +7 -8
- package/src/tools/ray/component.jsx +38 -25
- package/src/tools/segment/__tests__/component.test.jsx +7 -8
- package/src/tools/segment/component.jsx +19 -18
- package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
- package/src/tools/shared/arrow-head.jsx +60 -7
- package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
- package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
- package/src/tools/shared/icons/MissingSVG.jsx +10 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
- package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
- package/src/tools/shared/line/index.jsx +52 -7
- package/src/tools/shared/line/line-path.jsx +55 -59
- package/src/tools/shared/line/with-root-edge.jsx +1 -1
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
- package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
- package/src/tools/shared/point/arrow-point.jsx +10 -24
- package/src/tools/shared/point/arrow.jsx +5 -11
- package/src/tools/shared/point/base-point.jsx +42 -19
- package/src/tools/shared/point/index.jsx +27 -44
- package/src/tools/vector/__tests__/component.test.jsx +7 -8
- package/src/tools/vector/component.jsx +11 -16
- package/src/undo-redo.jsx +19 -21
- package/esm/index.css +0 -847
- package/esm/index.js +0 -239949
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -3
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
- package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
- package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
- package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
- package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
- package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
- package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
|
@@ -10,6 +10,43 @@ import MarkLabel from '../../../mark-label';
|
|
|
10
10
|
import isEmpty from 'lodash/isEmpty';
|
|
11
11
|
import { color } from '@pie-lib/render-ui';
|
|
12
12
|
import { getMiddleOfTwoPoints, equalPoints, sameAxes } from '../../../utils';
|
|
13
|
+
import { styled } from '@mui/material/styles';
|
|
14
|
+
|
|
15
|
+
const StyledLineGroup = styled('g')(({ disabled, correctness }) => ({
|
|
16
|
+
'& line': {
|
|
17
|
+
fill: 'transparent',
|
|
18
|
+
stroke: color.defaults.BLACK,
|
|
19
|
+
strokeWidth: 3,
|
|
20
|
+
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
21
|
+
'&:hover': {
|
|
22
|
+
strokeWidth: 6,
|
|
23
|
+
stroke: color.defaults.PRIMARY_DARK,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
...(disabled && {
|
|
27
|
+
'& line': {
|
|
28
|
+
...disabledSecondary('stroke'),
|
|
29
|
+
strokeWidth: 2,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
...(correctness === 'correct' && {
|
|
33
|
+
'& line': {
|
|
34
|
+
...correct('stroke'),
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
...(correctness === 'incorrect' && {
|
|
38
|
+
'& line': {
|
|
39
|
+
...incorrect('stroke'),
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
...(correctness === 'missing' && {
|
|
43
|
+
'& line': {
|
|
44
|
+
...missing('stroke'),
|
|
45
|
+
strokeWidth: 1,
|
|
46
|
+
strokeDasharray: '4 3',
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
}));
|
|
13
50
|
|
|
14
51
|
export const lineTool = (type, Component) => () => ({
|
|
15
52
|
type,
|
|
@@ -40,6 +77,13 @@ export const lineToolComponent = (Component) => {
|
|
|
40
77
|
static propTypes = {
|
|
41
78
|
...types.ToolPropTypeFields,
|
|
42
79
|
graphProps: types.GraphPropsType.isRequired,
|
|
80
|
+
limitLabeling: PropTypes.bool,
|
|
81
|
+
changeMarkProps: PropTypes.func,
|
|
82
|
+
disabled: PropTypes.bool,
|
|
83
|
+
from: types.PointType,
|
|
84
|
+
to: types.PointType,
|
|
85
|
+
labelModeEnabled: PropTypes.bool,
|
|
86
|
+
onClick: PropTypes.func,
|
|
43
87
|
};
|
|
44
88
|
|
|
45
89
|
constructor(props) {
|
|
@@ -181,9 +225,10 @@ export const lineBase = (Comp, opts) => {
|
|
|
181
225
|
onClick: PropTypes.func,
|
|
182
226
|
correctness: PropTypes.string,
|
|
183
227
|
disabled: PropTypes.bool,
|
|
184
|
-
|
|
185
|
-
labelModeEnabled: PropTypes.bool,
|
|
228
|
+
limitLabeling: PropTypes.bool,
|
|
186
229
|
changeMarkProps: PropTypes.func,
|
|
230
|
+
labelModeEnabled: PropTypes.bool,
|
|
231
|
+
labelNode: PropTypes.object,
|
|
187
232
|
};
|
|
188
233
|
|
|
189
234
|
onChangePoint = (point) => {
|
|
@@ -309,7 +354,7 @@ export const lineBase = (Comp, opts) => {
|
|
|
309
354
|
let lineLabelNode = null;
|
|
310
355
|
|
|
311
356
|
if (labelNode) {
|
|
312
|
-
if (from &&
|
|
357
|
+
if (from && Object.prototype.hasOwnProperty.call(from, 'label')) {
|
|
313
358
|
fromLabelNode = ReactDOM.createPortal(
|
|
314
359
|
<MarkLabel
|
|
315
360
|
inputRef={(r) => (this.input.from = r)}
|
|
@@ -322,7 +367,7 @@ export const lineBase = (Comp, opts) => {
|
|
|
322
367
|
);
|
|
323
368
|
}
|
|
324
369
|
|
|
325
|
-
if (to &&
|
|
370
|
+
if (to && Object.prototype.hasOwnProperty.call(to, 'label')) {
|
|
326
371
|
toLabelNode = ReactDOM.createPortal(
|
|
327
372
|
<MarkLabel
|
|
328
373
|
inputRef={(r) => (this.input.to = r)}
|
|
@@ -335,7 +380,7 @@ export const lineBase = (Comp, opts) => {
|
|
|
335
380
|
);
|
|
336
381
|
}
|
|
337
382
|
|
|
338
|
-
if (middle &&
|
|
383
|
+
if (middle && Object.prototype.hasOwnProperty.call(middle, 'label')) {
|
|
339
384
|
lineLabelNode = ReactDOM.createPortal(
|
|
340
385
|
<MarkLabel
|
|
341
386
|
inputRef={(r) => (this.input.middle = r)}
|
|
@@ -350,7 +395,7 @@ export const lineBase = (Comp, opts) => {
|
|
|
350
395
|
}
|
|
351
396
|
|
|
352
397
|
return (
|
|
353
|
-
<
|
|
398
|
+
<StyledLineGroup disabled={disabled} correctness={correctness}>
|
|
354
399
|
{to && (
|
|
355
400
|
<DraggableComp
|
|
356
401
|
from={from}
|
|
@@ -387,7 +432,7 @@ export const lineBase = (Comp, opts) => {
|
|
|
387
432
|
/>
|
|
388
433
|
)}
|
|
389
434
|
{toLabelNode}
|
|
390
|
-
</
|
|
435
|
+
</StyledLineGroup>
|
|
391
436
|
);
|
|
392
437
|
}
|
|
393
438
|
}
|
|
@@ -1,16 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { types } from '@pie-lib/plot';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
5
|
import { disabled, correct, incorrect, missing, disabledSecondary } from '../styles';
|
|
7
|
-
import * as vx from '@
|
|
6
|
+
import * as vx from '@visx/shape';
|
|
8
7
|
import { color } from '@pie-lib/render-ui';
|
|
9
8
|
|
|
9
|
+
const dragging = () => ({
|
|
10
|
+
strokeWidth: 4,
|
|
11
|
+
stroke: color.defaults.BLACK,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const StyledDrawLine = styled(vx.LinePath)(({ disabled: isDisabled, correctness }) => ({
|
|
15
|
+
fill: 'none',
|
|
16
|
+
strokeWidth: 2,
|
|
17
|
+
stroke: color.black(),
|
|
18
|
+
...(isDisabled && {
|
|
19
|
+
...disabledSecondary('stroke'),
|
|
20
|
+
strokeWidth: 2,
|
|
21
|
+
}),
|
|
22
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
23
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
24
|
+
...(correctness === 'missing' && {
|
|
25
|
+
...missing('stroke'),
|
|
26
|
+
strokeWidth: 1,
|
|
27
|
+
strokeDasharray: '4 3',
|
|
28
|
+
}),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const StyledLine = styled(vx.LinePath)(({ theme, disabled: isDisabled, correctness, isDragging }) => ({
|
|
32
|
+
strokeWidth: 3,
|
|
33
|
+
fill: 'none',
|
|
34
|
+
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
35
|
+
stroke: 'transparent',
|
|
36
|
+
'&:hover': dragging(theme),
|
|
37
|
+
...(isDragging && dragging(theme)),
|
|
38
|
+
...(isDisabled && {
|
|
39
|
+
...disabled('stroke'),
|
|
40
|
+
strokeWidth: 2,
|
|
41
|
+
}),
|
|
42
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
43
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
44
|
+
...(correctness === 'missing' && {
|
|
45
|
+
...missing('stroke'),
|
|
46
|
+
strokeWidth: 1,
|
|
47
|
+
strokeDasharray: '4 3',
|
|
48
|
+
}),
|
|
49
|
+
}));
|
|
50
|
+
|
|
10
51
|
export class RawLinePath extends React.Component {
|
|
11
52
|
static propTypes = {
|
|
12
53
|
className: PropTypes.string,
|
|
13
|
-
classes: PropTypes.object,
|
|
14
54
|
data: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
|
|
15
55
|
graphProps: types.GraphPropsType.isRequired,
|
|
16
56
|
disabled: PropTypes.bool,
|
|
@@ -27,30 +67,24 @@ export class RawLinePath extends React.Component {
|
|
|
27
67
|
|
|
28
68
|
render() {
|
|
29
69
|
/* eslint-disable no-unused-vars */
|
|
30
|
-
const { data,
|
|
70
|
+
const { data, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
|
|
31
71
|
/* eslint-enable */
|
|
32
72
|
|
|
33
73
|
return (
|
|
34
74
|
<React.Fragment>
|
|
35
|
-
<
|
|
75
|
+
<StyledDrawLine
|
|
36
76
|
data={data}
|
|
37
|
-
className={
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
classes[correctness],
|
|
41
|
-
className,
|
|
42
|
-
)}
|
|
77
|
+
className={className}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
correctness={correctness}
|
|
43
80
|
{...rest}
|
|
44
81
|
/>
|
|
45
|
-
<
|
|
82
|
+
<StyledLine
|
|
46
83
|
data={data}
|
|
47
|
-
className={
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
classes[correctness],
|
|
52
|
-
className,
|
|
53
|
-
)}
|
|
84
|
+
className={className}
|
|
85
|
+
isDragging={isDragging}
|
|
86
|
+
disabled={disabled}
|
|
87
|
+
correctness={correctness}
|
|
54
88
|
{...rest}
|
|
55
89
|
/>
|
|
56
90
|
</React.Fragment>
|
|
@@ -58,42 +92,4 @@ export class RawLinePath extends React.Component {
|
|
|
58
92
|
}
|
|
59
93
|
}
|
|
60
94
|
|
|
61
|
-
const
|
|
62
|
-
strokeWidth: 4,
|
|
63
|
-
stroke: color.defaults.BLACK,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const LinePath = withStyles((theme) => ({
|
|
67
|
-
drawLine: {
|
|
68
|
-
fill: 'none',
|
|
69
|
-
strokeWidth: 2,
|
|
70
|
-
stroke: color.black(),
|
|
71
|
-
},
|
|
72
|
-
line: {
|
|
73
|
-
strokeWidth: 3,
|
|
74
|
-
fill: 'none',
|
|
75
|
-
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
76
|
-
stroke: 'transparent',
|
|
77
|
-
'&:hover': dragging(theme),
|
|
78
|
-
},
|
|
79
|
-
dragging: dragging(theme),
|
|
80
|
-
disabled: {
|
|
81
|
-
...disabled('stroke'),
|
|
82
|
-
strokeWidth: 2,
|
|
83
|
-
},
|
|
84
|
-
disabledSecondary: {
|
|
85
|
-
...disabledSecondary('stroke'),
|
|
86
|
-
strokeWidth: 2,
|
|
87
|
-
},
|
|
88
|
-
correct: {
|
|
89
|
-
...correct('stroke'),
|
|
90
|
-
},
|
|
91
|
-
incorrect: {
|
|
92
|
-
...incorrect('stroke'),
|
|
93
|
-
},
|
|
94
|
-
missing: {
|
|
95
|
-
...missing('stroke'),
|
|
96
|
-
strokeWidth: 1,
|
|
97
|
-
strokeDasharray: '4 3',
|
|
98
|
-
},
|
|
99
|
-
}))(RawLinePath);
|
|
95
|
+
export const LinePath = RawLinePath;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { types } from '@pie-lib/plot';
|
|
4
4
|
import { LinePath } from './line-path';
|
|
5
|
-
import { curveMonotoneX } from '@
|
|
5
|
+
import { curveMonotoneX } from '@visx/curve';
|
|
6
6
|
import { lineBase, lineToolComponent } from './index';
|
|
7
7
|
|
|
8
8
|
const toRootEdge = (m) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '@pie-lib/test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ArrowPoint } from '../index';
|
|
4
4
|
import { graphProps } from '../../../../__tests__/utils';
|
|
@@ -7,10 +7,12 @@ import { gridDraggable, utils } from '@pie-lib/plot';
|
|
|
7
7
|
|
|
8
8
|
const { xy } = utils;
|
|
9
9
|
jest.mock('../../../../utils', () => {
|
|
10
|
-
const { point } = jest.requireActual('../../../../utils');
|
|
10
|
+
const { point, getAngleDeg, arrowDimensions } = jest.requireActual('../../../../utils');
|
|
11
11
|
return {
|
|
12
12
|
bounds: jest.fn(),
|
|
13
13
|
point,
|
|
14
|
+
getAngleDeg,
|
|
15
|
+
arrowDimensions,
|
|
14
16
|
};
|
|
15
17
|
});
|
|
16
18
|
|
|
@@ -24,9 +26,8 @@ jest.mock('@pie-lib/plot', () => {
|
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
describe('ArrowPoint', () => {
|
|
27
|
-
let w;
|
|
28
29
|
let onChange = jest.fn();
|
|
29
|
-
const
|
|
30
|
+
const renderComponent = (extras) => {
|
|
30
31
|
const defaults = {
|
|
31
32
|
classes: {},
|
|
32
33
|
className: 'className',
|
|
@@ -34,17 +35,20 @@ describe('ArrowPoint', () => {
|
|
|
34
35
|
graphProps: graphProps(),
|
|
35
36
|
from: xy(0, 0),
|
|
36
37
|
to: xy(1, 1),
|
|
38
|
+
x: 0,
|
|
39
|
+
y: 0,
|
|
37
40
|
};
|
|
38
41
|
const props = { ...defaults, ...extras };
|
|
39
|
-
return
|
|
42
|
+
return render(<ArrowPoint {...props} />);
|
|
40
43
|
};
|
|
41
44
|
|
|
42
|
-
describe('
|
|
43
|
-
it('renders', () => {
|
|
44
|
-
|
|
45
|
-
expect(
|
|
45
|
+
describe('rendering', () => {
|
|
46
|
+
it('renders without crashing', () => {
|
|
47
|
+
const { container } = renderComponent();
|
|
48
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
46
49
|
});
|
|
47
50
|
});
|
|
51
|
+
|
|
48
52
|
describe('gridDraggable options', () => {
|
|
49
53
|
let opts;
|
|
50
54
|
let domain;
|
|
@@ -60,8 +64,8 @@ describe('ArrowPoint', () => {
|
|
|
60
64
|
max: 1,
|
|
61
65
|
step: 1,
|
|
62
66
|
};
|
|
63
|
-
|
|
64
|
-
opts = gridDraggable.mock.calls[
|
|
67
|
+
renderComponent();
|
|
68
|
+
opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
|
|
65
69
|
});
|
|
66
70
|
|
|
67
71
|
describe('bounds', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '@pie-lib/test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BasePoint } from '../index';
|
|
4
4
|
import { gridDraggable } from '@pie-lib/plot';
|
|
@@ -6,10 +6,11 @@ import { graphProps } from '../../../../__tests__/utils';
|
|
|
6
6
|
import { bounds } from '../../../../utils';
|
|
7
7
|
|
|
8
8
|
jest.mock('../../../../utils', () => {
|
|
9
|
-
const { point } = jest.requireActual('../../../../utils');
|
|
9
|
+
const { point, thinnerShapesNeeded } = jest.requireActual('../../../../utils');
|
|
10
10
|
return {
|
|
11
11
|
bounds: jest.fn(),
|
|
12
12
|
point,
|
|
13
|
+
thinnerShapesNeeded,
|
|
13
14
|
};
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -23,25 +24,27 @@ jest.mock('@pie-lib/plot', () => {
|
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
describe('BasePoint', () => {
|
|
26
|
-
let w;
|
|
27
27
|
let onChange = jest.fn();
|
|
28
|
-
const
|
|
28
|
+
const renderComponent = (extras) => {
|
|
29
29
|
const defaults = {
|
|
30
30
|
classes: {},
|
|
31
31
|
className: 'className',
|
|
32
32
|
onChange,
|
|
33
33
|
graphProps: graphProps(),
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
34
36
|
};
|
|
35
37
|
const props = { ...defaults, ...extras };
|
|
36
|
-
return
|
|
38
|
+
return render(<BasePoint {...props} />);
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
describe('
|
|
40
|
-
it('renders', () => {
|
|
41
|
-
|
|
42
|
-
expect(
|
|
41
|
+
describe('rendering', () => {
|
|
42
|
+
it('renders without crashing', () => {
|
|
43
|
+
const { container } = renderComponent();
|
|
44
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
43
45
|
});
|
|
44
46
|
});
|
|
47
|
+
|
|
45
48
|
describe('gridDraggable options', () => {
|
|
46
49
|
let opts;
|
|
47
50
|
let domain;
|
|
@@ -57,8 +60,8 @@ describe('BasePoint', () => {
|
|
|
57
60
|
max: 1,
|
|
58
61
|
step: 1,
|
|
59
62
|
};
|
|
60
|
-
|
|
61
|
-
opts = gridDraggable.mock.calls[
|
|
63
|
+
renderComponent();
|
|
64
|
+
opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
|
|
62
65
|
});
|
|
63
66
|
|
|
64
67
|
describe('bounds', () => {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
3
|
import { types } from '@pie-lib/plot';
|
|
5
|
-
import isEqual from 'lodash/isEqual';
|
|
6
4
|
import { getAngleDeg, arrowDimensions } from '../../../utils';
|
|
7
5
|
|
|
8
6
|
export class RawArrow extends React.Component {
|
|
9
7
|
static propTypes = {
|
|
10
|
-
classes: PropTypes.object,
|
|
11
8
|
className: PropTypes.string,
|
|
12
9
|
correctness: PropTypes.string,
|
|
13
10
|
disabled: PropTypes.bool,
|
|
14
|
-
x: PropTypes.number,
|
|
15
|
-
y: PropTypes.number,
|
|
11
|
+
x: PropTypes.number.isRequired,
|
|
12
|
+
y: PropTypes.number.isRequired,
|
|
16
13
|
from: PropTypes.shape({
|
|
17
14
|
x: PropTypes.number,
|
|
18
15
|
y: PropTypes.number,
|
|
@@ -30,32 +27,21 @@ export class RawArrow extends React.Component {
|
|
|
30
27
|
};
|
|
31
28
|
|
|
32
29
|
render() {
|
|
33
|
-
const {
|
|
34
|
-
// x & y are the initial coordinates for the arrow
|
|
35
|
-
// from & to are used only to calculate the angle that the arrow should be rotated with
|
|
36
|
-
|
|
30
|
+
const { className, x, y, graphProps, from, to, ...rest } = this.props;
|
|
37
31
|
const { scale } = graphProps;
|
|
38
|
-
const angle = getAngleDeg(from.x, from.y, to.x, to.y);
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
const angle = from && to ? getAngleDeg(from.x, from.y, to.x, to.y) : 0;
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-${arrowDimensions.vector},${arrowDimensions.vector * 2}`;
|
|
47
|
-
}
|
|
35
|
+
const points =
|
|
36
|
+
from && to && (from.x !== to.x || from.y !== to.y)
|
|
37
|
+
? `0,0 ${arrowDimensions.vector},${arrowDimensions.vector * 2} -${arrowDimensions.vector},${arrowDimensions.vector * 2}`
|
|
38
|
+
: '0,0 0,0 0,0';
|
|
48
39
|
|
|
49
40
|
return (
|
|
50
|
-
<g
|
|
51
|
-
className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
52
|
-
{...rest}
|
|
53
|
-
>
|
|
41
|
+
<g className={className} {...rest}>
|
|
54
42
|
<polygon
|
|
55
43
|
points={points}
|
|
56
|
-
transform={`
|
|
57
|
-
translate(${scale.x(x)}, ${scale.y(y)})
|
|
58
|
-
rotate(${angle} 0 0)`}
|
|
44
|
+
transform={`translate(${scale.x(x)}, ${scale.y(y)}) rotate(${angle} 0 0)`}
|
|
59
45
|
/>
|
|
60
46
|
</g>
|
|
61
47
|
);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
3
|
import { types } from '@pie-lib/plot';
|
|
5
4
|
import { ArrowHead } from '../arrow-head';
|
|
6
5
|
import { thinnerShapesNeeded } from '../../../utils';
|
|
7
6
|
|
|
8
|
-
export
|
|
7
|
+
export class BaseArrow extends React.Component {
|
|
9
8
|
static propTypes = {
|
|
10
|
-
classes: PropTypes.object,
|
|
11
9
|
className: PropTypes.string,
|
|
12
10
|
correctness: PropTypes.string,
|
|
13
11
|
disabled: PropTypes.bool,
|
|
@@ -18,8 +16,7 @@ export default class Arrow extends React.Component {
|
|
|
18
16
|
};
|
|
19
17
|
|
|
20
18
|
render() {
|
|
21
|
-
const {
|
|
22
|
-
|
|
19
|
+
const { className, angle, x, y, correctness, graphProps, ...rest } = this.props;
|
|
23
20
|
const size = thinnerShapesNeeded(graphProps) ? 12 : 14;
|
|
24
21
|
const { scale } = graphProps;
|
|
25
22
|
|
|
@@ -29,14 +26,11 @@ export default class Arrow extends React.Component {
|
|
|
29
26
|
const transform = `rotate(${-angle}, ${scaledX},${scaledY})`;
|
|
30
27
|
const points = `${scaledX},${scaledY}
|
|
31
28
|
${scaledX - size},${scaledY - size / 2}
|
|
32
|
-
${scaledX - size}
|
|
29
|
+
${scaledX - size},${scaledY + size / 2}`;
|
|
33
30
|
|
|
34
31
|
return (
|
|
35
|
-
<g
|
|
36
|
-
|
|
37
|
-
{...rest}
|
|
38
|
-
>
|
|
39
|
-
<ArrowHead size={size} transform={transform} points={points} />
|
|
32
|
+
<g className={className} {...rest}>
|
|
33
|
+
<ArrowHead size={size} transform={transform} points={points} correctness={correctness} />
|
|
40
34
|
</g>
|
|
41
35
|
);
|
|
42
36
|
}
|
|
@@ -1,35 +1,58 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
3
|
import { types } from '@pie-lib/plot';
|
|
5
|
-
import CoordinatesLabel from '../../../coordinates-label';
|
|
6
4
|
import ReactDOM from 'react-dom';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
|
|
7
|
+
import CoordinatesLabel from '../../../coordinates-label';
|
|
7
8
|
import { thinnerShapesNeeded } from '../../../utils';
|
|
8
9
|
import MissingSVG from '../icons/MissingSVG';
|
|
9
10
|
import CorrectSVG from '../icons/CorrectSVG';
|
|
10
11
|
import IncorrectSVG from '../icons/IncorrectSVG';
|
|
12
|
+
import * as styles from '../styles';
|
|
13
|
+
|
|
14
|
+
const StyledPointGroup = styled('g')(({ disabled, correctness }) => ({
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
'& circle': {
|
|
17
|
+
fill: 'currentColor',
|
|
18
|
+
},
|
|
19
|
+
...(disabled && {
|
|
20
|
+
...styles.disabled('fill'),
|
|
21
|
+
...styles.disabled('color'),
|
|
22
|
+
}),
|
|
23
|
+
...(correctness === 'correct' && {
|
|
24
|
+
...styles.correct('fill'),
|
|
25
|
+
...styles.correct('color'),
|
|
26
|
+
}),
|
|
27
|
+
...(correctness === 'incorrect' && {
|
|
28
|
+
...styles.incorrect('fill'),
|
|
29
|
+
...styles.incorrect('color'),
|
|
30
|
+
}),
|
|
31
|
+
...(correctness === 'missing' && {
|
|
32
|
+
...styles.missing('fill'),
|
|
33
|
+
...styles.missing('color'),
|
|
34
|
+
}),
|
|
35
|
+
}));
|
|
11
36
|
|
|
12
37
|
export class RawBp extends React.Component {
|
|
13
38
|
static propTypes = {
|
|
14
|
-
classes: PropTypes.object,
|
|
15
39
|
className: PropTypes.string,
|
|
16
40
|
coordinatesOnHover: PropTypes.bool,
|
|
17
41
|
correctness: PropTypes.string,
|
|
18
42
|
disabled: PropTypes.bool,
|
|
19
43
|
labelNode: PropTypes.object,
|
|
20
|
-
x: PropTypes.number,
|
|
21
|
-
y: PropTypes.number,
|
|
44
|
+
x: PropTypes.number.isRequired,
|
|
45
|
+
y: PropTypes.number.isRequired,
|
|
22
46
|
graphProps: types.GraphPropsType.isRequired,
|
|
47
|
+
onClick: PropTypes.func,
|
|
48
|
+
onTouchStart: PropTypes.func,
|
|
49
|
+
onTouchEnd: PropTypes.func,
|
|
23
50
|
};
|
|
24
51
|
|
|
25
|
-
|
|
26
|
-
super(props);
|
|
27
|
-
this.state = { showCoordinates: false };
|
|
28
|
-
}
|
|
52
|
+
state = { showCoordinates: false };
|
|
29
53
|
|
|
30
54
|
render() {
|
|
31
55
|
const {
|
|
32
|
-
classes,
|
|
33
56
|
className,
|
|
34
57
|
coordinatesOnHover,
|
|
35
58
|
x,
|
|
@@ -38,19 +61,16 @@ export class RawBp extends React.Component {
|
|
|
38
61
|
correctness,
|
|
39
62
|
graphProps,
|
|
40
63
|
labelNode,
|
|
41
|
-
// we need to remove style from props
|
|
42
|
-
// eslint-disable-next-line no-unused-vars,react/prop-types
|
|
43
|
-
style,
|
|
44
64
|
onClick,
|
|
45
|
-
// Refactored RawBp component by isolating onTouchStart and onTouchEnd handlers to the outer circle, resolving erratic touch event behavior.
|
|
46
|
-
// Remaining props are now applied only to the inner circle for improved event handling consistency.
|
|
47
65
|
onTouchStart,
|
|
48
66
|
onTouchEnd,
|
|
49
67
|
...rest
|
|
50
68
|
} = this.props;
|
|
69
|
+
|
|
51
70
|
const { showCoordinates } = this.state;
|
|
52
71
|
const { scale } = graphProps;
|
|
53
72
|
const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
|
|
73
|
+
|
|
54
74
|
let SvgComponent;
|
|
55
75
|
switch (correctness) {
|
|
56
76
|
case 'missing':
|
|
@@ -64,11 +84,11 @@ export class RawBp extends React.Component {
|
|
|
64
84
|
break;
|
|
65
85
|
default:
|
|
66
86
|
SvgComponent = null;
|
|
67
|
-
break;
|
|
68
87
|
}
|
|
69
88
|
|
|
70
89
|
return (
|
|
71
90
|
<>
|
|
91
|
+
{/* Outer invisible circle for easier touch/click */}
|
|
72
92
|
<circle
|
|
73
93
|
style={{ fill: 'transparent', cursor: 'pointer', pointerEvents: 'all' }}
|
|
74
94
|
r={r * 3}
|
|
@@ -80,8 +100,11 @@ export class RawBp extends React.Component {
|
|
|
80
100
|
onTouchEnd={onTouchEnd}
|
|
81
101
|
onClick={onClick}
|
|
82
102
|
/>
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
{/* Actual point */}
|
|
104
|
+
<StyledPointGroup
|
|
105
|
+
className={className}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
correctness={correctness}
|
|
85
108
|
onMouseEnter={() => this.setState({ showCoordinates: true })}
|
|
86
109
|
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
87
110
|
>
|
|
@@ -91,7 +114,7 @@ export class RawBp extends React.Component {
|
|
|
91
114
|
coordinatesOnHover &&
|
|
92
115
|
showCoordinates &&
|
|
93
116
|
ReactDOM.createPortal(<CoordinatesLabel graphProps={graphProps} x={x} y={y} />, labelNode)}
|
|
94
|
-
</
|
|
117
|
+
</StyledPointGroup>
|
|
95
118
|
</>
|
|
96
119
|
);
|
|
97
120
|
}
|