@pie-lib/graphing 2.34.2-next.0 → 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 -8
- 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 +113 -183
- 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 +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 -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 +15 -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 +204 -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
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')(({ theme }) => ({
|
|
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,11 +42,24 @@ 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,
|
|
@@ -59,7 +71,7 @@ class RawLabel extends React.Component {
|
|
|
59
71
|
};
|
|
60
72
|
|
|
61
73
|
render() {
|
|
62
|
-
const { disabledLabel, placeholder, text, side, graphProps,
|
|
74
|
+
const { disabledLabel, placeholder, text, side, graphProps, onChange, mathMlOptions = {} } = this.props;
|
|
63
75
|
const { size, domain, range } = graphProps;
|
|
64
76
|
const totalHeight = (size.height || 500) + (range.padding || 0) * 2;
|
|
65
77
|
const totalWidth = (size.width || 500) + (domain.padding || 0) * 2;
|
|
@@ -89,14 +101,9 @@ class RawLabel extends React.Component {
|
|
|
89
101
|
textAnchor="middle"
|
|
90
102
|
>
|
|
91
103
|
<Readable false>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
[classes.bottomLabel]: side === 'bottom',
|
|
96
|
-
[classes.disabledAxisLabel]: disabledLabel,
|
|
97
|
-
},
|
|
98
|
-
classes.axisLabel,
|
|
99
|
-
)}
|
|
104
|
+
<StyledEditableHtml
|
|
105
|
+
side={side}
|
|
106
|
+
disabledLabel={disabledLabel}
|
|
100
107
|
markup={text || ''}
|
|
101
108
|
onChange={onChange}
|
|
102
109
|
placeholder={!disabledLabel && placeholder}
|
|
@@ -114,22 +121,7 @@ class RawLabel extends React.Component {
|
|
|
114
121
|
}
|
|
115
122
|
}
|
|
116
123
|
|
|
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);
|
|
124
|
+
const Label = RawLabel;
|
|
133
125
|
|
|
134
126
|
export const LabelType = {
|
|
135
127
|
left: PropTypes.string,
|
|
@@ -140,7 +132,6 @@ export const LabelType = {
|
|
|
140
132
|
|
|
141
133
|
export class Labels extends React.Component {
|
|
142
134
|
static propTypes = {
|
|
143
|
-
classes: PropTypes.object,
|
|
144
135
|
className: PropTypes.string,
|
|
145
136
|
disabledLabels: PropTypes.bool,
|
|
146
137
|
placeholders: PropTypes.object,
|
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')(({ theme }) => ({
|
|
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,14 +103,14 @@ 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
|
/>
|
|
@@ -115,8 +119,9 @@ const LabelInput = ({ _ref, externalInputRef, label, disabled, inputClassName, o
|
|
|
115
119
|
export const MarkLabel = (props) => {
|
|
116
120
|
const [input, setInput] = useState(null);
|
|
117
121
|
const _ref = useCallback((node) => setInput(node));
|
|
122
|
+
const theme = useTheme();
|
|
118
123
|
|
|
119
|
-
const { mark, graphProps,
|
|
124
|
+
const { mark, graphProps, disabled, inputRef: externalInputRef } = props;
|
|
120
125
|
|
|
121
126
|
const [label, setLabel] = useState(mark.label);
|
|
122
127
|
const { correctness, correctnesslabel, correctlabel } = mark;
|
|
@@ -156,23 +161,25 @@ export const MarkLabel = (props) => {
|
|
|
156
161
|
|
|
157
162
|
const disabledInput = disabled || mark.disabled;
|
|
158
163
|
|
|
159
|
-
const renderInput = (
|
|
164
|
+
const renderInput = (inputStyle, labelValue) => (
|
|
160
165
|
<LabelInput
|
|
161
166
|
_ref={_ref}
|
|
162
167
|
externalInputRef={externalInputRef}
|
|
163
168
|
label={labelValue}
|
|
164
169
|
disabled={disabledInput}
|
|
165
|
-
|
|
170
|
+
inputStyle={inputStyle}
|
|
166
171
|
onChange={onChange}
|
|
167
172
|
/>
|
|
168
173
|
);
|
|
169
174
|
|
|
175
|
+
const studentInputStyle = getStudentInputStyles();
|
|
176
|
+
|
|
170
177
|
if (correctness === 'correct' && correctnesslabel === 'correct' && correctlabel) {
|
|
171
178
|
return (
|
|
172
|
-
<
|
|
179
|
+
<StyledInputCorrect style={style}>
|
|
173
180
|
<SvgIcon type="correct" />
|
|
174
|
-
{renderInput(
|
|
175
|
-
</
|
|
181
|
+
{renderInput(studentInputStyle, correctlabel)}
|
|
182
|
+
</StyledInputCorrect>
|
|
176
183
|
);
|
|
177
184
|
}
|
|
178
185
|
|
|
@@ -184,44 +191,41 @@ export const MarkLabel = (props) => {
|
|
|
184
191
|
if (correctness === 'correct' && correctnesslabel === 'incorrect') {
|
|
185
192
|
return (
|
|
186
193
|
<>
|
|
187
|
-
<
|
|
194
|
+
<StyledInputIncorrect style={style}>
|
|
188
195
|
<SvgIcon type="incorrect" />
|
|
189
196
|
{label === '' ? (
|
|
190
197
|
<SvgIcon type="empty" style={{ marginLeft: '3px' }} />
|
|
191
198
|
) : (
|
|
192
|
-
renderInput(
|
|
199
|
+
renderInput(studentInputStyle, label)
|
|
193
200
|
)}
|
|
194
|
-
</
|
|
195
|
-
<
|
|
196
|
-
{renderInput(
|
|
197
|
-
</
|
|
201
|
+
</StyledInputIncorrect>
|
|
202
|
+
<StyledInputMissing style={secondLabelStyle}>
|
|
203
|
+
{renderInput(studentInputStyle, correctlabel)}
|
|
204
|
+
</StyledInputMissing>
|
|
198
205
|
</>
|
|
199
206
|
);
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
if (correctness === 'missing') {
|
|
203
210
|
return (
|
|
204
|
-
<
|
|
205
|
-
{renderInput(
|
|
206
|
-
</
|
|
211
|
+
<StyledInputMissing style={style}>
|
|
212
|
+
{renderInput(studentInputStyle, label)}
|
|
213
|
+
</StyledInputMissing>
|
|
207
214
|
);
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
if (correctness === 'incorrect') {
|
|
211
218
|
return (
|
|
212
|
-
<
|
|
213
|
-
{renderInput(
|
|
214
|
-
</
|
|
219
|
+
<StyledIncorrect style={style}>
|
|
220
|
+
{renderInput(studentInputStyle, label)}
|
|
221
|
+
</StyledIncorrect>
|
|
215
222
|
);
|
|
216
223
|
}
|
|
217
224
|
|
|
218
225
|
return (
|
|
219
226
|
<div style={style}>
|
|
220
227
|
{renderInput(
|
|
221
|
-
|
|
222
|
-
[classes.disabled]: disabled,
|
|
223
|
-
[classes.disabledMark]: mark.disabled,
|
|
224
|
-
}),
|
|
228
|
+
getInputStyles(theme, disabled, mark.disabled),
|
|
225
229
|
label,
|
|
226
230
|
)}
|
|
227
231
|
</div>
|
|
@@ -232,10 +236,8 @@ MarkLabel.propTypes = {
|
|
|
232
236
|
disabled: PropTypes.bool,
|
|
233
237
|
onChange: PropTypes.func,
|
|
234
238
|
graphProps: types.GraphPropsType,
|
|
235
|
-
classes: PropTypes.object,
|
|
236
239
|
inputRef: PropTypes.func,
|
|
237
240
|
mark: PropTypes.object,
|
|
238
|
-
theme: PropTypes.object,
|
|
239
241
|
};
|
|
240
242
|
|
|
241
|
-
export default
|
|
243
|
+
export default MarkLabel;
|