@pie-lib/graphing 2.34.2-next.0 → 2.36.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 +16 -6
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +104 -186
- 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 +23 -55
- 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 +174 -224
- 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 -13
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +41 -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 +61 -119
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +113 -163
- 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 +16 -48
- 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 +79 -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 +82 -183
- 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 +3 -8
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +3 -8
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +3 -8
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/index.js +126 -187
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +70 -100
- 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 +23 -62
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +24 -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 +16 -13
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +40 -45
- package/src/coordinates-label.jsx +13 -18
- package/src/graph-with-controls.jsx +52 -59
- package/src/grid-setup.jsx +210 -206
- package/src/grid.jsx +1 -3
- package/src/key-legend.jsx +52 -56
- package/src/labels.jsx +21 -30
- package/src/mark-label.jsx +83 -81
- package/src/toggle-bar.jsx +155 -166
- package/src/tools/circle/bg-circle.jsx +20 -28
- package/src/tools/circle/component.jsx +28 -63
- package/src/tools/line/component.jsx +22 -15
- package/src/tools/polygon/component.jsx +1 -2
- package/src/tools/polygon/line.jsx +28 -32
- package/src/tools/polygon/polygon.jsx +52 -45
- package/src/tools/ray/component.jsx +38 -25
- package/src/tools/segment/component.jsx +19 -18
- package/src/tools/shared/arrow-head.jsx +60 -7
- package/src/tools/shared/line/index.jsx +39 -2
- package/src/tools/shared/line/line-path.jsx +54 -58
- 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/component.jsx +11 -16
- package/src/undo-redo.jsx +19 -21
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
2
3
|
import { gridDraggable } from '@pie-lib/plot';
|
|
3
4
|
import * as utils from '../../../utils';
|
|
4
|
-
import { disabled, correct, incorrect, missing, disabledSecondary } from '../styles';
|
|
5
5
|
import { RawBp } from './base-point';
|
|
6
6
|
import { RawArrow } from './arrow-point';
|
|
7
|
-
import {
|
|
8
|
-
import BaseArrow from './arrow';
|
|
7
|
+
import { BaseArrow } from './arrow';
|
|
9
8
|
|
|
9
|
+
// Drag & bounds options
|
|
10
10
|
const opts = {
|
|
11
11
|
bounds: (props, { domain, range }) => {
|
|
12
12
|
const { x, y } = props;
|
|
13
13
|
const area = { left: x, top: y, bottom: y, right: x };
|
|
14
|
-
|
|
15
14
|
return utils.bounds(area, domain, range);
|
|
16
15
|
},
|
|
17
16
|
anchorPoint: (props) => {
|
|
18
17
|
const { x, y } = props;
|
|
19
|
-
|
|
20
18
|
return { x, y };
|
|
21
19
|
},
|
|
22
20
|
fromDelta: (props, delta) => {
|
|
@@ -24,42 +22,27 @@ const opts = {
|
|
|
24
22
|
},
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
correct: {
|
|
46
|
-
'& circle, & polygon': {
|
|
47
|
-
...correct(),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
incorrect: {
|
|
51
|
-
'& circle, & polygon': {
|
|
52
|
-
...incorrect(),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
missing: {
|
|
56
|
-
'& circle, & polygon': {
|
|
57
|
-
...missing(),
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|
|
25
|
+
// Common styled point
|
|
26
|
+
const PointStyle = styled('g')(() => ({
|
|
27
|
+
'& circle, & polygon': {
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
export const BasePoint = gridDraggable(opts)((props) => (
|
|
33
|
+
<PointStyle {...props}>
|
|
34
|
+
<RawBp {...props} />
|
|
35
|
+
</PointStyle>
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
export const ArrowPoint = gridDraggable(opts)((props) => (
|
|
39
|
+
<PointStyle {...props}>
|
|
40
|
+
<RawArrow {...props} />
|
|
41
|
+
</PointStyle>
|
|
42
|
+
));
|
|
62
43
|
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
export const Arrow = gridDraggable(opts)((props) => (
|
|
45
|
+
<PointStyle {...props}>
|
|
46
|
+
<BaseArrow {...props} />
|
|
47
|
+
</PointStyle>
|
|
48
|
+
));
|
|
@@ -3,23 +3,18 @@ import { Arrow } from '../shared/point';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { types } from '@pie-lib/plot';
|
|
6
|
-
import
|
|
7
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
8
7
|
import { getDistanceBetweenTwoPoints } from '../../utils';
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
disabled
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
incorrect: styles.incorrect(theme, 'stroke'),
|
|
16
|
-
missing: styles.missing(theme, 'stroke'),
|
|
17
|
-
});
|
|
9
|
+
const StyledLine = styled('line')(({ theme, disabled, correctness }) => ({
|
|
10
|
+
...styles.line(theme),
|
|
11
|
+
...(disabled && styles.disabledSecondary(theme)),
|
|
12
|
+
...(correctness && styles[correctness] && styles[correctness](theme, 'stroke')),
|
|
13
|
+
}));
|
|
18
14
|
|
|
19
15
|
export const Line = (props) => {
|
|
20
16
|
const {
|
|
21
17
|
className,
|
|
22
|
-
classes,
|
|
23
18
|
disabled,
|
|
24
19
|
correctness,
|
|
25
20
|
graphProps: { scale },
|
|
@@ -32,8 +27,10 @@ export const Line = (props) => {
|
|
|
32
27
|
const length = getDistanceBetweenTwoPoints(startPoint, endPoint);
|
|
33
28
|
|
|
34
29
|
return (
|
|
35
|
-
<
|
|
36
|
-
className={
|
|
30
|
+
<StyledLine
|
|
31
|
+
className={className}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
correctness={correctness}
|
|
37
34
|
x1={startPoint.x}
|
|
38
35
|
y1={startPoint.y}
|
|
39
36
|
x2={endPoint.x}
|
|
@@ -46,7 +43,6 @@ export const Line = (props) => {
|
|
|
46
43
|
|
|
47
44
|
Line.propTypes = {
|
|
48
45
|
className: PropTypes.string,
|
|
49
|
-
classes: PropTypes.object,
|
|
50
46
|
disabled: PropTypes.bool,
|
|
51
47
|
correctness: PropTypes.string,
|
|
52
48
|
graphProps: PropTypes.any,
|
|
@@ -54,8 +50,7 @@ Line.propTypes = {
|
|
|
54
50
|
to: types.PointType,
|
|
55
51
|
};
|
|
56
52
|
|
|
57
|
-
const
|
|
58
|
-
const Vector = lineBase(StyledLine, { to: Arrow });
|
|
53
|
+
const Vector = lineBase(Line, { to: Arrow });
|
|
59
54
|
const Component = lineToolComponent(Vector);
|
|
60
55
|
|
|
61
56
|
export default Component;
|
package/src/undo-redo.jsx
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import Button from '@material
|
|
5
|
-
import {
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { color } from '@pie-lib/render-ui';
|
|
7
7
|
import Translator from '@pie-lib/translator';
|
|
8
8
|
|
|
9
9
|
const { translator } = Translator;
|
|
10
10
|
|
|
11
|
+
const StyledButton = styled(Button)(({ theme }) => ({
|
|
12
|
+
color: color.text(),
|
|
13
|
+
fontWeight: 'bold',
|
|
14
|
+
marginBottom: theme.spacing(0.5),
|
|
15
|
+
'&:not(:last-of-type)': {
|
|
16
|
+
marginRight: theme.spacing(0.5),
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
11
20
|
export class UndoRedo extends React.Component {
|
|
12
21
|
static propTypes = {
|
|
13
|
-
classes: PropTypes.object,
|
|
14
22
|
className: PropTypes.string,
|
|
15
23
|
onUndo: PropTypes.func.isRequired,
|
|
16
24
|
onRedo: PropTypes.func.isRequired,
|
|
@@ -20,31 +28,21 @@ export class UndoRedo extends React.Component {
|
|
|
20
28
|
static defaultProps = {};
|
|
21
29
|
|
|
22
30
|
render() {
|
|
23
|
-
const {
|
|
31
|
+
const { className, onUndo, onRedo, onReset, language } = this.props;
|
|
24
32
|
return (
|
|
25
33
|
<div className={classNames(className)}>
|
|
26
|
-
<
|
|
34
|
+
<StyledButton onClick={() => onUndo(true)}>
|
|
27
35
|
{translator.t('common:undo', { lng: language })}
|
|
28
|
-
</
|
|
29
|
-
<
|
|
36
|
+
</StyledButton>
|
|
37
|
+
<StyledButton onClick={() => onRedo(true)}>
|
|
30
38
|
{translator.t('graphing.redo', { lng: language })}
|
|
31
|
-
</
|
|
32
|
-
<
|
|
39
|
+
</StyledButton>
|
|
40
|
+
<StyledButton onClick={() => onReset()}>
|
|
33
41
|
{translator.t('graphing.reset', { lng: language })}
|
|
34
|
-
</
|
|
42
|
+
</StyledButton>
|
|
35
43
|
</div>
|
|
36
44
|
);
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
button: {
|
|
42
|
-
color: color.text(),
|
|
43
|
-
marginBottom: theme.spacing.unit / 2,
|
|
44
|
-
'&:not(:last-of-type)': {
|
|
45
|
-
marginRight: theme.spacing.unit / 2,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export default withStyles(styles)(UndoRedo);
|
|
48
|
+
export default UndoRedo;
|