@pie-lib/graphing-solution-set 2.34.1 → 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.
Files changed (97) hide show
  1. package/CHANGELOG.md +10 -15
  2. package/lib/axis/arrow.js +19 -55
  3. package/lib/axis/arrow.js.map +1 -1
  4. package/lib/axis/axes.js +101 -184
  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 -60
  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 +132 -203
  23. package/lib/graph-with-controls.js.map +1 -1
  24. package/lib/graph.js +61 -126
  25. package/lib/graph.js.map +1 -1
  26. package/lib/grid-setup.js +161 -223
  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 -12
  31. package/lib/index.js.map +1 -1
  32. package/lib/labels.js +84 -184
  33. package/lib/labels.js.map +1 -1
  34. package/lib/mark-label.js +40 -88
  35. package/lib/mark-label.js.map +1 -1
  36. package/lib/toggle-bar.js +158 -242
  37. package/lib/toggle-bar.js.map +1 -1
  38. package/lib/tool-menu.js +93 -200
  39. package/lib/tool-menu.js.map +1 -1
  40. package/lib/tools/index.js +2 -7
  41. package/lib/tools/index.js.map +1 -1
  42. package/lib/tools/line/component.js +48 -62
  43. package/lib/tools/line/component.js.map +1 -1
  44. package/lib/tools/line/index.js +1 -6
  45. package/lib/tools/line/index.js.map +1 -1
  46. package/lib/tools/polygon/component.js +75 -172
  47. package/lib/tools/polygon/component.js.map +1 -1
  48. package/lib/tools/polygon/index.js +6 -23
  49. package/lib/tools/polygon/index.js.map +1 -1
  50. package/lib/tools/polygon/line.js +48 -85
  51. package/lib/tools/polygon/line.js.map +1 -1
  52. package/lib/tools/polygon/polygon.js +64 -102
  53. package/lib/tools/polygon/polygon.js.map +1 -1
  54. package/lib/tools/shared/arrow-head.js +7 -20
  55. package/lib/tools/shared/arrow-head.js.map +1 -1
  56. package/lib/tools/shared/line/index.js +86 -182
  57. package/lib/tools/shared/line/index.js.map +1 -1
  58. package/lib/tools/shared/line/line-path.js +70 -94
  59. package/lib/tools/shared/line/line-path.js.map +1 -1
  60. package/lib/tools/shared/line/with-root-edge.js +21 -55
  61. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  62. package/lib/tools/shared/point/arrow-point.js +18 -45
  63. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  64. package/lib/tools/shared/point/arrow.js +16 -42
  65. package/lib/tools/shared/point/arrow.js.map +1 -1
  66. package/lib/tools/shared/point/base-point.js +22 -52
  67. package/lib/tools/shared/point/base-point.js.map +1 -1
  68. package/lib/tools/shared/point/index.js +30 -52
  69. package/lib/tools/shared/point/index.js.map +1 -1
  70. package/lib/tools/shared/styles.js +8 -31
  71. package/lib/tools/shared/styles.js.map +1 -1
  72. package/lib/tools/shared/types.js +1 -5
  73. package/lib/tools/shared/types.js.map +1 -1
  74. package/lib/undo-redo.js +27 -67
  75. package/lib/undo-redo.js.map +1 -1
  76. package/lib/use-debounce.js +4 -11
  77. package/lib/use-debounce.js.map +1 -1
  78. package/lib/utils.js +56 -131
  79. package/lib/utils.js.map +1 -1
  80. package/package.json +16 -14
  81. package/src/axis/arrow.jsx +7 -12
  82. package/src/axis/axes.jsx +32 -37
  83. package/src/coordinates-label.jsx +13 -18
  84. package/src/graph-with-controls.jsx +90 -93
  85. package/src/grid-setup.jsx +204 -206
  86. package/src/grid.jsx +1 -3
  87. package/src/labels.jsx +83 -124
  88. package/src/mark-label.jsx +14 -25
  89. package/src/toggle-bar.jsx +155 -166
  90. package/src/tool-menu.jsx +136 -195
  91. package/src/tools/line/component.jsx +29 -29
  92. package/src/tools/polygon/component.jsx +1 -3
  93. package/src/tools/polygon/line.jsx +26 -24
  94. package/src/tools/polygon/polygon.jsx +34 -39
  95. package/src/tools/shared/line/line-path.jsx +50 -47
  96. package/src/tools/shared/point/index.jsx +22 -34
  97. package/src/undo-redo.jsx +16 -24
@@ -1,13 +1,37 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
3
+ import { alpha, styled } from '@mui/material/styles';
4
4
  import { gridDraggable, types } from '@pie-lib/plot';
5
5
  import * as utils from '../../utils';
6
- import classNames from 'classnames';
7
6
  import { color } from '@pie-lib/render-ui';
8
- import { fade } from '@material-ui/core/styles/colorManipulator';
9
7
  import { correct, disabled, incorrect } from '../shared/styles';
10
8
 
9
+ const StyledPolygon = styled('polygon', {
10
+ shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
11
+ })(({ theme, isSolution, correctness }) => ({
12
+ fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
13
+ strokeWidth: 2,
14
+ stroke: color.defaults.SECONDARY_LIGHT,
15
+ '&:hover': {
16
+ fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
17
+ },
18
+ ...(correctness === 'correct' && correct('stroke')),
19
+ ...(correctness === 'incorrect' && incorrect('stroke')),
20
+ }));
21
+
22
+ const StyledPolyline = styled('polyline', {
23
+ shouldForwardProp: (prop) => !['isSolution', 'correctness'].includes(prop),
24
+ })(({ theme, isSolution, correctness }) => ({
25
+ fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'transparent',
26
+ strokeWidth: 2,
27
+ stroke: color.defaults.SECONDARY_LIGHT,
28
+ '&:hover': {
29
+ fill: isSolution ? 'rgb(60, 73, 150, 0.6)' : 'rgb(0, 0, 0, 0.25)',
30
+ },
31
+ ...(correctness === 'correct' && correct('stroke')),
32
+ ...(correctness === 'incorrect' && incorrect('stroke')),
33
+ }));
34
+
11
35
  export const getPointString = (points, scale) => {
12
36
  return (points || [])
13
37
  .map((p) => {
@@ -22,7 +46,6 @@ export const getPointString = (points, scale) => {
22
46
 
23
47
  export class RawPolygon extends React.Component {
24
48
  static propTypes = {
25
- classes: PropTypes.object,
26
49
  className: PropTypes.string,
27
50
  isSolution: PropTypes.bool,
28
51
  points: PropTypes.arrayOf(types.PointType),
@@ -36,52 +59,24 @@ export class RawPolygon extends React.Component {
36
59
  };
37
60
 
38
61
  render() {
39
- const { points, classes, className, correctness, graphProps, closed, isSolution, ...rest } = this.props;
62
+ const { points, className, correctness, graphProps, closed, isSolution, ...rest } = this.props;
40
63
  const { scale } = graphProps;
41
64
 
42
65
  const pointString = getPointString(points, scale);
43
- const Tag = closed ? 'polygon' : 'polyline';
66
+ const Component = closed ? StyledPolygon : StyledPolyline;
44
67
  return (
45
- <Tag
68
+ <Component
46
69
  points={pointString}
47
- className={classNames(isSolution ? classes.gssSolution : classes.gssClosed, classes[correctness], className)}
70
+ isSolution={isSolution}
71
+ correctness={correctness}
72
+ className={className}
48
73
  {...rest}
49
74
  />
50
75
  );
51
76
  }
52
77
  }
53
78
 
54
- export const Polygon = withStyles((theme) => ({
55
- closed: {
56
- fill: fade(theme.palette.primary.light, 0.2), // TODO hardcoded color
57
- strokeWidth: 2,
58
- stroke: color.defaults.SECONDARY_LIGHT,
59
- },
60
- open: {
61
- fill: fade(theme.palette.primary.light, 0.0), // TODO hardcoded color
62
- strokeWidth: 2,
63
- stroke: color.defaults.SECONDARY_LIGHT,
64
- pointerEvents: 'none',
65
- },
66
- gssClosed: {
67
- fill: 'transparent',
68
- '&:hover': {
69
- fill: 'rgb(0, 0, 0, 0.25)',
70
- },
71
- },
72
- gssSolution: {
73
- fill: 'rgb(60, 73, 150, 0.6)',
74
- },
75
- disabled: {
76
- ...disabled('stroke'),
77
- },
78
- correct: {
79
- ...correct('stroke'),
80
- },
81
- incorrect: {
82
- ...incorrect('stroke'),
83
- },
84
- }))(RawPolygon);
79
+ export const Polygon = RawPolygon;
85
80
 
86
81
  export default gridDraggable({
87
82
  bounds: (props, { domain, range }) => {
@@ -1,16 +1,52 @@
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 classNames from 'classnames';
6
5
  import { disabled, correct, incorrect, missing } from '../styles';
7
6
  import * as vx from '@vx/shape';
8
7
  import { color } from '@pie-lib/render-ui';
9
8
 
9
+ const dragging = () => ({
10
+ strokeWidth: 7,
11
+ stroke: color.defaults.BLACK,
12
+ });
13
+
14
+ const StyledDrawLine = styled(vx.LinePath, {
15
+ shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
16
+ })(({ disabled: isDisabled, correctness }) => ({
17
+ fill: 'none',
18
+ strokeWidth: 2,
19
+ stroke: color.secondaryLight(),
20
+ ...(isDisabled && {
21
+ ...disabled('stroke'),
22
+ strokeWidth: 2,
23
+ }),
24
+ ...(correctness === 'correct' && correct('stroke')),
25
+ ...(correctness === 'incorrect' && incorrect('stroke')),
26
+ ...(correctness === 'missing' && missing('stroke')),
27
+ }));
28
+
29
+ const StyledInteractionLine = styled(vx.LinePath, {
30
+ shouldForwardProp: (prop) => !['disabled', 'correctness', 'isDragging'].includes(prop),
31
+ })(({ disabled: isDisabled, correctness, isDragging }) => ({
32
+ strokeWidth: 6,
33
+ fill: 'none',
34
+ transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
35
+ stroke: 'transparent',
36
+ '&:hover': dragging(),
37
+ ...(isDragging && dragging()),
38
+ ...(isDisabled && {
39
+ ...disabled('stroke'),
40
+ strokeWidth: 2,
41
+ }),
42
+ ...(correctness === 'correct' && correct('stroke')),
43
+ ...(correctness === 'incorrect' && incorrect('stroke')),
44
+ ...(correctness === 'missing' && missing('stroke')),
45
+ }));
46
+
10
47
  export class RawLinePath extends React.Component {
11
48
  static propTypes = {
12
49
  className: PropTypes.string,
13
- classes: PropTypes.object,
14
50
  data: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
15
51
  graphProps: types.GraphPropsType.isRequired,
16
52
  disabled: PropTypes.bool,
@@ -27,25 +63,24 @@ export class RawLinePath extends React.Component {
27
63
 
28
64
  render() {
29
65
  /* eslint-disable no-unused-vars */
30
- const { data, classes, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
66
+ const { data, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
31
67
  /* eslint-enable */
32
68
 
33
69
  return (
34
70
  <React.Fragment>
35
- <vx.LinePath
71
+ <StyledDrawLine
36
72
  data={data}
37
- className={classNames(classes.drawLine, disabled && classes.disabled, classes[correctness], className)}
73
+ disabled={disabled}
74
+ correctness={correctness}
75
+ className={className}
38
76
  {...rest}
39
77
  />
40
- <vx.LinePath
78
+ <StyledInteractionLine
41
79
  data={data}
42
- className={classNames(
43
- classes.line,
44
- isDragging && classes.dragging,
45
- disabled && classes.disabled,
46
- classes[correctness],
47
- className,
48
- )}
80
+ isDragging={isDragging}
81
+ disabled={disabled}
82
+ correctness={correctness}
83
+ className={className}
49
84
  {...rest}
50
85
  />
51
86
  </React.Fragment>
@@ -53,36 +88,4 @@ export class RawLinePath extends React.Component {
53
88
  }
54
89
  }
55
90
 
56
- const dragging = () => ({
57
- strokeWidth: 7,
58
- stroke: color.defaults.BLACK,
59
- });
60
-
61
- export const LinePath = withStyles((theme) => ({
62
- drawLine: {
63
- fill: 'none',
64
- strokeWidth: 2,
65
- stroke: color.secondaryLight(),
66
- },
67
- line: {
68
- strokeWidth: 6,
69
- fill: 'none',
70
- transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
71
- stroke: 'transparent',
72
- '&:hover': dragging(theme),
73
- },
74
- dragging: dragging(theme),
75
- disabled: {
76
- ...disabled('stroke'),
77
- strokeWidth: 2,
78
- },
79
- correct: {
80
- ...correct('stroke'),
81
- },
82
- incorrect: {
83
- ...incorrect('stroke'),
84
- },
85
- missing: {
86
- ...missing('stroke'),
87
- },
88
- }))(RawLinePath);
91
+ export const LinePath = RawLinePath;
@@ -1,4 +1,4 @@
1
- import { withStyles } from '@material-ui/core/styles/index';
1
+ import { styled } from '@mui/material/styles';
2
2
  import { gridDraggable } from '@pie-lib/plot';
3
3
  import * as utils from '../../../utils';
4
4
  import { disabled, correct, incorrect, missing } from '../styles';
@@ -24,37 +24,25 @@ const opts = {
24
24
  },
25
25
  };
26
26
 
27
- const styles = () => {
28
- return {
29
- point: {
30
- '& circle, & polygon': {
31
- cursor: 'pointer',
32
- fill: color.defaults.SECONDARY,
33
- },
34
- },
35
- disabled: {
36
- '& circle, & polygon': {
37
- ...disabled(),
38
- },
39
- },
40
- correct: {
41
- '& circle, & polygon': {
42
- ...correct(),
43
- },
44
- },
45
- incorrect: {
46
- '& circle, & polygon': {
47
- ...incorrect(),
48
- },
49
- },
50
- missing: {
51
- '& circle, & polygon': {
52
- ...missing(),
53
- },
54
- },
55
- };
56
- };
27
+ const StyledPointWrapper = styled('g', {
28
+ shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
29
+ })(({ disabled: isDisabled, correctness }) => ({
30
+ '& circle, & polygon': {
31
+ cursor: 'pointer',
32
+ fill: color.defaults.SECONDARY,
33
+ ...(isDisabled && disabled()),
34
+ ...(correctness === 'correct' && correct()),
35
+ ...(correctness === 'incorrect' && incorrect()),
36
+ ...(correctness === 'missing' && missing()),
37
+ },
38
+ }));
39
+
40
+ const withStyledWrapper = (WrappedComponent) => (props) => (
41
+ <StyledPointWrapper disabled={props.disabled} correctness={props.correctness}>
42
+ <WrappedComponent {...props} />
43
+ </StyledPointWrapper>
44
+ );
57
45
 
58
- export const BasePoint = withStyles(styles)(gridDraggable(opts)(RawBp));
59
- export const ArrowPoint = withStyles(styles)(gridDraggable(opts)(RawArrow));
60
- export const Arrow = withStyles(styles)(gridDraggable(opts)(BaseArrow));
46
+ export const BasePoint = gridDraggable(opts)(withStyledWrapper(RawBp));
47
+ export const ArrowPoint = gridDraggable(opts)(withStyledWrapper(RawArrow));
48
+ export const Arrow = gridDraggable(opts)(withStyledWrapper(BaseArrow));
package/src/undo-redo.jsx CHANGED
@@ -1,16 +1,23 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import Button from '@material-ui/core/Button';
5
- import { withStyles } from '@material-ui/core';
3
+ import { styled } from '@mui/material/styles';
4
+ import Button from '@mui/material/Button';
6
5
  import { color } from '@pie-lib/render-ui';
7
6
  import Translator from '@pie-lib/translator';
8
7
 
9
8
  const { translator } = Translator;
10
9
 
10
+ const StyledButton = styled(Button)(({ theme }) => ({
11
+ color: color.text(),
12
+ fontWeight: 'bold',
13
+ marginBottom: theme.spacing(0.5),
14
+ '&:not(:last-of-type)': {
15
+ marginRight: theme.spacing(0.5),
16
+ },
17
+ }));
18
+
11
19
  export class UndoRedo extends React.Component {
12
20
  static propTypes = {
13
- classes: PropTypes.object,
14
21
  className: PropTypes.string,
15
22
  onReset: PropTypes.func.isRequired,
16
23
  language: PropTypes.string,
@@ -18,30 +25,15 @@ export class UndoRedo extends React.Component {
18
25
  static defaultProps = {};
19
26
 
20
27
  render() {
21
- const { classes, className, onReset = false, language } = this.props;
28
+ const { className, onReset = false, language } = this.props;
22
29
  return (
23
- <div className={classNames(className)}>
24
- <Button classes={{ root: classes.button }} onClick={() => onReset()}>
30
+ <div className={className}>
31
+ <StyledButton onClick={() => onReset()}>
25
32
  {translator.t('graphing.reset', { lng: language })}
26
- </Button>
33
+ </StyledButton>
27
34
  </div>
28
35
  );
29
36
  }
30
37
  }
31
38
 
32
- const styles = (theme) => ({
33
- button: {
34
- color: color.text(),
35
- fontWeight: 'bold',
36
- marginBottom: theme.spacing.unit / 2,
37
- '&:not(:last-of-type)': {
38
- marginRight: theme.spacing.unit / 2,
39
- },
40
- },
41
- undoRedoDiv: {
42
- display: 'flex',
43
- flexDirection: 'row',
44
- },
45
- });
46
-
47
- export default withStyles(styles)(UndoRedo);
39
+ export default UndoRedo;