@pie-lib/charting 5.34.0 → 5.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 (77) hide show
  1. package/CHANGELOG.md +19 -4
  2. package/lib/actions-button.js +49 -88
  3. package/lib/actions-button.js.map +1 -1
  4. package/lib/axes.js +175 -233
  5. package/lib/axes.js.map +1 -1
  6. package/lib/bars/bar.js +13 -41
  7. package/lib/bars/bar.js.map +1 -1
  8. package/lib/bars/common/bars.js +55 -126
  9. package/lib/bars/common/bars.js.map +1 -1
  10. package/lib/bars/common/correct-check-icon.js +1 -6
  11. package/lib/bars/common/correct-check-icon.js.map +1 -1
  12. package/lib/bars/histogram.js +13 -41
  13. package/lib/bars/histogram.js.map +1 -1
  14. package/lib/chart-setup.js +110 -184
  15. package/lib/chart-setup.js.map +1 -1
  16. package/lib/chart-type.js +29 -38
  17. package/lib/chart-type.js.map +1 -1
  18. package/lib/chart-types.js +1 -10
  19. package/lib/chart-types.js.map +1 -1
  20. package/lib/chart.js +74 -146
  21. package/lib/chart.js.map +1 -1
  22. package/lib/common/correctness-indicators.js +74 -52
  23. package/lib/common/correctness-indicators.js.map +1 -1
  24. package/lib/common/drag-handle.js +67 -105
  25. package/lib/common/drag-handle.js.map +1 -1
  26. package/lib/common/drag-icon.js +6 -12
  27. package/lib/common/drag-icon.js.map +1 -1
  28. package/lib/common/styles.js +6 -24
  29. package/lib/common/styles.js.map +1 -1
  30. package/lib/grid.js +44 -81
  31. package/lib/grid.js.map +1 -1
  32. package/lib/index.js +0 -6
  33. package/lib/index.js.map +1 -1
  34. package/lib/key-legend.js +63 -87
  35. package/lib/key-legend.js.map +1 -1
  36. package/lib/line/common/drag-handle.js +69 -100
  37. package/lib/line/common/drag-handle.js.map +1 -1
  38. package/lib/line/common/line.js +44 -92
  39. package/lib/line/common/line.js.map +1 -1
  40. package/lib/line/line-cross.js +77 -87
  41. package/lib/line/line-cross.js.map +1 -1
  42. package/lib/line/line-dot.js +66 -78
  43. package/lib/line/line-dot.js.map +1 -1
  44. package/lib/mark-label.js +75 -117
  45. package/lib/mark-label.js.map +1 -1
  46. package/lib/plot/common/plot.js +76 -144
  47. package/lib/plot/common/plot.js.map +1 -1
  48. package/lib/plot/dot.js +31 -57
  49. package/lib/plot/dot.js.map +1 -1
  50. package/lib/plot/line.js +37 -62
  51. package/lib/plot/line.js.map +1 -1
  52. package/lib/tool-menu.js +48 -80
  53. package/lib/tool-menu.js.map +1 -1
  54. package/lib/utils.js +20 -77
  55. package/lib/utils.js.map +1 -1
  56. package/package.json +12 -9
  57. package/src/actions-button.jsx +36 -37
  58. package/src/axes.jsx +80 -75
  59. package/src/bars/common/bars.jsx +8 -23
  60. package/src/chart-setup.jsx +68 -78
  61. package/src/chart-type.js +26 -21
  62. package/src/chart.jsx +8 -20
  63. package/src/common/correctness-indicators.jsx +51 -13
  64. package/src/common/drag-handle.jsx +44 -59
  65. package/src/common/drag-icon.jsx +2 -2
  66. package/src/common/styles.js +1 -1
  67. package/src/grid.jsx +9 -13
  68. package/src/key-legend.jsx +62 -60
  69. package/src/line/common/drag-handle.jsx +57 -55
  70. package/src/line/common/line.jsx +17 -8
  71. package/src/line/line-cross.js +37 -12
  72. package/src/line/line-dot.js +30 -11
  73. package/src/mark-label.jsx +43 -44
  74. package/src/plot/common/plot.jsx +17 -22
  75. package/src/plot/dot.js +10 -3
  76. package/src/plot/line.js +14 -6
  77. package/src/tool-menu.jsx +20 -23
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import Check from '@material-ui/icons/Check';
5
- import { withStyles } from '@material-ui/core/styles/index';
4
+ import Check from '@mui/icons-material/Check';
5
+ import { styled } from '@mui/material/styles';
6
6
  import { Group } from '@vx/group';
7
7
  import debug from 'debug';
8
8
 
@@ -19,7 +19,6 @@ export class RawPlot extends React.Component {
19
19
  static propTypes = {
20
20
  onChangeCategory: PropTypes.func,
21
21
  value: PropTypes.number,
22
- classes: PropTypes.object,
23
22
  label: PropTypes.string,
24
23
  xBand: PropTypes.func,
25
24
  index: PropTypes.number.isRequired,
@@ -68,7 +67,7 @@ export class RawPlot extends React.Component {
68
67
  this.setDragValue(next);
69
68
  };
70
69
 
71
- renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, classes, scale, pointHeight, pointDiameter) => {
70
+ renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, scale, pointHeight, pointDiameter) => {
72
71
  let iconY;
73
72
 
74
73
  if (correctVal === 0) {
@@ -83,7 +82,7 @@ export class RawPlot extends React.Component {
83
82
  return (
84
83
  <foreignObject x={barX + barWidth / 2 - ICON_SIZE / 2} y={iconY} width={ICON_SIZE} height={ICON_SIZE}>
85
84
  <Check
86
- className={classNames(classes.correctnessIcon, classes.correctIcon, classes.smallIcon)}
85
+ className={classNames('correctnessIcon', 'correctIcon', 'smallIcon')}
87
86
  title={correctness.label}
88
87
  />
89
88
  </foreignObject>
@@ -95,7 +94,6 @@ export class RawPlot extends React.Component {
95
94
  graphProps,
96
95
  value,
97
96
  label,
98
- classes,
99
97
  xBand,
100
98
  index,
101
99
  CustomBarElement,
@@ -103,6 +101,7 @@ export class RawPlot extends React.Component {
103
101
  correctness,
104
102
  defineChart,
105
103
  correctData,
104
+ className
106
105
  } = this.props;
107
106
 
108
107
  const { scale, range, size } = graphProps;
@@ -130,6 +129,7 @@ export class RawPlot extends React.Component {
130
129
  return (
131
130
  <React.Fragment>
132
131
  <g
132
+ className={className}
133
133
  onMouseEnter={this.handleMouseEnter}
134
134
  onMouseLeave={this.handleMouseLeave}
135
135
  onTouchStart={this.handleMouseEnter}
@@ -155,7 +155,6 @@ export class RawPlot extends React.Component {
155
155
  pointHeight,
156
156
  label,
157
157
  value,
158
- classes,
159
158
  scale,
160
159
  }),
161
160
  )}
@@ -173,7 +172,6 @@ export class RawPlot extends React.Component {
173
172
  barWidth,
174
173
  correctVal,
175
174
  correctness,
176
- classes,
177
175
  scale,
178
176
  pointHeight,
179
177
  pointDiameter,
@@ -202,7 +200,6 @@ export class RawPlot extends React.Component {
202
200
  pointHeight={pointHeight}
203
201
  label={label}
204
202
  value={value}
205
- classes={classes}
206
203
  scale={scale}
207
204
  dottedOverline={true}
208
205
  />
@@ -211,7 +208,6 @@ export class RawPlot extends React.Component {
211
208
  barWidth,
212
209
  correctVal,
213
210
  correctness,
214
- classes,
215
211
  scale,
216
212
  pointHeight,
217
213
  pointDiameter,
@@ -235,7 +231,6 @@ export class RawPlot extends React.Component {
235
231
  pointHeight,
236
232
  label,
237
233
  value,
238
- classes,
239
234
  scale,
240
235
  dottedOverline: true,
241
236
  }),
@@ -245,7 +240,6 @@ export class RawPlot extends React.Component {
245
240
  barWidth,
246
241
  correctVal,
247
242
  correctness,
248
- classes,
249
243
  scale,
250
244
  pointHeight,
251
245
  pointDiameter,
@@ -273,30 +267,30 @@ export class RawPlot extends React.Component {
273
267
  }
274
268
  }
275
269
 
276
- const Bar = withStyles((theme) => ({
277
- dot: {
270
+ const Bar = styled(RawPlot)(({ theme }) => ({
271
+ '& .dot': {
278
272
  fill: color.visualElementsColors.PLOT_FILL_COLOR,
279
273
  '&.correct': correct('stroke'),
280
274
  '&.incorrect': incorrect('stroke'),
281
275
  },
282
- dotColor: {
276
+ '& .dotColor': {
283
277
  fill: color.visualElementsColors.PLOT_FILL_COLOR,
284
278
  '&.correct': correct('fill'),
285
279
  '&.incorrect': incorrect('fill'),
286
280
  },
287
- line: {
281
+ '& .line': {
288
282
  stroke: color.visualElementsColors.PLOT_FILL_COLOR,
289
283
  '&.correct': correct('stroke'),
290
284
  '&.incorrect': incorrect('stroke'),
291
285
  },
292
- correctIcon: {
286
+ '& .correctIcon': {
293
287
  backgroundColor: color.correct(),
294
288
  },
295
- incorrectIcon: {
289
+ '& .incorrectIcon': {
296
290
  backgroundColor: color.incorrectWithIcon(),
297
291
  },
298
- correctnessIcon: {
299
- borderRadius: theme.spacing.unit * 2,
292
+ '& .correctnessIcon': {
293
+ borderRadius: theme.spacing(2),
300
294
  color: color.defaults.WHITE,
301
295
  fontSize: '16px',
302
296
  width: '16px',
@@ -305,13 +299,14 @@ const Bar = withStyles((theme) => ({
305
299
  border: `1px solid ${color.defaults.WHITE}`,
306
300
  stroke: 'initial',
307
301
  boxSizing: 'unset', // to override the default border-box in IBX
302
+ display: 'block',
308
303
  },
309
- smallIcon: {
304
+ '& .smallIcon': {
310
305
  fontSize: '10px',
311
306
  width: '10px',
312
307
  height: '10px',
313
308
  },
314
- }))(RawPlot);
309
+ }));
315
310
 
316
311
  export class Plot extends React.Component {
317
312
  static propTypes = {
package/src/plot/dot.js CHANGED
@@ -6,9 +6,17 @@ import { types } from '@pie-lib/plot';
6
6
  import { dataToXBand } from '../utils';
7
7
  import Plot from './common/plot';
8
8
  import { color } from '@pie-lib/render-ui';
9
+ import { styled } from '@mui/material/styles';
10
+ import { correct, incorrect } from '../common/styles';
11
+
12
+ const StyledCircle = styled(Circle)(() => ({
13
+ fill: color.visualElementsColors.PLOT_FILL_COLOR,
14
+ '&.correct': correct('stroke'),
15
+ '&.incorrect': incorrect('stroke'),
16
+ }));
9
17
 
10
18
  const CustomBarElement = (props) => {
11
- const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale, dottedOverline } = props;
19
+ const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
12
20
 
13
21
  const r = pointDiameter / 2;
14
22
  const cx = barX + (barWidth - pointDiameter) / 2 + r;
@@ -26,7 +34,7 @@ const CustomBarElement = (props) => {
26
34
  fill="none"
27
35
  />
28
36
  ) : (
29
- <Circle key={`point-${label}-${value}-${index}`} className={classes.dot} cx={cx} cy={cy} r={r} />
37
+ <StyledCircle key={`point-${label}-${value}-${index}`} cx={cx} cy={cy} r={r} />
30
38
  );
31
39
  };
32
40
 
@@ -38,7 +46,6 @@ CustomBarElement.propTypes = {
38
46
  pointHeight: PropTypes.number,
39
47
  value: PropTypes.number,
40
48
  label: PropTypes.string,
41
- classes: PropTypes.object,
42
49
  scale: PropTypes.object,
43
50
  dottedOverline: PropTypes.bool,
44
51
  };
package/src/plot/line.js CHANGED
@@ -2,14 +2,22 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { LinePath } from '@vx/shape';
4
4
  import { Group } from '@vx/group';
5
+ import { styled } from '@mui/material/styles';
5
6
 
6
7
  import { types } from '@pie-lib/plot';
7
8
  import { dataToXBand } from '../utils';
8
9
  import { color } from '@pie-lib/render-ui';
9
10
  import Plot from './common/plot';
11
+ import { correct, incorrect } from '../common/styles';
12
+
13
+ const StyledLinePath = styled(LinePath)(() => ({
14
+ stroke: color.visualElementsColors.PLOT_FILL_COLOR,
15
+ '&.correct': correct('stroke'),
16
+ '&.incorrect': incorrect('stroke'),
17
+ }));
10
18
 
11
19
  const CustomBarElement = (props) => {
12
- const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale, dottedOverline } = props;
20
+ const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
13
21
 
14
22
  const x = barX + (barWidth - pointDiameter) / 2;
15
23
  const y = scale.y(index) - (pointHeight - pointDiameter) / 2;
@@ -28,27 +36,27 @@ const CustomBarElement = (props) => {
28
36
  />
29
37
  ) : (
30
38
  <Group>
31
- <LinePath
39
+ <StyledLinePath
32
40
  data={[
33
41
  { x, y },
34
42
  { x: x + pointDiameter, y: y - pointDiameter },
35
43
  ]}
36
44
  key={`point-${label}-${value}-${index}-1`}
37
- className={classes.line}
45
+ className={'line'}
38
46
  x={(d) => d.x}
39
47
  y={(d) => d.y}
40
48
  strokeWidth={pointDiameter / 5}
41
49
  />
42
- <LinePath
50
+ <StyledLinePath
43
51
  data={[
44
52
  { x, y: y - pointDiameter },
45
53
  { x: x + pointDiameter, y },
46
54
  ]}
47
55
  key={`point-${label}-${value}-${index}-2`}
48
- className={classes.line}
49
56
  x={(d) => d.x}
50
57
  y={(d) => d.y}
51
58
  strokeWidth={pointDiameter / 5}
59
+ className={'line'}
52
60
  />
53
61
  </Group>
54
62
  );
@@ -62,8 +70,8 @@ CustomBarElement.propTypes = {
62
70
  pointHeight: PropTypes.number,
63
71
  value: PropTypes.number,
64
72
  label: PropTypes.string,
65
- classes: PropTypes.object,
66
73
  scale: PropTypes.object,
74
+ dottedOverline: PropTypes.bool,
67
75
  };
68
76
 
69
77
  export class LinePlot extends React.Component {
package/src/tool-menu.jsx CHANGED
@@ -3,57 +3,54 @@ import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
  import { color } from '@pie-lib/render-ui';
5
5
 
6
- import { withStyles } from '@material-ui/core/styles';
7
- import cn from 'classnames';
8
- import Button from '@material-ui/core/Button';
6
+ import { styled } from '@mui/material/styles';
7
+ import Button from '@mui/material/Button';
9
8
  import Translator from '@pie-lib/translator';
10
9
 
11
10
  const { translator } = Translator;
12
11
 
13
- const buttonStyles = (theme) => ({
14
- root: {
15
- color: color.text(),
16
- border: `1px solid ${color.secondary()}`,
17
- fontSize: theme.typography.fontSize,
18
- },
19
- selected: {
12
+ const StyledMiniButton = styled(Button)(({ theme, selected, disabled }) => ({
13
+ color: color.text(),
14
+ border: `1px solid ${color.secondary()}`,
15
+ fontSize: theme.typography.fontSize,
16
+ ...(selected && {
20
17
  backgroundColor: color.background(),
21
18
  '& span': {
22
19
  color: color.primaryDark(),
23
20
  },
24
- },
25
- notSelected: {
21
+ }),
22
+ ...(!selected && !disabled && {
26
23
  '& span': {
27
24
  color: color.primary(),
28
25
  },
29
26
  backgroundColor: color.background(),
30
- },
31
- disabled: {
27
+ }),
28
+ ...(disabled && {
32
29
  '& span': {
33
30
  color: color.primary(),
34
31
  },
35
32
  backgroundColor: color.disabled(),
36
- },
37
- });
33
+ }),
34
+ }));
38
35
 
39
- export const MiniButton = withStyles(buttonStyles)((props) => {
40
- const { disabled, classes, className, selected, value, onClick } = props;
36
+ export const MiniButton = (props) => {
37
+ const { disabled, className, selected, value, onClick } = props;
41
38
  return (
42
- <Button
39
+ <StyledMiniButton
43
40
  size="small"
44
41
  disabled={disabled}
42
+ selected={selected}
45
43
  color={selected ? 'secondary' : 'default'}
46
- className={cn(classes.root, selected && classes.selected, className)}
47
- classes={{ disabled: cn(disabled && classes.disabled) }}
44
+ className={className}
48
45
  value={value}
49
46
  key={value}
50
47
  variant="outlined"
51
48
  onClick={onClick}
52
49
  >
53
50
  {value}
54
- </Button>
51
+ </StyledMiniButton>
55
52
  );
56
- });
53
+ };
57
54
  MiniButton.propTypes = {
58
55
  disabled: PropTypes.bool,
59
56
  className: PropTypes.string,