@pie-lib/graphing 2.34.3-next.2 → 2.34.4-next.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 +6 -76
- package/lib/__tests__/graph-with-controls.test.js +226 -0
- package/lib/__tests__/graph.test.js +187 -0
- package/lib/__tests__/grid.test.js +29 -0
- package/lib/__tests__/labels.test.js +61 -0
- package/lib/__tests__/mark-label.test.js +133 -0
- package/lib/__tests__/toggle-bar.test.js +150 -0
- package/lib/__tests__/tool-menu.test.js +101 -0
- package/lib/__tests__/undo-redo.test.js +31 -0
- package/lib/__tests__/use-debounce.test.js +24 -0
- package/lib/__tests__/utils.js +70 -0
- package/lib/__tests__/utils.test.js +123 -0
- package/lib/axis/__tests__/arrow.test.js +60 -0
- package/lib/axis/__tests__/axes.test.js +195 -0
- package/lib/axis/arrow.js +20 -56
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +107 -195
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +2 -7
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +22 -50
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js +3 -9
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js +15 -60
- package/lib/container/index.js.map +1 -1
- package/lib/container/marks.js +2 -7
- package/lib/container/marks.js.map +1 -1
- package/lib/container/middleware.js +3 -9
- package/lib/container/middleware.js.map +1 -1
- package/lib/container/reducer.js +2 -9
- package/lib/container/reducer.js.map +1 -1
- package/lib/coordinates-label.js +25 -55
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +121 -185
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +60 -117
- 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 +30 -75
- package/lib/grid.js.map +1 -1
- package/lib/index.js +2 -14
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +41 -86
- package/lib/key-legend.js.map +1 -1
- package/lib/label-svg-icon.js +2 -8
- 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 +121 -164
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +156 -244
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +17 -51
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/__tests__/component.test.js +67 -0
- package/lib/tools/absolute/component.js +5 -11
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/absolute/index.js +4 -17
- package/lib/tools/absolute/index.js.map +1 -1
- package/lib/tools/circle/__tests__/bg-circle.test.js +33 -0
- package/lib/tools/circle/__tests__/component.test.js +68 -0
- package/lib/tools/circle/bg-circle.js +43 -93
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +79 -166
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +4 -14
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/exponential/__tests__/component.test.js +66 -0
- package/lib/tools/exponential/component.js +5 -11
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/exponential/index.js +4 -19
- package/lib/tools/exponential/index.js.map +1 -1
- package/lib/tools/index.js +4 -17
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/__tests__/component.test.js +45 -0
- package/lib/tools/line/component.js +28 -49
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/line/index.js +2 -7
- package/lib/tools/line/index.js.map +1 -1
- package/lib/tools/parabola/__tests__/component.test.js +66 -0
- package/lib/tools/parabola/component.js +5 -11
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +4 -17
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/__tests__/component.test.js +50 -0
- package/lib/tools/point/component.js +25 -72
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +4 -12
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/__tests__/component.test.js +85 -0
- package/lib/tools/polygon/__tests__/index.test.js +92 -0
- package/lib/tools/polygon/__tests__/line.test.js +29 -0
- package/lib/tools/polygon/__tests__/polygon.test.js +59 -0
- package/lib/tools/polygon/component.js +84 -185
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +7 -24
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +49 -92
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +66 -99
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/__tests__/component.test.js +35 -0
- package/lib/tools/ray/component.js +42 -61
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/ray/index.js +2 -7
- package/lib/tools/ray/index.js.map +1 -1
- package/lib/tools/segment/__tests__/component.test.js +35 -0
- package/lib/tools/segment/component.js +26 -44
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/segment/index.js +2 -7
- package/lib/tools/segment/index.js.map +1 -1
- package/lib/tools/shared/__tests__/arrow-head.test.js +45 -0
- package/lib/tools/shared/arrow-head.js +70 -29
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +13 -9
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +13 -9
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +13 -9
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/__tests__/index.test.js +124 -0
- package/lib/tools/shared/line/__tests__/line-path.test.js +62 -0
- package/lib/tools/shared/line/__tests__/with-root-edge.test.js +91 -0
- package/lib/tools/shared/line/index.js +141 -194
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +71 -102
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +23 -57
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/__tests__/arrow-point.test.js +127 -0
- package/lib/tools/shared/point/__tests__/base-point.test.js +122 -0
- package/lib/tools/shared/point/arrow-point.js +22 -63
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +24 -53
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +55 -73
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +23 -58
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +11 -39
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +3 -10
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/__tests__/component.test.js +72 -0
- package/lib/tools/sine/component.js +9 -20
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +4 -17
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/__tests__/component.test.js +32 -0
- package/lib/tools/vector/component.js +25 -45
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/tools/vector/index.js +2 -7
- package/lib/tools/vector/index.js.map +1 -1
- package/lib/undo-redo.js +30 -70
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +5 -12
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +52 -129
- 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 +210 -206
- package/src/grid.jsx +2 -4
- package/src/key-legend.jsx +52 -56
- package/src/labels.jsx +23 -30
- 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
package/src/key-legend.jsx
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { color } from '@pie-lib/render-ui';
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
title: {
|
|
20
|
-
fontSize: theme.typography.h6.fontSize,
|
|
21
|
-
marginLeft: '30px',
|
|
22
|
-
fontWeight: '700',
|
|
23
|
-
marginBottom: '10px',
|
|
24
|
-
},
|
|
25
|
-
text: {
|
|
26
|
-
textAlign: 'right',
|
|
27
|
-
marginRight: '10px',
|
|
28
|
-
width: '175px',
|
|
29
|
-
fontSize: '15px',
|
|
30
|
-
},
|
|
6
|
+
const StyledContainer = styled('div')(() => ({
|
|
7
|
+
backgroundColor: color.defaults.WHITE,
|
|
8
|
+
padding: '20px',
|
|
9
|
+
width: '355px',
|
|
10
|
+
boxShadow: '0px 1px 5px 0px #9297A6',
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const StyledRow = styled('div')({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
padding: '10px',
|
|
31
17
|
});
|
|
32
18
|
|
|
33
|
-
const
|
|
34
|
-
|
|
19
|
+
const StyledTitle = styled('div')(({ theme }) => ({
|
|
20
|
+
fontSize: theme.typography.h6.fontSize,
|
|
21
|
+
marginLeft: '30px',
|
|
22
|
+
fontWeight: '700',
|
|
23
|
+
marginBottom: '10px',
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const StyledText = styled('div')({
|
|
27
|
+
textAlign: 'right',
|
|
28
|
+
marginRight: '10px',
|
|
29
|
+
width: '175px',
|
|
30
|
+
fontSize: '15px',
|
|
31
|
+
});
|
|
35
32
|
|
|
33
|
+
const KeyLegend = ({ className, isLabelAvailable }) => {
|
|
36
34
|
return (
|
|
37
|
-
<
|
|
38
|
-
<
|
|
35
|
+
<StyledContainer className={className}>
|
|
36
|
+
<StyledTitle>Key</StyledTitle>
|
|
39
37
|
{isLabelAvailable && (
|
|
40
|
-
<
|
|
41
|
-
<
|
|
38
|
+
<StyledRow>
|
|
39
|
+
<StyledText> Missing Required Label </StyledText>
|
|
42
40
|
<svg width="34" height="16" viewBox="0 0 34 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
43
41
|
<rect x="0.5" y="0.5" width="33" height="15" rx="3.5" fill="white" stroke="#BF0D00" />
|
|
44
42
|
<path
|
|
@@ -50,10 +48,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
50
48
|
fill="#BF0D00"
|
|
51
49
|
/>
|
|
52
50
|
</svg>
|
|
53
|
-
</
|
|
51
|
+
</StyledRow>
|
|
54
52
|
)}
|
|
55
|
-
<
|
|
56
|
-
<
|
|
53
|
+
<StyledRow>
|
|
54
|
+
<StyledText> Answer Key Correct </StyledText>
|
|
57
55
|
<svg width="75" height="15" viewBox="0 0 75 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
58
56
|
<circle cx="7.5" cy="7.5" r="7.5" fill="#6A78A1" />
|
|
59
57
|
<path
|
|
@@ -62,10 +60,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
62
60
|
/>
|
|
63
61
|
<path d="M75 7L15 7" stroke="#6A78A1" strokeDasharray="4 2" />
|
|
64
62
|
</svg>
|
|
65
|
-
</
|
|
63
|
+
</StyledRow>
|
|
66
64
|
{isLabelAvailable && (
|
|
67
|
-
<
|
|
68
|
-
<
|
|
65
|
+
<StyledRow>
|
|
66
|
+
<StyledText> Answer Key Correct Label </StyledText>
|
|
69
67
|
<svg width="30" height="16" viewBox="0 0 30 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
70
68
|
<rect x="0.5" y="0.5" width="29" height="15" rx="3.5" fill="white" />
|
|
71
69
|
<rect x="0.5" y="0.5" width="29" height="15" rx="3.5" stroke="#6A78A1" />
|
|
@@ -74,10 +72,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
74
72
|
fill="#6A78A1"
|
|
75
73
|
/>
|
|
76
74
|
</svg>
|
|
77
|
-
</
|
|
75
|
+
</StyledRow>
|
|
78
76
|
)}
|
|
79
|
-
<
|
|
80
|
-
<
|
|
77
|
+
<StyledRow>
|
|
78
|
+
<StyledText> Student Incorrect </StyledText>
|
|
81
79
|
<svg width="77" height="16" viewBox="0 0 77 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
82
80
|
<circle cx="8" cy="8" r="8" fill="#BF0D00" />
|
|
83
81
|
<path
|
|
@@ -86,10 +84,10 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
86
84
|
/>
|
|
87
85
|
<path d="M77 8L15 8" stroke="#BF0D00" strokeWidth="3" />
|
|
88
86
|
</svg>
|
|
89
|
-
</
|
|
87
|
+
</StyledRow>
|
|
90
88
|
{isLabelAvailable && (
|
|
91
|
-
<
|
|
92
|
-
<
|
|
89
|
+
<StyledRow>
|
|
90
|
+
<StyledText> Incorrect Student Label </StyledText>
|
|
93
91
|
<svg width="42" height="16" viewBox="0 0 42 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
94
92
|
<rect x="0.5" y="0.5" width="41" height="15" rx="3.5" fill="white" />
|
|
95
93
|
<rect x="0.5" y="0.5" width="41" height="15" rx="3.5" stroke="#BF0D00" />
|
|
@@ -102,22 +100,21 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
102
100
|
fill="#BF0D00"
|
|
103
101
|
/>
|
|
104
102
|
</svg>
|
|
105
|
-
</
|
|
103
|
+
</StyledRow>
|
|
106
104
|
)}
|
|
107
|
-
<
|
|
108
|
-
<
|
|
105
|
+
<StyledRow>
|
|
106
|
+
<StyledText> Student Correct </StyledText>
|
|
109
107
|
<svg width="76" height="16" viewBox="0 0 76 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
110
108
|
<path d="M76 8L14 8" stroke="#0B7D38" strokeWidth="3" />
|
|
111
109
|
<circle cx="8" cy="8" r="8" fill="#0B7D38" />
|
|
112
110
|
<path
|
|
113
111
|
d="M12.1953 4.46875C12.3125 4.35156 12.5 4.35156 12.5938 4.46875L13.2734 5.125C13.3672 5.24219 13.3672 5.42969 13.2734 5.52344L6.24219 12.5547C6.125 12.6719 5.96094 12.6719 5.84375 12.5547L2.70312 9.4375C2.60938 9.32031 2.60938 9.13281 2.70312 9.03906L3.38281 8.35938C3.47656 8.26562 3.66406 8.26562 3.78125 8.35938L6.03125 10.6328L12.1953 4.46875Z"
|
|
114
112
|
fill="white"
|
|
115
|
-
/>
|
|
116
|
-
|
|
117
|
-
</div>
|
|
113
|
+
/> </svg>
|
|
114
|
+
</StyledRow>
|
|
118
115
|
{isLabelAvailable && (
|
|
119
|
-
<
|
|
120
|
-
<
|
|
116
|
+
<StyledRow>
|
|
117
|
+
<StyledText> Student Correct Label </StyledText>
|
|
121
118
|
<svg width="43" height="16" viewBox="0 0 43 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
122
119
|
<rect x="0.5" y="0.5" width="42" height="15" rx="3.5" fill="white" />
|
|
123
120
|
<rect x="0.5" y="0.5" width="42" height="15" rx="3.5" stroke="#0B7D38" />
|
|
@@ -130,16 +127,15 @@ const KeyLegend = ({ className, classes, isLabelAvailable }) => {
|
|
|
130
127
|
fill="#0B7D38"
|
|
131
128
|
/>
|
|
132
129
|
</svg>
|
|
133
|
-
</
|
|
130
|
+
</StyledRow>
|
|
134
131
|
)}
|
|
135
|
-
</
|
|
132
|
+
</StyledContainer>
|
|
136
133
|
);
|
|
137
134
|
};
|
|
138
135
|
|
|
139
136
|
KeyLegend.propTypes = {
|
|
140
137
|
className: PropTypes.string,
|
|
141
|
-
classes: PropTypes.object.isRequired,
|
|
142
138
|
isLabelAvailable: PropTypes.bool,
|
|
143
139
|
};
|
|
144
140
|
|
|
145
|
-
export default
|
|
141
|
+
export default KeyLegend;
|
package/src/labels.jsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
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 {
|
|
5
|
+
import { Readable } from '@pie-lib/render-ui';
|
|
6
6
|
import EditableHtml from '@pie-lib/editable-html';
|
|
7
|
-
import cn from 'classnames';
|
|
8
7
|
|
|
9
8
|
const rotations = {
|
|
10
9
|
left: -90,
|
|
@@ -43,15 +42,29 @@ const getY = (side, height) => {
|
|
|
43
42
|
}
|
|
44
43
|
};
|
|
45
44
|
|
|
45
|
+
const StyledEditableHtml = styled(EditableHtml, {
|
|
46
|
+
shouldForwardProp: (prop) => !['side', 'disabledLabel'].includes(prop),
|
|
47
|
+
})(({ theme, side, disabledLabel }) => ({
|
|
48
|
+
fontSize: theme.typography.fontSize - 2,
|
|
49
|
+
textAlign: 'center',
|
|
50
|
+
padding: '0 4px',
|
|
51
|
+
...(side === 'bottom' && {
|
|
52
|
+
marginTop: '44px',
|
|
53
|
+
}),
|
|
54
|
+
...(disabledLabel && {
|
|
55
|
+
pointerEvents: 'none',
|
|
56
|
+
}),
|
|
57
|
+
}));
|
|
58
|
+
|
|
46
59
|
class RawLabel extends React.Component {
|
|
47
60
|
static propTypes = {
|
|
48
61
|
text: PropTypes.string,
|
|
49
62
|
side: PropTypes.string,
|
|
50
|
-
classes: PropTypes.object,
|
|
51
63
|
disabledLabel: PropTypes.bool,
|
|
52
64
|
placeholder: PropTypes.string,
|
|
53
65
|
graphProps: types.GraphPropsType.isRequired,
|
|
54
66
|
onChange: PropTypes.func,
|
|
67
|
+
mathMlOptions: PropTypes.object,
|
|
55
68
|
};
|
|
56
69
|
|
|
57
70
|
static defaultProps = {
|
|
@@ -59,7 +72,7 @@ class RawLabel extends React.Component {
|
|
|
59
72
|
};
|
|
60
73
|
|
|
61
74
|
render() {
|
|
62
|
-
const { disabledLabel, placeholder, text, side, graphProps,
|
|
75
|
+
const { disabledLabel, placeholder, text, side, graphProps, onChange, mathMlOptions = {} } = this.props;
|
|
63
76
|
const { size, domain, range } = graphProps;
|
|
64
77
|
const totalHeight = (size.height || 500) + (range.padding || 0) * 2;
|
|
65
78
|
const totalWidth = (size.width || 500) + (domain.padding || 0) * 2;
|
|
@@ -89,14 +102,9 @@ class RawLabel extends React.Component {
|
|
|
89
102
|
textAnchor="middle"
|
|
90
103
|
>
|
|
91
104
|
<Readable false>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
[classes.bottomLabel]: side === 'bottom',
|
|
96
|
-
[classes.disabledAxisLabel]: disabledLabel,
|
|
97
|
-
},
|
|
98
|
-
classes.axisLabel,
|
|
99
|
-
)}
|
|
105
|
+
<StyledEditableHtml
|
|
106
|
+
side={side}
|
|
107
|
+
disabledLabel={disabledLabel}
|
|
100
108
|
markup={text || ''}
|
|
101
109
|
onChange={onChange}
|
|
102
110
|
placeholder={!disabledLabel && placeholder}
|
|
@@ -114,22 +122,7 @@ class RawLabel extends React.Component {
|
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
|
|
117
|
-
const Label =
|
|
118
|
-
label: {
|
|
119
|
-
fill: color.defaults.SECONDARY,
|
|
120
|
-
},
|
|
121
|
-
axisLabel: {
|
|
122
|
-
fontSize: theme.typography.fontSize - 2,
|
|
123
|
-
textAlign: 'center',
|
|
124
|
-
padding: '0 4px',
|
|
125
|
-
},
|
|
126
|
-
disabledAxisLabel: {
|
|
127
|
-
pointerEvents: 'none',
|
|
128
|
-
},
|
|
129
|
-
bottomLabel: {
|
|
130
|
-
marginTop: '44px',
|
|
131
|
-
},
|
|
132
|
-
}))(RawLabel);
|
|
125
|
+
const Label = RawLabel;
|
|
133
126
|
|
|
134
127
|
export const LabelType = {
|
|
135
128
|
left: PropTypes.string,
|
|
@@ -140,13 +133,13 @@ export const LabelType = {
|
|
|
140
133
|
|
|
141
134
|
export class Labels extends React.Component {
|
|
142
135
|
static propTypes = {
|
|
143
|
-
classes: PropTypes.object,
|
|
144
136
|
className: PropTypes.string,
|
|
145
137
|
disabledLabels: PropTypes.bool,
|
|
146
138
|
placeholders: PropTypes.object,
|
|
147
139
|
value: PropTypes.shape(LabelType),
|
|
148
140
|
graphProps: PropTypes.object,
|
|
149
141
|
onChange: PropTypes.object,
|
|
142
|
+
mathMlOptions: PropTypes.object,
|
|
150
143
|
};
|
|
151
144
|
|
|
152
145
|
static defaultProps = {};
|
package/src/mark-label.jsx
CHANGED
|
@@ -1,71 +1,75 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import cn from 'classnames';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
3
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
5
4
|
import AutosizeInput from 'react-input-autosize';
|
|
6
5
|
import { useDebounce } from './use-debounce';
|
|
7
6
|
import { types } from '@pie-lib/plot';
|
|
8
7
|
import { color } from '@pie-lib/render-ui';
|
|
9
8
|
import SvgIcon from './label-svg-icon';
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const StyledInputCorrect = styled('div')(({ theme }) => ({
|
|
12
11
|
float: 'right',
|
|
13
|
-
padding: theme.spacing
|
|
12
|
+
padding: theme.spacing(0.5),
|
|
14
13
|
borderRadius: '4px',
|
|
15
14
|
fontSize: '10px',
|
|
16
15
|
backgroundColor: color.defaults.WHITE,
|
|
16
|
+
color: color.defaults.CORRECT_WITH_ICON,
|
|
17
|
+
border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const StyledInputIncorrect = styled('div')(({ theme }) => ({
|
|
21
|
+
float: 'right',
|
|
22
|
+
padding: theme.spacing(0.5),
|
|
23
|
+
borderRadius: '4px',
|
|
24
|
+
fontSize: '10px',
|
|
25
|
+
backgroundColor: color.defaults.WHITE,
|
|
26
|
+
color: color.defaults.INCORRECT_WITH_ICON,
|
|
27
|
+
border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const StyledInputMissing = styled('div')(({ theme }) => ({
|
|
31
|
+
float: 'right',
|
|
32
|
+
padding: theme.spacing(0.5),
|
|
33
|
+
borderRadius: '4px',
|
|
34
|
+
fontSize: '10px',
|
|
35
|
+
backgroundColor: color.defaults.WHITE,
|
|
36
|
+
color: color.defaults.MISSING_WITH_ICON,
|
|
37
|
+
border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,
|
|
38
|
+
fontWeight: 'bold',
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const StyledIncorrect = styled('div')(() => ({
|
|
42
|
+
float: 'right',
|
|
43
|
+
padding: 0,
|
|
44
|
+
borderRadius: '4px',
|
|
45
|
+
fontSize: '10px',
|
|
46
|
+
backgroundColor: color.defaults.WHITE,
|
|
47
|
+
color: color.defaults.INCORRECT_WITH_ICON,
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const getInputStyles = (theme, disabled, markDisabled) => ({
|
|
52
|
+
float: 'right',
|
|
53
|
+
padding: theme.spacing(0.5),
|
|
54
|
+
fontFamily: theme.typography.fontFamily,
|
|
55
|
+
fontSize: '10px',
|
|
56
|
+
border: disabled
|
|
57
|
+
? `solid 1px ${color.defaults.PRIMARY_DARK}`
|
|
58
|
+
: markDisabled
|
|
59
|
+
? `solid 1px ${color.disabled()}`
|
|
60
|
+
: `solid 1px ${color.defaults.SECONDARY}`,
|
|
61
|
+
borderRadius: '3px',
|
|
62
|
+
color: markDisabled ? color.disabled() : color.defaults.PRIMARY_DARK,
|
|
63
|
+
backgroundColor: color.defaults.WHITE,
|
|
64
|
+
WebkitOpacity: disabled ? '1' : undefined,
|
|
65
|
+
WebkitTextFillColor: markDisabled ? color.disabled() : undefined,
|
|
17
66
|
});
|
|
18
67
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
color: 'inherit',
|
|
25
|
-
fontWeight: 'bold',
|
|
26
|
-
},
|
|
27
|
-
input: {
|
|
28
|
-
float: 'right',
|
|
29
|
-
padding: theme.spacing.unit * 0.5,
|
|
30
|
-
fontFamily: theme.typography.fontFamily,
|
|
31
|
-
fontSize: '10px',
|
|
32
|
-
border: `solid 1px ${color.defaults.SECONDARY}`,
|
|
33
|
-
borderRadius: '3px',
|
|
34
|
-
color: color.defaults.PRIMARY_DARK,
|
|
35
|
-
backgroundColor: color.defaults.WHITE,
|
|
36
|
-
},
|
|
37
|
-
disabled: {
|
|
38
|
-
border: `solid 1px ${color.defaults.PRIMARY_DARK}`,
|
|
39
|
-
backgroundColor: color.defaults.WHITE,
|
|
40
|
-
'-webkit-opacity': '1',
|
|
41
|
-
},
|
|
42
|
-
disabledMark: {
|
|
43
|
-
border: `solid 1px ${color.disabled()}`,
|
|
44
|
-
color: color.disabled(),
|
|
45
|
-
'-webkit-text-fill-color': color.disabled(),
|
|
46
|
-
},
|
|
47
|
-
inputCorrect: {
|
|
48
|
-
...inputStyles(theme),
|
|
49
|
-
color: color.defaults.CORRECT_WITH_ICON,
|
|
50
|
-
border: `solid 1px ${color.defaults.CORRECT_WITH_ICON}`,
|
|
51
|
-
},
|
|
52
|
-
inputIncorrect: {
|
|
53
|
-
...inputStyles(theme),
|
|
54
|
-
color: color.defaults.INCORRECT_WITH_ICON,
|
|
55
|
-
border: `solid 1px ${color.defaults.INCORRECT_WITH_ICON}`,
|
|
56
|
-
},
|
|
57
|
-
inputMissing: {
|
|
58
|
-
...inputStyles(theme),
|
|
59
|
-
color: color.defaults.MISSING_WITH_ICON,
|
|
60
|
-
border: `solid 1px ${color.defaults.MISSING_WITH_ICON}`,
|
|
61
|
-
fontWeight: 'bold',
|
|
62
|
-
},
|
|
63
|
-
incorrect: {
|
|
64
|
-
...inputStyles(theme),
|
|
65
|
-
color: color.defaults.INCORRECT_WITH_ICON,
|
|
66
|
-
fontWeight: 'bold',
|
|
67
|
-
padding: '0',
|
|
68
|
-
},
|
|
68
|
+
const getStudentInputStyles = () => ({
|
|
69
|
+
padding: '0',
|
|
70
|
+
border: 'none',
|
|
71
|
+
color: 'inherit',
|
|
72
|
+
fontWeight: 'bold',
|
|
69
73
|
});
|
|
70
74
|
|
|
71
75
|
export const position = (graphProps, mark, rect = { width: 0, height: 0 }) => {
|
|
@@ -99,24 +103,34 @@ export const coordinates = (graphProps, mark, rect = { width: 0, height: 0 }, po
|
|
|
99
103
|
}
|
|
100
104
|
};
|
|
101
105
|
|
|
102
|
-
const LabelInput = ({ _ref, externalInputRef, label, disabled,
|
|
106
|
+
const LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, onChange }) => (
|
|
103
107
|
<AutosizeInput
|
|
104
108
|
inputRef={(r) => {
|
|
105
109
|
_ref(r);
|
|
106
110
|
externalInputRef(r);
|
|
107
111
|
}}
|
|
108
112
|
disabled={disabled}
|
|
109
|
-
|
|
113
|
+
inputStyle={inputStyle}
|
|
110
114
|
value={label}
|
|
111
115
|
onChange={onChange}
|
|
112
116
|
/>
|
|
113
117
|
);
|
|
114
118
|
|
|
119
|
+
LabelInput.propTypes = {
|
|
120
|
+
_ref: PropTypes.func,
|
|
121
|
+
externalInputRef: PropTypes.func,
|
|
122
|
+
label: PropTypes.string,
|
|
123
|
+
disabled: PropTypes.bool,
|
|
124
|
+
inputStyle: PropTypes.object,
|
|
125
|
+
onChange: PropTypes.func,
|
|
126
|
+
};
|
|
127
|
+
|
|
115
128
|
export const MarkLabel = (props) => {
|
|
116
129
|
const [input, setInput] = useState(null);
|
|
117
130
|
const _ref = useCallback((node) => setInput(node));
|
|
131
|
+
const theme = useTheme();
|
|
118
132
|
|
|
119
|
-
const { mark, graphProps,
|
|
133
|
+
const { mark, graphProps, disabled, inputRef: externalInputRef } = props;
|
|
120
134
|
|
|
121
135
|
const [label, setLabel] = useState(mark.label);
|
|
122
136
|
const { correctness, correctnesslabel, correctlabel } = mark;
|
|
@@ -156,23 +170,25 @@ export const MarkLabel = (props) => {
|
|
|
156
170
|
|
|
157
171
|
const disabledInput = disabled || mark.disabled;
|
|
158
172
|
|
|
159
|
-
const renderInput = (
|
|
173
|
+
const renderInput = (inputStyle, labelValue) => (
|
|
160
174
|
<LabelInput
|
|
161
175
|
_ref={_ref}
|
|
162
176
|
externalInputRef={externalInputRef}
|
|
163
177
|
label={labelValue}
|
|
164
178
|
disabled={disabledInput}
|
|
165
|
-
|
|
179
|
+
inputStyle={inputStyle}
|
|
166
180
|
onChange={onChange}
|
|
167
181
|
/>
|
|
168
182
|
);
|
|
169
183
|
|
|
184
|
+
const studentInputStyle = getStudentInputStyles();
|
|
185
|
+
|
|
170
186
|
if (correctness === 'correct' && correctnesslabel === 'correct' && correctlabel) {
|
|
171
187
|
return (
|
|
172
|
-
<
|
|
188
|
+
<StyledInputCorrect style={style}>
|
|
173
189
|
<SvgIcon type="correct" />
|
|
174
|
-
{renderInput(
|
|
175
|
-
</
|
|
190
|
+
{renderInput(studentInputStyle, correctlabel)}
|
|
191
|
+
</StyledInputCorrect>
|
|
176
192
|
);
|
|
177
193
|
}
|
|
178
194
|
|
|
@@ -184,44 +200,41 @@ export const MarkLabel = (props) => {
|
|
|
184
200
|
if (correctness === 'correct' && correctnesslabel === 'incorrect') {
|
|
185
201
|
return (
|
|
186
202
|
<>
|
|
187
|
-
<
|
|
203
|
+
<StyledInputIncorrect style={style}>
|
|
188
204
|
<SvgIcon type="incorrect" />
|
|
189
205
|
{label === '' ? (
|
|
190
206
|
<SvgIcon type="empty" style={{ marginLeft: '3px' }} />
|
|
191
207
|
) : (
|
|
192
|
-
renderInput(
|
|
208
|
+
renderInput(studentInputStyle, label)
|
|
193
209
|
)}
|
|
194
|
-
</
|
|
195
|
-
<
|
|
196
|
-
{renderInput(
|
|
197
|
-
</
|
|
210
|
+
</StyledInputIncorrect>
|
|
211
|
+
<StyledInputMissing style={secondLabelStyle}>
|
|
212
|
+
{renderInput(studentInputStyle, correctlabel)}
|
|
213
|
+
</StyledInputMissing>
|
|
198
214
|
</>
|
|
199
215
|
);
|
|
200
216
|
}
|
|
201
217
|
|
|
202
218
|
if (correctness === 'missing') {
|
|
203
219
|
return (
|
|
204
|
-
<
|
|
205
|
-
{renderInput(
|
|
206
|
-
</
|
|
220
|
+
<StyledInputMissing style={style}>
|
|
221
|
+
{renderInput(studentInputStyle, label)}
|
|
222
|
+
</StyledInputMissing>
|
|
207
223
|
);
|
|
208
224
|
}
|
|
209
225
|
|
|
210
226
|
if (correctness === 'incorrect') {
|
|
211
227
|
return (
|
|
212
|
-
<
|
|
213
|
-
{renderInput(
|
|
214
|
-
</
|
|
228
|
+
<StyledIncorrect style={style}>
|
|
229
|
+
{renderInput(studentInputStyle, label)}
|
|
230
|
+
</StyledIncorrect>
|
|
215
231
|
);
|
|
216
232
|
}
|
|
217
233
|
|
|
218
234
|
return (
|
|
219
235
|
<div style={style}>
|
|
220
236
|
{renderInput(
|
|
221
|
-
|
|
222
|
-
[classes.disabled]: disabled,
|
|
223
|
-
[classes.disabledMark]: mark.disabled,
|
|
224
|
-
}),
|
|
237
|
+
getInputStyles(theme, disabled, mark.disabled),
|
|
225
238
|
label,
|
|
226
239
|
)}
|
|
227
240
|
</div>
|
|
@@ -232,10 +245,8 @@ MarkLabel.propTypes = {
|
|
|
232
245
|
disabled: PropTypes.bool,
|
|
233
246
|
onChange: PropTypes.func,
|
|
234
247
|
graphProps: types.GraphPropsType,
|
|
235
|
-
classes: PropTypes.object,
|
|
236
248
|
inputRef: PropTypes.func,
|
|
237
249
|
mark: PropTypes.object,
|
|
238
|
-
theme: PropTypes.object,
|
|
239
250
|
};
|
|
240
251
|
|
|
241
|
-
export default
|
|
252
|
+
export default MarkLabel;
|