@pie-lib/graphing 2.34.2-next.0 → 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 (155) hide show
  1. package/CHANGELOG.md +10 -8
  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 +113 -183
  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 +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 -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 +15 -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 +204 -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
@@ -1,22 +1,20 @@
1
- import { withStyles } from '@material-ui/core/styles/index';
1
+ import React from 'react';
2
+ import { styled } from '@mui/material/styles';
2
3
  import { gridDraggable } from '@pie-lib/plot';
3
4
  import * as utils from '../../../utils';
4
- import { disabled, correct, incorrect, missing, disabledSecondary } from '../styles';
5
5
  import { RawBp } from './base-point';
6
6
  import { RawArrow } from './arrow-point';
7
- import { color } from '@pie-lib/render-ui';
8
- import BaseArrow from './arrow';
7
+ import { BaseArrow } from './arrow';
9
8
 
9
+ // Drag & bounds options
10
10
  const opts = {
11
11
  bounds: (props, { domain, range }) => {
12
12
  const { x, y } = props;
13
13
  const area = { left: x, top: y, bottom: y, right: x };
14
-
15
14
  return utils.bounds(area, domain, range);
16
15
  },
17
16
  anchorPoint: (props) => {
18
17
  const { x, y } = props;
19
-
20
18
  return { x, y };
21
19
  },
22
20
  fromDelta: (props, delta) => {
@@ -24,42 +22,27 @@ const opts = {
24
22
  },
25
23
  };
26
24
 
27
- const styles = () => {
28
- return {
29
- point: {
30
- '& circle, & polygon': {
31
- cursor: 'pointer',
32
- fill: color.defaults.BLACK,
33
- },
34
- },
35
- disabled: {
36
- '& circle, & polygon': {
37
- ...disabled(),
38
- },
39
- },
40
- disabledSecondary: {
41
- '& circle, & polygon': {
42
- ...disabledSecondary(),
43
- },
44
- },
45
- correct: {
46
- '& circle, & polygon': {
47
- ...correct(),
48
- },
49
- },
50
- incorrect: {
51
- '& circle, & polygon': {
52
- ...incorrect(),
53
- },
54
- },
55
- missing: {
56
- '& circle, & polygon': {
57
- ...missing(),
58
- },
59
- },
60
- };
61
- };
25
+ // Common styled point
26
+ const PointStyle = styled('g')(() => ({
27
+ '& circle, & polygon': {
28
+ cursor: 'pointer',
29
+ },
30
+ }));
31
+
32
+ export const BasePoint = gridDraggable(opts)((props) => (
33
+ <PointStyle {...props}>
34
+ <RawBp {...props} />
35
+ </PointStyle>
36
+ ));
37
+
38
+ export const ArrowPoint = gridDraggable(opts)((props) => (
39
+ <PointStyle {...props}>
40
+ <RawArrow {...props} />
41
+ </PointStyle>
42
+ ));
62
43
 
63
- export const BasePoint = withStyles(styles)(gridDraggable(opts)(RawBp));
64
- export const ArrowPoint = withStyles(styles)(gridDraggable(opts)(RawArrow));
65
- export const Arrow = withStyles(styles)(gridDraggable(opts)(BaseArrow));
44
+ export const Arrow = gridDraggable(opts)((props) => (
45
+ <PointStyle {...props}>
46
+ <BaseArrow {...props} />
47
+ </PointStyle>
48
+ ));
@@ -3,23 +3,18 @@ import { Arrow } from '../shared/point';
3
3
  import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { types } from '@pie-lib/plot';
6
- import classNames from 'classnames';
7
- import { withStyles } from '@material-ui/core/styles';
6
+ import { styled } from '@mui/material/styles';
8
7
  import { getDistanceBetweenTwoPoints } from '../../utils';
9
8
 
10
- const lineStyles = (theme) => ({
11
- line: styles.line(theme),
12
- disabled: styles.disabled(theme),
13
- disabledSecondary: styles.disabledSecondary(theme),
14
- correct: styles.correct(theme, 'stroke'),
15
- incorrect: styles.incorrect(theme, 'stroke'),
16
- missing: styles.missing(theme, 'stroke'),
17
- });
9
+ const StyledLine = styled('line')(({ theme, disabled, correctness }) => ({
10
+ ...styles.line(theme),
11
+ ...(disabled && styles.disabledSecondary(theme)),
12
+ ...(correctness && styles[correctness] && styles[correctness](theme, 'stroke')),
13
+ }));
18
14
 
19
15
  export const Line = (props) => {
20
16
  const {
21
17
  className,
22
- classes,
23
18
  disabled,
24
19
  correctness,
25
20
  graphProps: { scale },
@@ -32,8 +27,10 @@ export const Line = (props) => {
32
27
  const length = getDistanceBetweenTwoPoints(startPoint, endPoint);
33
28
 
34
29
  return (
35
- <line
36
- className={classNames(classes.line, disabled && classes.disabledSecondary, classes[correctness], className)}
30
+ <StyledLine
31
+ className={className}
32
+ disabled={disabled}
33
+ correctness={correctness}
37
34
  x1={startPoint.x}
38
35
  y1={startPoint.y}
39
36
  x2={endPoint.x}
@@ -46,7 +43,6 @@ export const Line = (props) => {
46
43
 
47
44
  Line.propTypes = {
48
45
  className: PropTypes.string,
49
- classes: PropTypes.object,
50
46
  disabled: PropTypes.bool,
51
47
  correctness: PropTypes.string,
52
48
  graphProps: PropTypes.any,
@@ -54,8 +50,7 @@ Line.propTypes = {
54
50
  to: types.PointType,
55
51
  };
56
52
 
57
- const StyledLine = withStyles(lineStyles)(Line);
58
- const Vector = lineBase(StyledLine, { to: Arrow });
53
+ const Vector = lineBase(Line, { to: Arrow });
59
54
  const Component = lineToolComponent(Vector);
60
55
 
61
56
  export default Component;
package/src/undo-redo.jsx CHANGED
@@ -1,16 +1,24 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import Button from '@material-ui/core/Button';
5
- import { withStyles } from '@material-ui/core';
4
+ import Button from '@mui/material/Button';
5
+ import { styled } from '@mui/material/styles';
6
6
  import { color } from '@pie-lib/render-ui';
7
7
  import Translator from '@pie-lib/translator';
8
8
 
9
9
  const { translator } = Translator;
10
10
 
11
+ const StyledButton = styled(Button)(({ theme }) => ({
12
+ color: color.text(),
13
+ fontWeight: 'bold',
14
+ marginBottom: theme.spacing(0.5),
15
+ '&:not(:last-of-type)': {
16
+ marginRight: theme.spacing(0.5),
17
+ },
18
+ }));
19
+
11
20
  export class UndoRedo extends React.Component {
12
21
  static propTypes = {
13
- classes: PropTypes.object,
14
22
  className: PropTypes.string,
15
23
  onUndo: PropTypes.func.isRequired,
16
24
  onRedo: PropTypes.func.isRequired,
@@ -20,31 +28,21 @@ export class UndoRedo extends React.Component {
20
28
  static defaultProps = {};
21
29
 
22
30
  render() {
23
- const { classes, className, onUndo, onRedo, onReset, language } = this.props;
31
+ const { className, onUndo, onRedo, onReset, language } = this.props;
24
32
  return (
25
33
  <div className={classNames(className)}>
26
- <Button classes={{ root: classes.button }} onClick={() => onUndo(true)}>
34
+ <StyledButton onClick={() => onUndo(true)}>
27
35
  {translator.t('common:undo', { lng: language })}
28
- </Button>
29
- <Button classes={{ root: classes.button }} onClick={() => onRedo(true)}>
36
+ </StyledButton>
37
+ <StyledButton onClick={() => onRedo(true)}>
30
38
  {translator.t('graphing.redo', { lng: language })}
31
- </Button>
32
- <Button classes={{ root: classes.button }} onClick={() => onReset()}>
39
+ </StyledButton>
40
+ <StyledButton onClick={() => onReset()}>
33
41
  {translator.t('graphing.reset', { lng: language })}
34
- </Button>
42
+ </StyledButton>
35
43
  </div>
36
44
  );
37
45
  }
38
46
  }
39
47
 
40
- const styles = (theme) => ({
41
- button: {
42
- color: color.text(),
43
- marginBottom: theme.spacing.unit / 2,
44
- '&:not(:last-of-type)': {
45
- marginRight: theme.spacing.unit / 2,
46
- },
47
- },
48
- });
49
-
50
- export default withStyles(styles)(UndoRedo);
48
+ export default UndoRedo;