@pie-lib/graphing-solution-set 2.34.1 → 2.35.0-mui-update.0
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 +10 -15
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +101 -184
- 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 -60
- 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 +23 -55
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +132 -203
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +61 -126
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +161 -223
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +28 -73
- package/lib/grid.js.map +1 -1
- package/lib/index.js +1 -12
- package/lib/index.js.map +1 -1
- package/lib/labels.js +84 -184
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +40 -88
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +158 -242
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +93 -200
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/index.js +2 -7
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +48 -62
- 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/polygon/component.js +75 -172
- 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 -85
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +64 -102
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +7 -20
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +86 -182
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +70 -94
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +21 -55
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +18 -45
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +16 -42
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +22 -52
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +30 -52
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +8 -31
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +1 -5
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/undo-redo.js +27 -67
- 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 +56 -131
- package/lib/utils.js.map +1 -1
- package/package.json +16 -14
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +32 -37
- package/src/coordinates-label.jsx +13 -18
- package/src/graph-with-controls.jsx +90 -93
- package/src/grid-setup.jsx +204 -206
- package/src/grid.jsx +1 -3
- package/src/labels.jsx +83 -124
- package/src/mark-label.jsx +14 -25
- package/src/toggle-bar.jsx +155 -166
- package/src/tool-menu.jsx +136 -195
- package/src/tools/line/component.jsx +29 -29
- package/src/tools/polygon/component.jsx +1 -3
- package/src/tools/polygon/line.jsx +26 -24
- package/src/tools/polygon/polygon.jsx +34 -39
- package/src/tools/shared/line/line-path.jsx +50 -47
- package/src/tools/shared/point/index.jsx +22 -34
- package/src/undo-redo.jsx +16 -24
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
4
4
|
import { gridDraggable, types } from '@pie-lib/plot';
|
|
5
5
|
import * as utils from '../../utils';
|
|
6
|
-
import classNames from 'classnames';
|
|
7
6
|
import { color } from '@pie-lib/render-ui';
|
|
8
|
-
import { fade } from '@material-ui/core/styles/colorManipulator';
|
|
9
7
|
import { correct, disabled, incorrect } from '../shared/styles';
|
|
10
8
|
|
|
9
|
+
const StyledPolygon = styled('polygon', {
|
|
10
|
+
shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
|
|
11
|
+
})(({ theme, isSolution, correctness }) => ({
|
|
12
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
|
|
13
|
+
strokeWidth: 2,
|
|
14
|
+
stroke: color.defaults.SECONDARY_LIGHT,
|
|
15
|
+
'&:hover': {
|
|
16
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
|
|
17
|
+
},
|
|
18
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
19
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const StyledPolyline = styled('polyline', {
|
|
23
|
+
shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
|
|
24
|
+
})(({ theme, isSolution, correctness }) => ({
|
|
25
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
|
|
26
|
+
strokeWidth: 2,
|
|
27
|
+
stroke: color.defaults.SECONDARY_LIGHT,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
|
|
30
|
+
},
|
|
31
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
32
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
33
|
+
}));
|
|
34
|
+
|
|
11
35
|
export const getPointString = (points, scale) => {
|
|
12
36
|
return (points || [])
|
|
13
37
|
.map((p) => {
|
|
@@ -22,7 +46,6 @@ export const getPointString = (points, scale) => {
|
|
|
22
46
|
|
|
23
47
|
export class RawPolygon extends React.Component {
|
|
24
48
|
static propTypes = {
|
|
25
|
-
classes: PropTypes.object,
|
|
26
49
|
className: PropTypes.string,
|
|
27
50
|
isSolution: PropTypes.bool,
|
|
28
51
|
points: PropTypes.arrayOf(types.PointType),
|
|
@@ -36,52 +59,24 @@ export class RawPolygon extends React.Component {
|
|
|
36
59
|
};
|
|
37
60
|
|
|
38
61
|
render() {
|
|
39
|
-
const { points,
|
|
62
|
+
const { points, className, correctness, graphProps, closed, isSolution, ...rest } = this.props;
|
|
40
63
|
const { scale } = graphProps;
|
|
41
64
|
|
|
42
65
|
const pointString = getPointString(points, scale);
|
|
43
|
-
const
|
|
66
|
+
const Component = closed ? StyledPolygon : StyledPolyline;
|
|
44
67
|
return (
|
|
45
|
-
<
|
|
68
|
+
<Component
|
|
46
69
|
points={pointString}
|
|
47
|
-
|
|
70
|
+
isSolution={isSolution}
|
|
71
|
+
correctness={correctness}
|
|
72
|
+
className={className}
|
|
48
73
|
{...rest}
|
|
49
74
|
/>
|
|
50
75
|
);
|
|
51
76
|
}
|
|
52
77
|
}
|
|
53
78
|
|
|
54
|
-
export const Polygon =
|
|
55
|
-
closed: {
|
|
56
|
-
fill: fade(theme.palette.primary.light, 0.2), // TODO hardcoded color
|
|
57
|
-
strokeWidth: 2,
|
|
58
|
-
stroke: color.defaults.SECONDARY_LIGHT,
|
|
59
|
-
},
|
|
60
|
-
open: {
|
|
61
|
-
fill: fade(theme.palette.primary.light, 0.0), // TODO hardcoded color
|
|
62
|
-
strokeWidth: 2,
|
|
63
|
-
stroke: color.defaults.SECONDARY_LIGHT,
|
|
64
|
-
pointerEvents: 'none',
|
|
65
|
-
},
|
|
66
|
-
gssClosed: {
|
|
67
|
-
fill: 'transparent',
|
|
68
|
-
'&:hover': {
|
|
69
|
-
fill: 'rgb(0, 0, 0, 0.25)',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
gssSolution: {
|
|
73
|
-
fill: 'rgb(60, 73, 150, 0.6)',
|
|
74
|
-
},
|
|
75
|
-
disabled: {
|
|
76
|
-
...disabled('stroke'),
|
|
77
|
-
},
|
|
78
|
-
correct: {
|
|
79
|
-
...correct('stroke'),
|
|
80
|
-
},
|
|
81
|
-
incorrect: {
|
|
82
|
-
...incorrect('stroke'),
|
|
83
|
-
},
|
|
84
|
-
}))(RawPolygon);
|
|
79
|
+
export const Polygon = RawPolygon;
|
|
85
80
|
|
|
86
81
|
export default gridDraggable({
|
|
87
82
|
bounds: (props, { domain, range }) => {
|
|
@@ -1,16 +1,52 @@
|
|
|
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 } from '../styles';
|
|
7
6
|
import * as vx from '@vx/shape';
|
|
8
7
|
import { color } from '@pie-lib/render-ui';
|
|
9
8
|
|
|
9
|
+
const dragging = () => ({
|
|
10
|
+
strokeWidth: 7,
|
|
11
|
+
stroke: color.defaults.BLACK,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const StyledDrawLine = styled(vx.LinePath, {
|
|
15
|
+
shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
|
|
16
|
+
})(({ disabled: isDisabled, correctness }) => ({
|
|
17
|
+
fill: 'none',
|
|
18
|
+
strokeWidth: 2,
|
|
19
|
+
stroke: color.secondaryLight(),
|
|
20
|
+
...(isDisabled && {
|
|
21
|
+
...disabled('stroke'),
|
|
22
|
+
strokeWidth: 2,
|
|
23
|
+
}),
|
|
24
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
25
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
26
|
+
...(correctness === 'missing' && missing('stroke')),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const StyledInteractionLine = styled(vx.LinePath, {
|
|
30
|
+
shouldForwardProp: (prop) => !['disabled', 'correctness', 'isDragging'].includes(prop),
|
|
31
|
+
})(({ disabled: isDisabled, correctness, isDragging }) => ({
|
|
32
|
+
strokeWidth: 6,
|
|
33
|
+
fill: 'none',
|
|
34
|
+
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
35
|
+
stroke: 'transparent',
|
|
36
|
+
'&:hover': dragging(),
|
|
37
|
+
...(isDragging && dragging()),
|
|
38
|
+
...(isDisabled && {
|
|
39
|
+
...disabled('stroke'),
|
|
40
|
+
strokeWidth: 2,
|
|
41
|
+
}),
|
|
42
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
43
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
44
|
+
...(correctness === 'missing' && missing('stroke')),
|
|
45
|
+
}));
|
|
46
|
+
|
|
10
47
|
export class RawLinePath extends React.Component {
|
|
11
48
|
static propTypes = {
|
|
12
49
|
className: PropTypes.string,
|
|
13
|
-
classes: PropTypes.object,
|
|
14
50
|
data: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
|
|
15
51
|
graphProps: types.GraphPropsType.isRequired,
|
|
16
52
|
disabled: PropTypes.bool,
|
|
@@ -27,25 +63,24 @@ export class RawLinePath extends React.Component {
|
|
|
27
63
|
|
|
28
64
|
render() {
|
|
29
65
|
/* eslint-disable no-unused-vars */
|
|
30
|
-
const { data,
|
|
66
|
+
const { data, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
|
|
31
67
|
/* eslint-enable */
|
|
32
68
|
|
|
33
69
|
return (
|
|
34
70
|
<React.Fragment>
|
|
35
|
-
<
|
|
71
|
+
<StyledDrawLine
|
|
36
72
|
data={data}
|
|
37
|
-
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
correctness={correctness}
|
|
75
|
+
className={className}
|
|
38
76
|
{...rest}
|
|
39
77
|
/>
|
|
40
|
-
<
|
|
78
|
+
<StyledInteractionLine
|
|
41
79
|
data={data}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
classes[correctness],
|
|
47
|
-
className,
|
|
48
|
-
)}
|
|
80
|
+
isDragging={isDragging}
|
|
81
|
+
disabled={disabled}
|
|
82
|
+
correctness={correctness}
|
|
83
|
+
className={className}
|
|
49
84
|
{...rest}
|
|
50
85
|
/>
|
|
51
86
|
</React.Fragment>
|
|
@@ -53,36 +88,4 @@ export class RawLinePath extends React.Component {
|
|
|
53
88
|
}
|
|
54
89
|
}
|
|
55
90
|
|
|
56
|
-
const
|
|
57
|
-
strokeWidth: 7,
|
|
58
|
-
stroke: color.defaults.BLACK,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export const LinePath = withStyles((theme) => ({
|
|
62
|
-
drawLine: {
|
|
63
|
-
fill: 'none',
|
|
64
|
-
strokeWidth: 2,
|
|
65
|
-
stroke: color.secondaryLight(),
|
|
66
|
-
},
|
|
67
|
-
line: {
|
|
68
|
-
strokeWidth: 6,
|
|
69
|
-
fill: 'none',
|
|
70
|
-
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
71
|
-
stroke: 'transparent',
|
|
72
|
-
'&:hover': dragging(theme),
|
|
73
|
-
},
|
|
74
|
-
dragging: dragging(theme),
|
|
75
|
-
disabled: {
|
|
76
|
-
...disabled('stroke'),
|
|
77
|
-
strokeWidth: 2,
|
|
78
|
-
},
|
|
79
|
-
correct: {
|
|
80
|
-
...correct('stroke'),
|
|
81
|
-
},
|
|
82
|
-
incorrect: {
|
|
83
|
-
...incorrect('stroke'),
|
|
84
|
-
},
|
|
85
|
-
missing: {
|
|
86
|
-
...missing('stroke'),
|
|
87
|
-
},
|
|
88
|
-
}))(RawLinePath);
|
|
91
|
+
export const LinePath = RawLinePath;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
2
|
import { gridDraggable } from '@pie-lib/plot';
|
|
3
3
|
import * as utils from '../../../utils';
|
|
4
4
|
import { disabled, correct, incorrect, missing } from '../styles';
|
|
@@ -24,37 +24,25 @@ const opts = {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
incorrect: {
|
|
46
|
-
'& circle, & polygon': {
|
|
47
|
-
...incorrect(),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
missing: {
|
|
51
|
-
'& circle, & polygon': {
|
|
52
|
-
...missing(),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
};
|
|
27
|
+
const StyledPointWrapper = styled('g', {
|
|
28
|
+
shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
|
|
29
|
+
})(({ disabled: isDisabled, correctness }) => ({
|
|
30
|
+
'& circle, & polygon': {
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
fill: color.defaults.SECONDARY,
|
|
33
|
+
...(isDisabled && disabled()),
|
|
34
|
+
...(correctness === 'correct' && correct()),
|
|
35
|
+
...(correctness === 'incorrect' && incorrect()),
|
|
36
|
+
...(correctness === 'missing' && missing()),
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
const withStyledWrapper = (WrappedComponent) => (props) => (
|
|
41
|
+
<StyledPointWrapper disabled={props.disabled} correctness={props.correctness}>
|
|
42
|
+
<WrappedComponent {...props} />
|
|
43
|
+
</StyledPointWrapper>
|
|
44
|
+
);
|
|
57
45
|
|
|
58
|
-
export const BasePoint =
|
|
59
|
-
export const ArrowPoint =
|
|
60
|
-
export const Arrow =
|
|
46
|
+
export const BasePoint = gridDraggable(opts)(withStyledWrapper(RawBp));
|
|
47
|
+
export const ArrowPoint = gridDraggable(opts)(withStyledWrapper(RawArrow));
|
|
48
|
+
export const Arrow = gridDraggable(opts)(withStyledWrapper(BaseArrow));
|
package/src/undo-redo.jsx
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import Button from '@material
|
|
5
|
-
import { withStyles } from '@material-ui/core';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
6
5
|
import { color } from '@pie-lib/render-ui';
|
|
7
6
|
import Translator from '@pie-lib/translator';
|
|
8
7
|
|
|
9
8
|
const { translator } = Translator;
|
|
10
9
|
|
|
10
|
+
const StyledButton = styled(Button)(({ theme }) => ({
|
|
11
|
+
color: color.text(),
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
marginBottom: theme.spacing(0.5),
|
|
14
|
+
'&:not(:last-of-type)': {
|
|
15
|
+
marginRight: theme.spacing(0.5),
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
11
19
|
export class UndoRedo extends React.Component {
|
|
12
20
|
static propTypes = {
|
|
13
|
-
classes: PropTypes.object,
|
|
14
21
|
className: PropTypes.string,
|
|
15
22
|
onReset: PropTypes.func.isRequired,
|
|
16
23
|
language: PropTypes.string,
|
|
@@ -18,30 +25,15 @@ export class UndoRedo extends React.Component {
|
|
|
18
25
|
static defaultProps = {};
|
|
19
26
|
|
|
20
27
|
render() {
|
|
21
|
-
const {
|
|
28
|
+
const { className, onReset = false, language } = this.props;
|
|
22
29
|
return (
|
|
23
|
-
<div className={
|
|
24
|
-
<
|
|
30
|
+
<div className={className}>
|
|
31
|
+
<StyledButton onClick={() => onReset()}>
|
|
25
32
|
{translator.t('graphing.reset', { lng: language })}
|
|
26
|
-
</
|
|
33
|
+
</StyledButton>
|
|
27
34
|
</div>
|
|
28
35
|
);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
button: {
|
|
34
|
-
color: color.text(),
|
|
35
|
-
fontWeight: 'bold',
|
|
36
|
-
marginBottom: theme.spacing.unit / 2,
|
|
37
|
-
'&:not(:last-of-type)': {
|
|
38
|
-
marginRight: theme.spacing.unit / 2,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
undoRedoDiv: {
|
|
42
|
-
display: 'flex',
|
|
43
|
-
flexDirection: 'row',
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export default withStyles(styles)(UndoRedo);
|
|
39
|
+
export default UndoRedo;
|