@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.
Files changed (252) hide show
  1. package/CHANGELOG.md +6 -76
  2. package/lib/__tests__/graph-with-controls.test.js +226 -0
  3. package/lib/__tests__/graph.test.js +187 -0
  4. package/lib/__tests__/grid.test.js +29 -0
  5. package/lib/__tests__/labels.test.js +61 -0
  6. package/lib/__tests__/mark-label.test.js +133 -0
  7. package/lib/__tests__/toggle-bar.test.js +150 -0
  8. package/lib/__tests__/tool-menu.test.js +101 -0
  9. package/lib/__tests__/undo-redo.test.js +31 -0
  10. package/lib/__tests__/use-debounce.test.js +24 -0
  11. package/lib/__tests__/utils.js +70 -0
  12. package/lib/__tests__/utils.test.js +123 -0
  13. package/lib/axis/__tests__/arrow.test.js +60 -0
  14. package/lib/axis/__tests__/axes.test.js +195 -0
  15. package/lib/axis/arrow.js +20 -56
  16. package/lib/axis/arrow.js.map +1 -1
  17. package/lib/axis/axes.js +107 -195
  18. package/lib/axis/axes.js.map +1 -1
  19. package/lib/axis/index.js +2 -7
  20. package/lib/axis/index.js.map +1 -1
  21. package/lib/bg.js +22 -50
  22. package/lib/bg.js.map +1 -1
  23. package/lib/container/actions.js +3 -9
  24. package/lib/container/actions.js.map +1 -1
  25. package/lib/container/index.js +15 -60
  26. package/lib/container/index.js.map +1 -1
  27. package/lib/container/marks.js +2 -7
  28. package/lib/container/marks.js.map +1 -1
  29. package/lib/container/middleware.js +3 -9
  30. package/lib/container/middleware.js.map +1 -1
  31. package/lib/container/reducer.js +2 -9
  32. package/lib/container/reducer.js.map +1 -1
  33. package/lib/coordinates-label.js +25 -55
  34. package/lib/coordinates-label.js.map +1 -1
  35. package/lib/graph-with-controls.js +121 -185
  36. package/lib/graph-with-controls.js.map +1 -1
  37. package/lib/graph.js +60 -117
  38. package/lib/graph.js.map +1 -1
  39. package/lib/grid-setup.js +169 -225
  40. package/lib/grid-setup.js.map +1 -1
  41. package/lib/grid.js +30 -75
  42. package/lib/grid.js.map +1 -1
  43. package/lib/index.js +2 -14
  44. package/lib/index.js.map +1 -1
  45. package/lib/key-legend.js +41 -86
  46. package/lib/key-legend.js.map +1 -1
  47. package/lib/label-svg-icon.js +2 -8
  48. package/lib/label-svg-icon.js.map +1 -1
  49. package/lib/labels.js +66 -122
  50. package/lib/labels.js.map +1 -1
  51. package/lib/mark-label.js +121 -164
  52. package/lib/mark-label.js.map +1 -1
  53. package/lib/toggle-bar.js +156 -244
  54. package/lib/toggle-bar.js.map +1 -1
  55. package/lib/tool-menu.js +17 -51
  56. package/lib/tool-menu.js.map +1 -1
  57. package/lib/tools/absolute/__tests__/component.test.js +67 -0
  58. package/lib/tools/absolute/component.js +5 -11
  59. package/lib/tools/absolute/component.js.map +1 -1
  60. package/lib/tools/absolute/index.js +4 -17
  61. package/lib/tools/absolute/index.js.map +1 -1
  62. package/lib/tools/circle/__tests__/bg-circle.test.js +33 -0
  63. package/lib/tools/circle/__tests__/component.test.js +68 -0
  64. package/lib/tools/circle/bg-circle.js +43 -93
  65. package/lib/tools/circle/bg-circle.js.map +1 -1
  66. package/lib/tools/circle/component.js +79 -166
  67. package/lib/tools/circle/component.js.map +1 -1
  68. package/lib/tools/circle/index.js +4 -14
  69. package/lib/tools/circle/index.js.map +1 -1
  70. package/lib/tools/exponential/__tests__/component.test.js +66 -0
  71. package/lib/tools/exponential/component.js +5 -11
  72. package/lib/tools/exponential/component.js.map +1 -1
  73. package/lib/tools/exponential/index.js +4 -19
  74. package/lib/tools/exponential/index.js.map +1 -1
  75. package/lib/tools/index.js +4 -17
  76. package/lib/tools/index.js.map +1 -1
  77. package/lib/tools/line/__tests__/component.test.js +45 -0
  78. package/lib/tools/line/component.js +28 -49
  79. package/lib/tools/line/component.js.map +1 -1
  80. package/lib/tools/line/index.js +2 -7
  81. package/lib/tools/line/index.js.map +1 -1
  82. package/lib/tools/parabola/__tests__/component.test.js +66 -0
  83. package/lib/tools/parabola/component.js +5 -11
  84. package/lib/tools/parabola/component.js.map +1 -1
  85. package/lib/tools/parabola/index.js +4 -17
  86. package/lib/tools/parabola/index.js.map +1 -1
  87. package/lib/tools/point/__tests__/component.test.js +50 -0
  88. package/lib/tools/point/component.js +25 -72
  89. package/lib/tools/point/component.js.map +1 -1
  90. package/lib/tools/point/index.js +4 -12
  91. package/lib/tools/point/index.js.map +1 -1
  92. package/lib/tools/polygon/__tests__/component.test.js +85 -0
  93. package/lib/tools/polygon/__tests__/index.test.js +92 -0
  94. package/lib/tools/polygon/__tests__/line.test.js +29 -0
  95. package/lib/tools/polygon/__tests__/polygon.test.js +59 -0
  96. package/lib/tools/polygon/component.js +84 -185
  97. package/lib/tools/polygon/component.js.map +1 -1
  98. package/lib/tools/polygon/index.js +7 -24
  99. package/lib/tools/polygon/index.js.map +1 -1
  100. package/lib/tools/polygon/line.js +49 -92
  101. package/lib/tools/polygon/line.js.map +1 -1
  102. package/lib/tools/polygon/polygon.js +66 -99
  103. package/lib/tools/polygon/polygon.js.map +1 -1
  104. package/lib/tools/ray/__tests__/component.test.js +35 -0
  105. package/lib/tools/ray/component.js +42 -61
  106. package/lib/tools/ray/component.js.map +1 -1
  107. package/lib/tools/ray/index.js +2 -7
  108. package/lib/tools/ray/index.js.map +1 -1
  109. package/lib/tools/segment/__tests__/component.test.js +35 -0
  110. package/lib/tools/segment/component.js +26 -44
  111. package/lib/tools/segment/component.js.map +1 -1
  112. package/lib/tools/segment/index.js +2 -7
  113. package/lib/tools/segment/index.js.map +1 -1
  114. package/lib/tools/shared/__tests__/arrow-head.test.js +45 -0
  115. package/lib/tools/shared/arrow-head.js +70 -29
  116. package/lib/tools/shared/arrow-head.js.map +1 -1
  117. package/lib/tools/shared/icons/CorrectSVG.js +13 -9
  118. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  119. package/lib/tools/shared/icons/IncorrectSVG.js +13 -9
  120. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  121. package/lib/tools/shared/icons/MissingSVG.js +13 -9
  122. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  123. package/lib/tools/shared/line/__tests__/index.test.js +124 -0
  124. package/lib/tools/shared/line/__tests__/line-path.test.js +62 -0
  125. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +91 -0
  126. package/lib/tools/shared/line/index.js +141 -194
  127. package/lib/tools/shared/line/index.js.map +1 -1
  128. package/lib/tools/shared/line/line-path.js +71 -102
  129. package/lib/tools/shared/line/line-path.js.map +1 -1
  130. package/lib/tools/shared/line/with-root-edge.js +23 -57
  131. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  132. package/lib/tools/shared/point/__tests__/arrow-point.test.js +127 -0
  133. package/lib/tools/shared/point/__tests__/base-point.test.js +122 -0
  134. package/lib/tools/shared/point/arrow-point.js +22 -63
  135. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  136. package/lib/tools/shared/point/arrow.js +24 -53
  137. package/lib/tools/shared/point/arrow.js.map +1 -1
  138. package/lib/tools/shared/point/base-point.js +55 -73
  139. package/lib/tools/shared/point/base-point.js.map +1 -1
  140. package/lib/tools/shared/point/index.js +23 -58
  141. package/lib/tools/shared/point/index.js.map +1 -1
  142. package/lib/tools/shared/styles.js +11 -39
  143. package/lib/tools/shared/styles.js.map +1 -1
  144. package/lib/tools/shared/types.js +3 -10
  145. package/lib/tools/shared/types.js.map +1 -1
  146. package/lib/tools/sine/__tests__/component.test.js +72 -0
  147. package/lib/tools/sine/component.js +9 -20
  148. package/lib/tools/sine/component.js.map +1 -1
  149. package/lib/tools/sine/index.js +4 -17
  150. package/lib/tools/sine/index.js.map +1 -1
  151. package/lib/tools/vector/__tests__/component.test.js +32 -0
  152. package/lib/tools/vector/component.js +25 -45
  153. package/lib/tools/vector/component.js.map +1 -1
  154. package/lib/tools/vector/index.js +2 -7
  155. package/lib/tools/vector/index.js.map +1 -1
  156. package/lib/undo-redo.js +30 -70
  157. package/lib/undo-redo.js.map +1 -1
  158. package/lib/use-debounce.js +5 -12
  159. package/lib/use-debounce.js.map +1 -1
  160. package/lib/utils.js +52 -129
  161. package/lib/utils.js.map +1 -1
  162. package/package.json +25 -29
  163. package/src/__tests__/graph-with-controls.test.jsx +28 -11
  164. package/src/__tests__/graph.test.jsx +104 -168
  165. package/src/__tests__/grid.test.jsx +8 -6
  166. package/src/__tests__/labels.test.jsx +25 -8
  167. package/src/__tests__/mark-label.test.jsx +12 -17
  168. package/src/__tests__/toggle-bar.test.jsx +92 -17
  169. package/src/__tests__/tool-menu.test.jsx +61 -12
  170. package/src/__tests__/undo-redo.test.jsx +7 -8
  171. package/src/__tests__/utils.js +3 -0
  172. package/src/axis/__tests__/arrow.test.jsx +16 -17
  173. package/src/axis/__tests__/axes.test.jsx +118 -122
  174. package/src/axis/arrow.jsx +7 -12
  175. package/src/axis/axes.jsx +45 -55
  176. package/src/coordinates-label.jsx +14 -18
  177. package/src/graph-with-controls.jsx +52 -59
  178. package/src/grid-setup.jsx +210 -206
  179. package/src/grid.jsx +2 -4
  180. package/src/key-legend.jsx +52 -56
  181. package/src/labels.jsx +23 -30
  182. package/src/mark-label.jsx +92 -81
  183. package/src/toggle-bar.jsx +135 -164
  184. package/src/tool-menu.jsx +1 -1
  185. package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
  186. package/src/tools/circle/__tests__/component.test.jsx +17 -189
  187. package/src/tools/circle/bg-circle.jsx +20 -28
  188. package/src/tools/circle/component.jsx +28 -63
  189. package/src/tools/line/__tests__/component.test.jsx +7 -7
  190. package/src/tools/line/component.jsx +22 -15
  191. package/src/tools/point/__tests__/component.test.jsx +18 -43
  192. package/src/tools/point/component.jsx +1 -1
  193. package/src/tools/polygon/__tests__/component.test.jsx +18 -162
  194. package/src/tools/polygon/__tests__/line.test.jsx +7 -10
  195. package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
  196. package/src/tools/polygon/component.jsx +3 -4
  197. package/src/tools/polygon/line.jsx +30 -33
  198. package/src/tools/polygon/polygon.jsx +52 -45
  199. package/src/tools/ray/__tests__/component.test.jsx +7 -8
  200. package/src/tools/ray/component.jsx +38 -25
  201. package/src/tools/segment/__tests__/component.test.jsx +7 -8
  202. package/src/tools/segment/component.jsx +19 -18
  203. package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
  204. package/src/tools/shared/arrow-head.jsx +60 -7
  205. package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
  206. package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
  207. package/src/tools/shared/icons/MissingSVG.jsx +10 -0
  208. package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
  209. package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
  210. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
  211. package/src/tools/shared/line/index.jsx +52 -7
  212. package/src/tools/shared/line/line-path.jsx +55 -59
  213. package/src/tools/shared/line/with-root-edge.jsx +1 -1
  214. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
  215. package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
  216. package/src/tools/shared/point/arrow-point.jsx +10 -24
  217. package/src/tools/shared/point/arrow.jsx +5 -11
  218. package/src/tools/shared/point/base-point.jsx +42 -19
  219. package/src/tools/shared/point/index.jsx +27 -44
  220. package/src/tools/vector/__tests__/component.test.jsx +7 -8
  221. package/src/tools/vector/component.jsx +11 -16
  222. package/src/undo-redo.jsx +19 -21
  223. package/esm/index.css +0 -847
  224. package/esm/index.js +0 -239949
  225. package/esm/index.js.map +0 -1
  226. package/esm/package.json +0 -3
  227. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
  228. package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
  229. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
  230. package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
  231. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
  232. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
  233. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
  234. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
  235. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
  236. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
  237. package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
  238. package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
  239. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
  240. package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
  241. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
  242. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  243. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
  244. package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
  245. package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
  246. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
  247. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
  248. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
  249. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
  250. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
  251. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
  252. package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
@@ -1,44 +1,42 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
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 styles = (theme) => ({
8
- container: {
9
- backgroundColor: color.defaults.WHITE,
10
- padding: '20px',
11
- width: '355px',
12
- boxShadow: '0px 1px 5px 0px #9297A6',
13
- },
14
- row: {
15
- display: 'flex',
16
- alignItems: 'center',
17
- padding: '10px',
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 KeyLegend = ({ className, classes, isLabelAvailable }) => {
34
- const names = classNames(classes.formControl, className);
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
- <div className={classes.container}>
38
- <div className={classes.title}>Key</div>
35
+ <StyledContainer className={className}>
36
+ <StyledTitle>Key</StyledTitle>
39
37
  {isLabelAvailable && (
40
- <div className={classes.row}>
41
- <div className={classes.text}> Missing Required Label </div>
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
- </div>
51
+ </StyledRow>
54
52
  )}
55
- <div className={classes.row}>
56
- <div className={classes.text}> Answer Key Correct </div>
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
- </div>
63
+ </StyledRow>
66
64
  {isLabelAvailable && (
67
- <div className={classes.row}>
68
- <div className={classes.text}> Answer Key Correct Label </div>
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
- </div>
75
+ </StyledRow>
78
76
  )}
79
- <div className={classes.row}>
80
- <div className={classes.text}> Student Incorrect </div>
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
- </div>
87
+ </StyledRow>
90
88
  {isLabelAvailable && (
91
- <div className={classes.row}>
92
- <div className={classes.text}> Incorrect Student Label </div>
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
- </div>
103
+ </StyledRow>
106
104
  )}
107
- <div className={classes.row}>
108
- <div className={classes.text}> Student Correct </div>
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
- </svg>
117
- </div>
113
+ /> </svg>
114
+ </StyledRow>
118
115
  {isLabelAvailable && (
119
- <div className={classes.row}>
120
- <div className={classes.text}> Student Correct Label </div>
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
- </div>
130
+ </StyledRow>
134
131
  )}
135
- </div>
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 withStyles(styles)(KeyLegend);
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 { withStyles } from '@material-ui/core/styles';
3
+ import { styled } from '@mui/material/styles';
4
4
  import { types } from '@pie-lib/plot';
5
- import { color, Readable } from '@pie-lib/render-ui';
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, classes, onChange, mathMlOptions = {} } = this.props;
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
- <EditableHtml
93
- className={cn(
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 = withStyles((theme) => ({
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 = {};
@@ -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 { withStyles } from '@material-ui/core/styles';
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 inputStyles = (theme) => ({
10
+ const StyledInputCorrect = styled('div')(({ theme }) => ({
12
11
  float: 'right',
13
- padding: theme.spacing.unit * 0.5,
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 styles = (theme) => ({
20
- inputStudent: {
21
- ...inputStyles(theme),
22
- padding: '0',
23
- border: 'none',
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, inputClassName, onChange }) => (
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
- inputClassName={inputClassName}
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, classes, disabled, inputRef: externalInputRef, theme } = props;
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 = (inputClass, labelValue) => (
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
- inputClassName={cn(inputClass)}
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
- <div className={classes.inputCorrect} style={style}>
188
+ <StyledInputCorrect style={style}>
173
189
  <SvgIcon type="correct" />
174
- {renderInput(classes.inputStudent, correctlabel)}
175
- </div>
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
- <div className={classes.inputIncorrect} style={style}>
203
+ <StyledInputIncorrect style={style}>
188
204
  <SvgIcon type="incorrect" />
189
205
  {label === '' ? (
190
206
  <SvgIcon type="empty" style={{ marginLeft: '3px' }} />
191
207
  ) : (
192
- renderInput(classes.inputStudent, label)
208
+ renderInput(studentInputStyle, label)
193
209
  )}
194
- </div>
195
- <div className={classes.inputMissing} style={secondLabelStyle}>
196
- {renderInput(classes.inputStudent, correctlabel)}
197
- </div>
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
- <div className={classes.inputMissing} style={style}>
205
- {renderInput(classes.inputStudent, label)}
206
- </div>
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
- <div className={classes.incorrect} style={style}>
213
- {renderInput(classes.inputStudent, label)}
214
- </div>
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
- cn(classes.input, {
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 withStyles(styles, { withTheme: true })(MarkLabel);
252
+ export default MarkLabel;