@pie-lib/graphing 2.34.2-next.0 → 2.36.0-mui-update.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +16 -6
  2. package/lib/axis/arrow.js +19 -55
  3. package/lib/axis/arrow.js.map +1 -1
  4. package/lib/axis/axes.js +104 -186
  5. package/lib/axis/axes.js.map +1 -1
  6. package/lib/axis/index.js +1 -6
  7. package/lib/axis/index.js.map +1 -1
  8. package/lib/bg.js +21 -49
  9. package/lib/bg.js.map +1 -1
  10. package/lib/container/actions.js +2 -8
  11. package/lib/container/actions.js.map +1 -1
  12. package/lib/container/index.js +14 -59
  13. package/lib/container/index.js.map +1 -1
  14. package/lib/container/marks.js +1 -6
  15. package/lib/container/marks.js.map +1 -1
  16. package/lib/container/middleware.js +2 -8
  17. package/lib/container/middleware.js.map +1 -1
  18. package/lib/container/reducer.js +1 -8
  19. package/lib/container/reducer.js.map +1 -1
  20. package/lib/coordinates-label.js +23 -55
  21. package/lib/coordinates-label.js.map +1 -1
  22. package/lib/graph-with-controls.js +120 -184
  23. package/lib/graph-with-controls.js.map +1 -1
  24. package/lib/graph.js +59 -116
  25. package/lib/graph.js.map +1 -1
  26. package/lib/grid-setup.js +174 -224
  27. package/lib/grid-setup.js.map +1 -1
  28. package/lib/grid.js +28 -73
  29. package/lib/grid.js.map +1 -1
  30. package/lib/index.js +1 -13
  31. package/lib/index.js.map +1 -1
  32. package/lib/key-legend.js +41 -85
  33. package/lib/key-legend.js.map +1 -1
  34. package/lib/label-svg-icon.js +1 -7
  35. package/lib/label-svg-icon.js.map +1 -1
  36. package/lib/labels.js +61 -119
  37. package/lib/labels.js.map +1 -1
  38. package/lib/mark-label.js +113 -163
  39. package/lib/mark-label.js.map +1 -1
  40. package/lib/toggle-bar.js +158 -242
  41. package/lib/toggle-bar.js.map +1 -1
  42. package/lib/tool-menu.js +16 -48
  43. package/lib/tool-menu.js.map +1 -1
  44. package/lib/tools/absolute/component.js +4 -10
  45. package/lib/tools/absolute/component.js.map +1 -1
  46. package/lib/tools/absolute/index.js +3 -16
  47. package/lib/tools/absolute/index.js.map +1 -1
  48. package/lib/tools/circle/bg-circle.js +42 -92
  49. package/lib/tools/circle/bg-circle.js.map +1 -1
  50. package/lib/tools/circle/component.js +79 -165
  51. package/lib/tools/circle/component.js.map +1 -1
  52. package/lib/tools/circle/index.js +3 -13
  53. package/lib/tools/circle/index.js.map +1 -1
  54. package/lib/tools/exponential/component.js +4 -10
  55. package/lib/tools/exponential/component.js.map +1 -1
  56. package/lib/tools/exponential/index.js +3 -18
  57. package/lib/tools/exponential/index.js.map +1 -1
  58. package/lib/tools/index.js +3 -16
  59. package/lib/tools/index.js.map +1 -1
  60. package/lib/tools/line/component.js +27 -48
  61. package/lib/tools/line/component.js.map +1 -1
  62. package/lib/tools/line/index.js +1 -6
  63. package/lib/tools/line/index.js.map +1 -1
  64. package/lib/tools/parabola/component.js +4 -10
  65. package/lib/tools/parabola/component.js.map +1 -1
  66. package/lib/tools/parabola/index.js +3 -16
  67. package/lib/tools/parabola/index.js.map +1 -1
  68. package/lib/tools/point/component.js +24 -71
  69. package/lib/tools/point/component.js.map +1 -1
  70. package/lib/tools/point/index.js +3 -11
  71. package/lib/tools/point/index.js.map +1 -1
  72. package/lib/tools/polygon/component.js +82 -183
  73. package/lib/tools/polygon/component.js.map +1 -1
  74. package/lib/tools/polygon/index.js +6 -23
  75. package/lib/tools/polygon/index.js.map +1 -1
  76. package/lib/tools/polygon/line.js +48 -91
  77. package/lib/tools/polygon/line.js.map +1 -1
  78. package/lib/tools/polygon/polygon.js +65 -98
  79. package/lib/tools/polygon/polygon.js.map +1 -1
  80. package/lib/tools/ray/component.js +41 -60
  81. package/lib/tools/ray/component.js.map +1 -1
  82. package/lib/tools/ray/index.js +1 -6
  83. package/lib/tools/ray/index.js.map +1 -1
  84. package/lib/tools/segment/component.js +25 -43
  85. package/lib/tools/segment/component.js.map +1 -1
  86. package/lib/tools/segment/index.js +1 -6
  87. package/lib/tools/segment/index.js.map +1 -1
  88. package/lib/tools/shared/arrow-head.js +69 -28
  89. package/lib/tools/shared/arrow-head.js.map +1 -1
  90. package/lib/tools/shared/icons/CorrectSVG.js +3 -8
  91. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  92. package/lib/tools/shared/icons/IncorrectSVG.js +3 -8
  93. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  94. package/lib/tools/shared/icons/MissingSVG.js +3 -8
  95. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  96. package/lib/tools/shared/line/index.js +126 -187
  97. package/lib/tools/shared/line/index.js.map +1 -1
  98. package/lib/tools/shared/line/line-path.js +70 -100
  99. package/lib/tools/shared/line/line-path.js.map +1 -1
  100. package/lib/tools/shared/line/with-root-edge.js +21 -55
  101. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  102. package/lib/tools/shared/point/arrow-point.js +23 -62
  103. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  104. package/lib/tools/shared/point/arrow.js +24 -52
  105. package/lib/tools/shared/point/arrow.js.map +1 -1
  106. package/lib/tools/shared/point/base-point.js +54 -72
  107. package/lib/tools/shared/point/base-point.js.map +1 -1
  108. package/lib/tools/shared/point/index.js +22 -57
  109. package/lib/tools/shared/point/index.js.map +1 -1
  110. package/lib/tools/shared/styles.js +10 -38
  111. package/lib/tools/shared/styles.js.map +1 -1
  112. package/lib/tools/shared/types.js +2 -9
  113. package/lib/tools/shared/types.js.map +1 -1
  114. package/lib/tools/sine/component.js +8 -19
  115. package/lib/tools/sine/component.js.map +1 -1
  116. package/lib/tools/sine/index.js +3 -16
  117. package/lib/tools/sine/index.js.map +1 -1
  118. package/lib/tools/vector/component.js +24 -44
  119. package/lib/tools/vector/component.js.map +1 -1
  120. package/lib/tools/vector/index.js +1 -6
  121. package/lib/tools/vector/index.js.map +1 -1
  122. package/lib/undo-redo.js +29 -69
  123. package/lib/undo-redo.js.map +1 -1
  124. package/lib/use-debounce.js +4 -11
  125. package/lib/use-debounce.js.map +1 -1
  126. package/lib/utils.js +51 -128
  127. package/lib/utils.js.map +1 -1
  128. package/package.json +16 -13
  129. package/src/axis/arrow.jsx +7 -12
  130. package/src/axis/axes.jsx +40 -45
  131. package/src/coordinates-label.jsx +13 -18
  132. package/src/graph-with-controls.jsx +52 -59
  133. package/src/grid-setup.jsx +210 -206
  134. package/src/grid.jsx +1 -3
  135. package/src/key-legend.jsx +52 -56
  136. package/src/labels.jsx +21 -30
  137. package/src/mark-label.jsx +83 -81
  138. package/src/toggle-bar.jsx +155 -166
  139. package/src/tools/circle/bg-circle.jsx +20 -28
  140. package/src/tools/circle/component.jsx +28 -63
  141. package/src/tools/line/component.jsx +22 -15
  142. package/src/tools/polygon/component.jsx +1 -2
  143. package/src/tools/polygon/line.jsx +28 -32
  144. package/src/tools/polygon/polygon.jsx +52 -45
  145. package/src/tools/ray/component.jsx +38 -25
  146. package/src/tools/segment/component.jsx +19 -18
  147. package/src/tools/shared/arrow-head.jsx +60 -7
  148. package/src/tools/shared/line/index.jsx +39 -2
  149. package/src/tools/shared/line/line-path.jsx +54 -58
  150. package/src/tools/shared/point/arrow-point.jsx +10 -24
  151. package/src/tools/shared/point/arrow.jsx +5 -11
  152. package/src/tools/shared/point/base-point.jsx +42 -19
  153. package/src/tools/shared/point/index.jsx +27 -44
  154. package/src/tools/vector/component.jsx +11 -16
  155. package/src/undo-redo.jsx +19 -21
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.34.2-next.0+19a7ac5d",
6
+ "version": "2.36.0-mui-update.0",
7
7
  "description": "Graphing components",
8
8
  "keywords": [
9
9
  "react",
@@ -16,15 +16,18 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
+ "@dnd-kit/sortable": "8.0.0",
20
+ "@emotion/react": "^11.14.0",
21
+ "@emotion/style": "^0.8.0",
19
22
  "@mapbox/point-geometry": "^0.1.0",
20
- "@material-ui/core": "^3.8.3",
21
- "@material-ui/icons": "^3.0.2",
22
- "@pie-lib/drag": "^2.22.2-next.0+19a7ac5d",
23
- "@pie-lib/editable-html": "^11.21.2-next.0+19a7ac5d",
24
- "@pie-lib/graphing-utils": "^1.21.2-next.0+19a7ac5d",
25
- "@pie-lib/plot": "^2.27.2-next.0+19a7ac5d",
26
- "@pie-lib/render-ui": "^4.35.2-next.0+19a7ac5d",
27
- "@pie-lib/translator": "^2.23.2-next.0+19a7ac5d",
23
+ "@mui/icons-material": "^7.3.4",
24
+ "@mui/material": "^7.3.4",
25
+ "@pie-lib/drag": "^2.24.0-mui-update.0",
26
+ "@pie-lib/editable-html": "^11.23.0-mui-update.0",
27
+ "@pie-lib/graphing-utils": "^1.23.0-mui-update.0",
28
+ "@pie-lib/plot": "^2.29.0-mui-update.0",
29
+ "@pie-lib/render-ui": "^4.37.0-mui-update.0",
30
+ "@pie-lib/translator": "^2.26.0-mui-update.0",
28
31
  "@vx/axis": "^0.0.189",
29
32
  "@vx/clip-path": "^0.0.189",
30
33
  "@vx/event": "^0.0.189",
@@ -39,8 +42,8 @@
39
42
  "invariant": "^2.2.4",
40
43
  "lodash": "^4.17.11",
41
44
  "prop-types": "^15.7.2",
42
- "react": "^16.8.1",
43
- "react-dom": "^16.9.0",
45
+ "react": "^18.2.0",
46
+ "react-dom": "^18.2.0",
44
47
  "react-draggable": "^3.3.0",
45
48
  "react-input-autosize": "^2.2.1",
46
49
  "react-redux": "^6.0.0",
@@ -48,8 +51,8 @@
48
51
  "redux-undo": "beta"
49
52
  },
50
53
  "peerDependencies": {
51
- "react": "^16.8.1"
54
+ "react": "^18.2.0"
52
55
  },
53
- "gitHead": "19a7ac5d429f1c5fe9138faff9981720f8c9e294",
56
+ "gitHead": "4d8ccede3634986a13ea7df987defd26d089f0d6",
54
57
  "scripts": {}
55
58
  }
@@ -1,20 +1,16 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- import classNames from 'classnames';
5
- import { withStyles } from '@material-ui/core/styles';
4
+ import { styled } from '@mui/material/styles';
6
5
  import { types } from '@pie-lib/plot';
7
6
 
8
- const style = (theme) => ({
9
- root: {
10
- fill: `var(--arrow-color, ${theme.palette.common.black})`,
11
- },
12
- });
7
+ const StyledPath = styled('path')(({ theme }) => ({
8
+ fill: `var(--arrow-color, ${theme.palette.common.black})`,
9
+ }));
13
10
 
14
11
  export class Arrow extends React.Component {
15
12
  render() {
16
- const { x, y, classes, className, scale } = this.props;
17
- const names = classNames(classes.root, className);
13
+ const { x, y, className, scale } = this.props;
18
14
  let direction = this.props.direction || 'left';
19
15
 
20
16
  const xv = scale.x(x);
@@ -40,7 +36,7 @@ export class Arrow extends React.Component {
40
36
  transform = getTransform(xv, yv + 15, 270);
41
37
  }
42
38
 
43
- return <path d="m 0,0 8,-5 0,10 -8,-5" transform={transform} className={names} />;
39
+ return <StyledPath d="m 0,0 8,-5 0,10 -8,-5" transform={transform} className={className} />;
44
40
  }
45
41
  }
46
42
 
@@ -48,7 +44,6 @@ Arrow.propTypes = {
48
44
  y: PropTypes.number,
49
45
  x: PropTypes.number,
50
46
  direction: PropTypes.oneOf(['left', 'right', 'up', 'down']),
51
- classes: PropTypes.object.isRequired,
52
47
  className: PropTypes.string,
53
48
  scale: types.ScaleType.isRequired,
54
49
  };
@@ -59,4 +54,4 @@ Arrow.defaultProps = {
59
54
  direction: 'left',
60
55
  };
61
56
 
62
- export default withStyles(style)(Arrow);
57
+ export default Arrow;
package/src/axis/axes.jsx CHANGED
@@ -3,7 +3,7 @@ import { Axis } from '@vx/axis';
3
3
  import { types } from '@pie-lib/plot';
4
4
  import PropTypes from 'prop-types';
5
5
  import Arrow from './arrow';
6
- import { withStyles } from '@material-ui/core';
6
+ import { styled } from '@mui/material/styles';
7
7
  import { countWords, findLongestWord, amountToIncreaseWidth, getTickValues } from '../utils';
8
8
  import { color, Readable } from '@pie-lib/render-ui';
9
9
 
@@ -21,34 +21,37 @@ const AxisDefaultProps = {
21
21
  },
22
22
  };
23
23
 
24
- const axisStyles = (theme) => ({
25
- line: {
24
+ const StyledArrow = styled(Arrow)(() => ({
25
+ fill: color.defaults.PRIMARY,
26
+ }));
27
+
28
+ const StyledLabel = styled('div')(({ theme }) => ({
29
+ fontSize: theme.typography.fontSize,
30
+ }));
31
+
32
+ const StyledAxisLabelHolder = styled('div')(({ theme }) => ({
33
+ padding: 0,
34
+ margin: 0,
35
+ textAlign: 'center',
36
+ '* > *': {
37
+ margin: 0,
38
+ padding: 0,
39
+ },
40
+ fontSize: theme.typography.fontSize,
41
+ }));
42
+
43
+ const StyledAxesGroup = styled('g')(() => ({
44
+ '& .vx-axis-line': {
26
45
  stroke: color.defaults.PRIMARY,
27
46
  strokeWidth: 3,
28
47
  },
29
- arrow: {
30
- fill: color.defaults.PRIMARY,
31
- },
32
- tick: {
48
+ '& .vx-axis-tick': {
33
49
  fill: color.defaults.PRIMARY,
34
- '& > line': {
50
+ '& line': {
35
51
  stroke: color.defaults.PRIMARY,
36
52
  },
37
53
  },
38
- labelFontSize: {
39
- fontSize: theme.typography.fontSize,
40
- },
41
- axisLabelHolder: {
42
- padding: 0,
43
- margin: 0,
44
- textAlign: 'center',
45
- '* > *': {
46
- margin: 0,
47
- padding: 0,
48
- },
49
- fontSize: theme.typography.fontSize,
50
- },
51
- });
54
+ }));
52
55
 
53
56
  const tickLabelStyles = {
54
57
  fontFamily: 'Roboto',
@@ -84,7 +87,6 @@ export const firstNegativeValue = (interval) => (interval || []).find((element)
84
87
  export class RawXAxis extends React.Component {
85
88
  static propTypes = {
86
89
  ...AxisPropTypes,
87
- classes: PropTypes.object,
88
90
  graphProps: types.GraphPropsType.isRequired,
89
91
  };
90
92
  static defaultProps = AxisDefaultProps;
@@ -92,7 +94,6 @@ export class RawXAxis extends React.Component {
92
94
  render() {
93
95
  const {
94
96
  includeArrows,
95
- classes,
96
97
  graphProps,
97
98
  columnTicksValues,
98
99
  skipValues,
@@ -124,36 +125,34 @@ export class RawXAxis extends React.Component {
124
125
  const necessaryWidth = amountToIncreaseWidth(longestWord) + 2;
125
126
 
126
127
  return (
127
- <React.Fragment>
128
+ <StyledAxesGroup>
128
129
  <Axis
129
- axisLineClassName={classes.line}
130
130
  scale={scale.x}
131
131
  top={scale.y(0)}
132
132
  left={0}
133
133
  label={domain.label}
134
134
  rangePadding={8}
135
- tickClassName={classes.tick}
136
135
  tickFormat={(value) => value}
137
136
  tickLabelProps={labelProps}
138
137
  tickValues={tickValues}
139
138
  />
140
139
  {includeArrows && includeArrows.left && (
141
- <Arrow direction="left" x={domain.min} y={0} className={classes.arrow} scale={scale} />
140
+ <StyledArrow direction="left" x={domain.min} y={0} scale={scale} />
142
141
  )}
143
142
  {includeArrows && includeArrows.right && (
144
- <Arrow direction="right" x={domain.max} y={0} className={classes.arrow} scale={scale} />
143
+ <StyledArrow direction="right" x={domain.max} y={0} scale={scale} />
145
144
  )}
146
145
  {domain.axisLabel && (
147
146
  <foreignObject x={size.width + 17} y={scale.y(0) - 9} width={necessaryWidth} height={20 * necessaryRows}>
148
- <div dangerouslySetInnerHTML={{ __html: domain.axisLabel }} className={classes.labelFontSize} />
147
+ <StyledLabel dangerouslySetInnerHTML={{ __html: domain.axisLabel }} />
149
148
  </foreignObject>
150
149
  )}
151
- </React.Fragment>
150
+ </StyledAxesGroup>
152
151
  );
153
152
  }
154
153
  }
155
154
 
156
- const XAxis = withStyles(axisStyles)(RawXAxis);
155
+ const XAxis = RawXAxis;
157
156
 
158
157
  export class RawYAxis extends React.Component {
159
158
  static propTypes = {
@@ -163,7 +162,7 @@ export class RawYAxis extends React.Component {
163
162
  static defaultProps = AxisDefaultProps;
164
163
 
165
164
  render() {
166
- const { classes, includeArrows, graphProps, skipValues, rowTickValues } = this.props;
165
+ const { includeArrows, graphProps, skipValues, rowTickValues } = this.props;
167
166
  const { scale, range, size } = graphProps || {};
168
167
 
169
168
  const necessaryWidth = range.axisLabel ? amountToIncreaseWidth(range.axisLabel.length) : 0;
@@ -171,9 +170,8 @@ export class RawYAxis extends React.Component {
171
170
  const customTickFormat = (value) => (skipValues && skipValues.indexOf(value) >= 0 ? '' : value);
172
171
 
173
172
  return (
174
- <React.Fragment>
173
+ <StyledAxesGroup>
175
174
  <Axis
176
- axisLineClassName={classes.line}
177
175
  orientation={'left'}
178
176
  scale={scale.y}
179
177
  top={0}
@@ -183,7 +181,6 @@ export class RawYAxis extends React.Component {
183
181
  labelProps={{ 'data-pie-readable': false }}
184
182
  rangePadding={8}
185
183
  tickLength={10}
186
- tickClassName={classes.tick}
187
184
  tickFormat={customTickFormat}
188
185
  tickLabelProps={(value) => {
189
186
  let digits = value.toLocaleString().replace(/[.-]/g, '').length || 1;
@@ -199,31 +196,29 @@ export class RawYAxis extends React.Component {
199
196
  tickTextAnchor={'bottom'}
200
197
  tickValues={rowTickValues}
201
198
  />
202
-
203
199
  {includeArrows && includeArrows.down && (
204
- <Arrow direction="down" x={0} y={range.min} className={classes.arrow} scale={scale} />
200
+ <StyledArrow direction="down" x={0} y={range.min} scale={scale} />
205
201
  )}
206
202
  {includeArrows && includeArrows.up && (
207
- <Arrow direction="up" x={0} y={range.max} className={classes.arrow} scale={scale} />
203
+ <StyledArrow direction="up" x={0} y={range.max} scale={scale} />
208
204
  )}
209
205
  {range.axisLabel && (
210
206
  <foreignObject x={scale.x(0) - necessaryWidth / 2} y={-33} width={necessaryWidth} height="20">
211
207
  <Readable false>
212
- <div dangerouslySetInnerHTML={{ __html: range.axisLabel }} className={classes.axisLabelHolder} />
208
+ <StyledAxisLabelHolder dangerouslySetInnerHTML={{ __html: range.axisLabel }} />
213
209
  </Readable>
214
210
  </foreignObject>
215
211
  )}
216
- </React.Fragment>
212
+ </StyledAxesGroup>
217
213
  );
218
214
  }
219
215
  }
220
216
 
221
- const YAxis = withStyles(axisStyles)(RawYAxis);
217
+ const YAxis = RawYAxis;
222
218
 
223
219
  export default class Axes extends React.Component {
224
220
  static propTypes = {
225
221
  ...AxisPropTypes,
226
- classes: PropTypes.object,
227
222
  graphProps: types.GraphPropsType.isRequired,
228
223
  };
229
224
  static defaultProps = AxisDefaultProps;
@@ -283,7 +278,7 @@ export default class Axes extends React.Component {
283
278
 
284
279
  // each axis has to be displayed only if the domain & range include it
285
280
  return (
286
- <React.Fragment>
281
+ <StyledAxesGroup>
287
282
  {range.min <= 0 ? (
288
283
  <XAxis
289
284
  {...this.props}
@@ -301,7 +296,7 @@ export default class Axes extends React.Component {
301
296
  distanceFromOriginToFirstNegativeX={distanceFromOriginToFirstNegativeX}
302
297
  />
303
298
  ) : null}
304
- </React.Fragment>
299
+ </StyledAxesGroup>
305
300
  );
306
301
  }
307
302
  }
@@ -2,22 +2,20 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { types } from '@pie-lib/plot';
4
4
  import { color } from '@pie-lib/render-ui';
5
- import { withStyles } from '@material-ui/core/styles';
6
- import InputBase from '@material-ui/core/InputBase';
5
+ import { styled } from '@mui/material/styles';
6
+ import InputBase from '@mui/material/InputBase';
7
7
  import { roundNumber } from './utils';
8
8
 
9
- const styles = (theme) => ({
10
- input: {
11
- fontFamily: theme.typography.fontFamily,
12
- fontSize: theme.typography.fontSize,
13
- borderRadius: '8px',
14
- background: theme.palette.common.white,
15
- color: color.defaults.PRIMARY_DARK,
16
- },
17
- inputLabel: {
9
+ const StyledInputBase = styled(InputBase)(({ theme }) => ({
10
+ fontFamily: theme.typography.fontFamily,
11
+ fontSize: theme.typography.fontSize,
12
+ borderRadius: '8px',
13
+ background: theme.palette.common.white,
14
+ color: color.defaults.PRIMARY_DARK,
15
+ '& .MuiInputBase-input': {
18
16
  padding: 0,
19
17
  },
20
- });
18
+ }));
21
19
 
22
20
  export const getLabelPosition = (graphProps, x, y, labelLength) => {
23
21
  const { scale, domain, range } = graphProps;
@@ -39,7 +37,7 @@ export const getLabelPosition = (graphProps, x, y, labelLength) => {
39
37
  };
40
38
  };
41
39
 
42
- export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
40
+ export const CoordinatesLabel = ({ x, y, graphProps }) => {
43
41
  const label = `(${roundNumber(x)}, ${roundNumber(y)})`;
44
42
  const labelLength = (label.length || 0) * 6;
45
43
  const labelPosition = getLabelPosition(graphProps, x, y, labelLength);
@@ -53,10 +51,8 @@ export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
53
51
  };
54
52
 
55
53
  return (
56
- <InputBase
54
+ <StyledInputBase
57
55
  style={style}
58
- classes={{ input: classes.inputLabel }}
59
- className={classes.input}
60
56
  value={label}
61
57
  inputProps={{ ariaLabel: 'naked' }}
62
58
  />
@@ -65,9 +61,8 @@ export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
65
61
 
66
62
  CoordinatesLabel.propTypes = {
67
63
  graphProps: types.GraphPropsType,
68
- classes: PropTypes.object,
69
64
  x: PropTypes.number,
70
65
  y: PropTypes.number,
71
66
  };
72
67
 
73
- export default withStyles(styles)(CoordinatesLabel);
68
+ export default CoordinatesLabel;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
4
- import classNames from 'classnames';
3
+ import { styled } from '@mui/material/styles';
5
4
  import uniq from 'lodash/uniq';
6
5
  import isString from 'lodash/isString';
7
6
  import { color } from '@pie-lib/render-ui';
@@ -10,8 +9,45 @@ import ToolMenu from './tool-menu';
10
9
  import Graph, { graphPropTypes } from './graph';
11
10
  import UndoRedo from './undo-redo';
12
11
  import { allTools, toolsArr } from './tools';
13
- import { ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary, Typography } from '@material-ui/core';
14
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
12
+ import { Accordion, AccordionDetails, AccordionSummary, Typography } from '@mui/material';
13
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
14
+
15
+ const StyledGraphContainer = styled('div')({
16
+ display: 'flex',
17
+ flexDirection: 'column',
18
+ width: 'min-content',
19
+ });
20
+
21
+ const StyledControls = styled('div')(({ theme }) => ({
22
+ display: 'flex',
23
+ justifyContent: 'space-between',
24
+ padding: theme.spacing(1),
25
+ color: color.text(),
26
+ backgroundColor: color.primaryLight(),
27
+ '& button': {
28
+ fontSize: theme.typography.fontSize,
29
+ },
30
+ }));
31
+
32
+ const StyledAccordion = styled(Accordion)({
33
+ backgroundColor: color.primaryLight(),
34
+ width: '100%',
35
+ });
36
+
37
+ const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
38
+ padding: `0 ${theme.spacing(1)}px`,
39
+ minHeight: '32px !important',
40
+ '& .MuiAccordionSummary-content': {
41
+ margin: '4px 0 !important',
42
+ },
43
+ }));
44
+
45
+ const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
46
+ padding: 0,
47
+ marginTop: theme.spacing(1),
48
+ display: 'flex',
49
+ justifyContent: 'space-between',
50
+ }));
15
51
 
16
52
  export const setToolbarAvailability = (toolbarTools) =>
17
53
  toolsArr.map((tA) => ({ ...tA, toolbar: !!toolbarTools.find((t) => t === tA.type) })) || [];
@@ -29,23 +65,16 @@ export const filterByVisibleToolTypes = (toolbarTools, marks) =>
29
65
 
30
66
  const getDefaultCurrentTool = (toolType) => toolsArr.find((tool) => tool.type === toolType) || null;
31
67
 
32
- const Collapsible = ({ classes, children, title }) => (
33
- <ExpansionPanel elevation={0} className={classes.expansionPanel} disabledGutters={true} square={true}>
34
- <ExpansionPanelSummary
35
- classes={{
36
- root: classes.summaryRoot,
37
- content: classes.summaryContent,
38
- }}
39
- expandIcon={<ExpandMoreIcon />}
40
- >
68
+ const Collapsible = ({ children, title }) => (
69
+ <StyledAccordion elevation={0} disableGutters={true} square={true} TransitionProps={{ timeout: { enter: 225, exit: 195 } }}>
70
+ <StyledAccordionSummary expandIcon={<ExpandMoreIcon />}>
41
71
  <Typography variant="subheading">{title}</Typography>
42
- </ExpansionPanelSummary>
43
- <ExpansionPanelDetails className={classes.details}>{children}</ExpansionPanelDetails>
44
- </ExpansionPanel>
72
+ </StyledAccordionSummary>
73
+ <StyledAccordionDetails>{children}</StyledAccordionDetails>
74
+ </StyledAccordion>
45
75
  );
46
76
 
47
77
  Collapsible.propTypes = {
48
- classes: PropTypes.object,
49
78
  children: PropTypes.array,
50
79
  title: PropTypes.string,
51
80
  };
@@ -96,7 +125,6 @@ export class GraphWithControls extends React.Component {
96
125
  let { currentTool, labelModeEnabled } = this.state;
97
126
  const {
98
127
  axesSettings,
99
- classes,
100
128
  className,
101
129
  coordinatesOnHover,
102
130
  collapsibleToolbar,
@@ -162,16 +190,16 @@ export class GraphWithControls extends React.Component {
162
190
  );
163
191
 
164
192
  return (
165
- <div className={classNames(classes.graphWithControls, className)}>
166
- <div className={classes.controls}>
193
+ <StyledGraphContainer className={className}>
194
+ <StyledControls>
167
195
  {collapsibleToolbar ? (
168
- <Collapsible classes={classes} title={collapsibleToolbarTitle}>
196
+ <Collapsible title={collapsibleToolbarTitle}>
169
197
  {graphActions}
170
198
  </Collapsible>
171
199
  ) : (
172
200
  graphActions
173
201
  )}
174
- </div>
202
+ </StyledControls>
175
203
 
176
204
  <div ref={(r) => (this.labelNode = r)} />
177
205
 
@@ -201,44 +229,9 @@ export class GraphWithControls extends React.Component {
201
229
  removeIncompleteTool={removeIncompleteTool}
202
230
  limitLabeling={limitLabeling}
203
231
  />
204
- </div>
232
+ </StyledGraphContainer>
205
233
  );
206
234
  }
207
235
  }
208
236
 
209
- const styles = (theme) => ({
210
- graphWithControls: {
211
- display: 'flex',
212
- flexDirection: 'column',
213
- width: 'min-content',
214
- },
215
- controls: {
216
- display: 'flex',
217
- justifyContent: 'space-between',
218
- padding: theme.spacing.unit,
219
- color: color.text(),
220
- backgroundColor: color.primaryLight(),
221
- '& button': {
222
- fontSize: theme.typography.fontSize,
223
- },
224
- },
225
- expansionPanel: {
226
- backgroundColor: color.primaryLight(),
227
- width: '100%',
228
- },
229
- summaryRoot: {
230
- padding: `0 ${theme.spacing.unit}px`,
231
- minHeight: '32px !important',
232
- },
233
- summaryContent: {
234
- margin: '4px 0 !important',
235
- },
236
- details: {
237
- padding: 0,
238
- marginTop: theme.spacing.unit,
239
- display: 'flex',
240
- justifyContent: 'space-between',
241
- },
242
- });
243
-
244
- export default withStyles(styles)(GraphWithControls);
237
+ export default GraphWithControls;