@pie-lib/graphing-solution-set 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 (169) hide show
  1. package/CHANGELOG.md +7 -78
  2. package/lib/__tests__/graph-with-controls.test.js +199 -0
  3. package/lib/__tests__/graph.test.js +114 -0
  4. package/lib/__tests__/grid.test.js +29 -0
  5. package/lib/__tests__/labels.test.js +45 -0
  6. package/lib/__tests__/mark-label.test.js +133 -0
  7. package/lib/__tests__/toggle-bar.test.js +89 -0
  8. package/lib/__tests__/tool-menu.test.js +41 -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 +162 -0
  15. package/lib/axis/arrow.js +20 -56
  16. package/lib/axis/arrow.js.map +1 -1
  17. package/lib/axis/axes.js +104 -194
  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 -61
  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 +24 -56
  34. package/lib/coordinates-label.js.map +1 -1
  35. package/lib/graph-with-controls.js +130 -204
  36. package/lib/graph-with-controls.js.map +1 -1
  37. package/lib/graph.js +62 -127
  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 -13
  44. package/lib/index.js.map +1 -1
  45. package/lib/labels.js +85 -185
  46. package/lib/labels.js.map +1 -1
  47. package/lib/mark-label.js +40 -89
  48. package/lib/mark-label.js.map +1 -1
  49. package/lib/toggle-bar.js +156 -244
  50. package/lib/toggle-bar.js.map +1 -1
  51. package/lib/tool-menu.js +94 -201
  52. package/lib/tool-menu.js.map +1 -1
  53. package/lib/tools/index.js +3 -8
  54. package/lib/tools/index.js.map +1 -1
  55. package/lib/tools/line/__tests__/component.test.js +45 -0
  56. package/lib/tools/line/component.js +49 -63
  57. package/lib/tools/line/component.js.map +1 -1
  58. package/lib/tools/line/index.js +2 -7
  59. package/lib/tools/line/index.js.map +1 -1
  60. package/lib/tools/polygon/__tests__/component.test.js +81 -0
  61. package/lib/tools/polygon/__tests__/index.test.js +92 -0
  62. package/lib/tools/polygon/__tests__/line.test.js +30 -0
  63. package/lib/tools/polygon/__tests__/polygon.test.js +61 -0
  64. package/lib/tools/polygon/component.js +77 -174
  65. package/lib/tools/polygon/component.js.map +1 -1
  66. package/lib/tools/polygon/index.js +7 -24
  67. package/lib/tools/polygon/index.js.map +1 -1
  68. package/lib/tools/polygon/line.js +49 -86
  69. package/lib/tools/polygon/line.js.map +1 -1
  70. package/lib/tools/polygon/polygon.js +63 -103
  71. package/lib/tools/polygon/polygon.js.map +1 -1
  72. package/lib/tools/shared/__tests__/arrow-head.test.js +45 -0
  73. package/lib/tools/shared/arrow-head.js +8 -21
  74. package/lib/tools/shared/arrow-head.js.map +1 -1
  75. package/lib/tools/shared/line/__tests__/index.test.js +129 -0
  76. package/lib/tools/shared/line/__tests__/line-path.test.js +64 -0
  77. package/lib/tools/shared/line/__tests__/with-root-edge.test.js +83 -0
  78. package/lib/tools/shared/line/index.js +90 -186
  79. package/lib/tools/shared/line/index.js.map +1 -1
  80. package/lib/tools/shared/line/line-path.js +72 -96
  81. package/lib/tools/shared/line/line-path.js.map +1 -1
  82. package/lib/tools/shared/line/with-root-edge.js +23 -57
  83. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  84. package/lib/tools/shared/point/__tests__/arrow-point.test.js +127 -0
  85. package/lib/tools/shared/point/__tests__/base-point.test.js +122 -0
  86. package/lib/tools/shared/point/arrow-point.js +19 -46
  87. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  88. package/lib/tools/shared/point/arrow.js +17 -43
  89. package/lib/tools/shared/point/arrow.js.map +1 -1
  90. package/lib/tools/shared/point/base-point.js +45 -59
  91. package/lib/tools/shared/point/base-point.js.map +1 -1
  92. package/lib/tools/shared/point/index.js +39 -53
  93. package/lib/tools/shared/point/index.js.map +1 -1
  94. package/lib/tools/shared/styles.js +9 -32
  95. package/lib/tools/shared/styles.js.map +1 -1
  96. package/lib/tools/shared/types.js +2 -6
  97. package/lib/tools/shared/types.js.map +1 -1
  98. package/lib/undo-redo.js +28 -68
  99. package/lib/undo-redo.js.map +1 -1
  100. package/lib/use-debounce.js +5 -12
  101. package/lib/use-debounce.js.map +1 -1
  102. package/lib/utils.js +57 -132
  103. package/lib/utils.js.map +1 -1
  104. package/package.json +26 -31
  105. package/src/__tests__/graph-with-controls.test.jsx +23 -10
  106. package/src/__tests__/graph.test.jsx +36 -171
  107. package/src/__tests__/grid.test.jsx +9 -6
  108. package/src/__tests__/labels.test.jsx +11 -8
  109. package/src/__tests__/mark-label.test.jsx +15 -17
  110. package/src/__tests__/toggle-bar.test.jsx +46 -17
  111. package/src/__tests__/tool-menu.test.jsx +12 -8
  112. package/src/__tests__/undo-redo.test.jsx +9 -8
  113. package/src/__tests__/utils.js +3 -0
  114. package/src/axis/__tests__/arrow.test.jsx +21 -17
  115. package/src/axis/__tests__/axes.test.jsx +117 -155
  116. package/src/axis/arrow.jsx +7 -12
  117. package/src/axis/axes.jsx +41 -51
  118. package/src/coordinates-label.jsx +13 -18
  119. package/src/graph-with-controls.jsx +90 -93
  120. package/src/grid-setup.jsx +210 -206
  121. package/src/grid.jsx +2 -4
  122. package/src/labels.jsx +83 -124
  123. package/src/mark-label.jsx +14 -25
  124. package/src/toggle-bar.jsx +135 -163
  125. package/src/tool-menu.jsx +136 -195
  126. package/src/tools/line/__tests__/component.test.jsx +7 -7
  127. package/src/tools/line/component.jsx +29 -29
  128. package/src/tools/polygon/__tests__/component.test.jsx +13 -152
  129. package/src/tools/polygon/__tests__/line.test.jsx +7 -9
  130. package/src/tools/polygon/__tests__/polygon.test.jsx +8 -8
  131. package/src/tools/polygon/component.jsx +2 -4
  132. package/src/tools/polygon/line.jsx +26 -24
  133. package/src/tools/polygon/polygon.jsx +35 -40
  134. package/src/tools/shared/__tests__/arrow-head.test.jsx +16 -17
  135. package/src/tools/shared/line/__tests__/index.test.jsx +26 -163
  136. package/src/tools/shared/line/__tests__/line-path.test.jsx +9 -9
  137. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +14 -24
  138. package/src/tools/shared/line/index.jsx +3 -3
  139. package/src/tools/shared/line/line-path.jsx +51 -48
  140. package/src/tools/shared/line/with-root-edge.jsx +1 -1
  141. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
  142. package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
  143. package/src/tools/shared/point/base-point.jsx +33 -6
  144. package/src/tools/shared/point/index.jsx +30 -32
  145. package/src/undo-redo.jsx +16 -24
  146. package/esm/index.css +0 -847
  147. package/esm/index.js +0 -233259
  148. package/esm/index.js.map +0 -1
  149. package/esm/package.json +0 -3
  150. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -114
  151. package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -213
  152. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
  153. package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
  154. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -37
  155. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
  156. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -35
  157. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -15
  158. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
  159. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
  160. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
  161. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -94
  162. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -44
  163. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -53
  164. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -32
  165. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
  166. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -57
  167. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
  168. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -55
  169. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -43
@@ -1,15 +1,38 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
3
  import { types } from '@pie-lib/plot';
5
4
  import CoordinatesLabel from '../../../coordinates-label';
6
5
  import ReactDOM from 'react-dom';
7
6
  import { thinnerShapesNeeded } from '../../../utils';
8
7
  import { color } from '@pie-lib/render-ui';
8
+ import { styled } from '@mui/material/styles';
9
+ import { disabled as disabledStyle, correct, incorrect, missing } from '../styles';
10
+
11
+ const StyledPointGroup = styled('g')(({ disabled, correctness }) => ({
12
+ cursor: 'pointer',
13
+ '& circle': {
14
+ fill: 'currentColor',
15
+ },
16
+ ...(disabled && {
17
+ ...disabledStyle('fill'),
18
+ ...disabledStyle('color'),
19
+ }),
20
+ ...(correctness === 'correct' && {
21
+ ...correct('fill'),
22
+ ...correct('color'),
23
+ }),
24
+ ...(correctness === 'incorrect' && {
25
+ ...incorrect('fill'),
26
+ ...incorrect('color'),
27
+ }),
28
+ ...(correctness === 'missing' && {
29
+ ...missing('fill'),
30
+ ...missing('color'),
31
+ }),
32
+ }));
9
33
 
10
34
  export class RawBp extends React.Component {
11
35
  static propTypes = {
12
- classes: PropTypes.object,
13
36
  className: PropTypes.string,
14
37
  coordinatesOnHover: PropTypes.bool,
15
38
  correctness: PropTypes.string,
@@ -18,6 +41,9 @@ export class RawBp extends React.Component {
18
41
  x: PropTypes.number,
19
42
  y: PropTypes.number,
20
43
  graphProps: types.GraphPropsType.isRequired,
44
+ onClick: PropTypes.func,
45
+ onTouchStart: PropTypes.func,
46
+ onTouchEnd: PropTypes.func,
21
47
  };
22
48
 
23
49
  constructor(props) {
@@ -27,7 +53,6 @@ export class RawBp extends React.Component {
27
53
 
28
54
  render() {
29
55
  const {
30
- classes,
31
56
  className,
32
57
  coordinatesOnHover,
33
58
  x,
@@ -63,8 +88,10 @@ export class RawBp extends React.Component {
63
88
  onTouchEnd={onTouchEnd}
64
89
  onClick={onClick}
65
90
  />
66
- <g
67
- className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)}
91
+ <StyledPointGroup
92
+ disabled={disabled}
93
+ correctness={correctness}
94
+ className={className}
68
95
  onMouseEnter={() => this.setState({ showCoordinates: true })}
69
96
  onMouseLeave={() => this.setState({ showCoordinates: false })}
70
97
  >
@@ -79,7 +106,7 @@ export class RawBp extends React.Component {
79
106
  coordinatesOnHover &&
80
107
  showCoordinates &&
81
108
  ReactDOM.createPortal(<CoordinatesLabel graphProps={graphProps} x={x} y={y} />, labelNode)}
82
- </g>
109
+ </StyledPointGroup>
83
110
  </>
84
111
  );
85
112
  }
@@ -1,4 +1,6 @@
1
- import { withStyles } from '@material-ui/core/styles/index';
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
2
4
  import { gridDraggable } from '@pie-lib/plot';
3
5
  import * as utils from '../../../utils';
4
6
  import { disabled, correct, incorrect, missing } from '../styles';
@@ -24,37 +26,33 @@ const opts = {
24
26
  },
25
27
  };
26
28
 
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
- },
29
+ const StyledPointWrapper = styled('g', {
30
+ shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
31
+ })(({ disabled: isDisabled, correctness }) => ({
32
+ '& circle, & polygon': {
33
+ cursor: 'pointer',
34
+ fill: color.defaults.SECONDARY,
35
+ ...(isDisabled && disabled()),
36
+ ...(correctness === 'correct' && correct()),
37
+ ...(correctness === 'incorrect' && incorrect()),
38
+ ...(correctness === 'missing' && missing()),
39
+ },
40
+ }));
41
+
42
+ const withStyledWrapper = (WrappedComponent) => {
43
+ const WrappedComponentWithStyles = (props) => (
44
+ <StyledPointWrapper disabled={props.disabled} correctness={props.correctness}>
45
+ <WrappedComponent {...props} />
46
+ </StyledPointWrapper>
47
+ );
48
+ WrappedComponentWithStyles.displayName = `withStyledWrapper(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
49
+ WrappedComponentWithStyles.propTypes = {
50
+ disabled: PropTypes.bool,
51
+ correctness: PropTypes.string,
55
52
  };
53
+ return WrappedComponentWithStyles;
56
54
  };
57
55
 
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));
56
+ export const BasePoint = gridDraggable(opts)(withStyledWrapper(RawBp));
57
+ export const ArrowPoint = gridDraggable(opts)(withStyledWrapper(RawArrow));
58
+ 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;