@pie-lib/graphing 2.11.3-next.52 → 2.11.4

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 (90) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lib/axis/arrow.js.map +1 -1
  3. package/lib/axis/axes.js.map +1 -1
  4. package/lib/bg.js.map +1 -1
  5. package/lib/container/actions.js.map +1 -1
  6. package/lib/container/index.js.map +1 -1
  7. package/lib/coordinates-label.js.map +1 -1
  8. package/lib/graph-with-controls.js.map +1 -1
  9. package/lib/graph.js.map +1 -1
  10. package/lib/grid-setup.js.map +1 -1
  11. package/lib/grid.js.map +1 -1
  12. package/lib/labels.js.map +1 -1
  13. package/lib/mark-label.js.map +1 -1
  14. package/lib/toggle-bar.js.map +1 -1
  15. package/lib/tool-menu.js.map +1 -1
  16. package/lib/tools/circle/bg-circle.js.map +1 -1
  17. package/lib/tools/circle/component.js.map +1 -1
  18. package/lib/tools/circle/index.js.map +1 -1
  19. package/lib/tools/index.js.map +1 -1
  20. package/lib/tools/line/component.js.map +1 -1
  21. package/lib/tools/parabola/component.js.map +1 -1
  22. package/lib/tools/parabola/index.js.map +1 -1
  23. package/lib/tools/point/component.js.map +1 -1
  24. package/lib/tools/point/index.js.map +1 -1
  25. package/lib/tools/polygon/component.js.map +1 -1
  26. package/lib/tools/polygon/index.js.map +1 -1
  27. package/lib/tools/polygon/line.js.map +1 -1
  28. package/lib/tools/polygon/polygon.js.map +1 -1
  29. package/lib/tools/ray/component.js.map +1 -1
  30. package/lib/tools/segment/component.js.map +1 -1
  31. package/lib/tools/shared/arrow-head.js.map +1 -1
  32. package/lib/tools/shared/line/index.js.map +1 -1
  33. package/lib/tools/shared/line/line-path.js.map +1 -1
  34. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  35. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  36. package/lib/tools/shared/point/arrow.js.map +1 -1
  37. package/lib/tools/shared/point/base-point.js.map +1 -1
  38. package/lib/tools/shared/point/index.js.map +1 -1
  39. package/lib/tools/shared/styles.js.map +1 -1
  40. package/lib/tools/shared/types.js.map +1 -1
  41. package/lib/tools/sine/component.js.map +1 -1
  42. package/lib/tools/sine/index.js.map +1 -1
  43. package/lib/tools/vector/component.js.map +1 -1
  44. package/lib/undo-redo.js.map +1 -1
  45. package/lib/utils.js.map +1 -1
  46. package/package.json +6 -6
  47. package/src/axis/arrow.jsx +4 -4
  48. package/src/axis/axes.jsx +34 -56
  49. package/src/bg.jsx +3 -11
  50. package/src/container/actions.js +3 -3
  51. package/src/container/index.jsx +7 -7
  52. package/src/coordinates-label.jsx +8 -8
  53. package/src/graph-with-controls.jsx +30 -41
  54. package/src/graph.jsx +20 -22
  55. package/src/grid-setup.jsx +37 -64
  56. package/src/grid.jsx +17 -19
  57. package/src/labels.jsx +20 -20
  58. package/src/mark-label.jsx +13 -13
  59. package/src/toggle-bar.jsx +28 -30
  60. package/src/tool-menu.jsx +7 -12
  61. package/src/tools/circle/bg-circle.jsx +11 -26
  62. package/src/tools/circle/component.jsx +25 -25
  63. package/src/tools/circle/index.js +2 -2
  64. package/src/tools/index.js +2 -23
  65. package/src/tools/line/component.jsx +5 -10
  66. package/src/tools/parabola/component.jsx +2 -9
  67. package/src/tools/parabola/index.js +2 -2
  68. package/src/tools/point/component.jsx +5 -5
  69. package/src/tools/point/index.js +3 -3
  70. package/src/tools/polygon/component.jsx +18 -34
  71. package/src/tools/polygon/index.js +3 -3
  72. package/src/tools/polygon/line.jsx +10 -15
  73. package/src/tools/polygon/polygon.jsx +16 -25
  74. package/src/tools/ray/component.jsx +5 -10
  75. package/src/tools/segment/component.jsx +5 -10
  76. package/src/tools/shared/arrow-head.jsx +4 -4
  77. package/src/tools/shared/line/index.jsx +30 -31
  78. package/src/tools/shared/line/line-path.jsx +13 -29
  79. package/src/tools/shared/line/with-root-edge.jsx +14 -25
  80. package/src/tools/shared/point/arrow-point.jsx +6 -25
  81. package/src/tools/shared/point/arrow.jsx +3 -21
  82. package/src/tools/shared/point/base-point.jsx +3 -11
  83. package/src/tools/shared/point/index.jsx +11 -11
  84. package/src/tools/shared/styles.js +3 -3
  85. package/src/tools/shared/types.js +1 -1
  86. package/src/tools/sine/component.jsx +2 -2
  87. package/src/tools/sine/index.js +2 -2
  88. package/src/tools/vector/component.jsx +5 -10
  89. package/src/undo-redo.jsx +6 -6
  90. package/src/utils.js +29 -38
@@ -9,7 +9,7 @@ import { thinnerShapesNeeded, getAdjustedGraphLimits } from '../../utils';
9
9
 
10
10
  const markerId = genUid();
11
11
 
12
- const rayStyles = theme => ({
12
+ const rayStyles = (theme) => ({
13
13
  line: styles.line(theme),
14
14
  enabledArrow: styles.arrow(theme),
15
15
  disabledArrow: styles.disabledArrow(theme),
@@ -17,10 +17,10 @@ const rayStyles = theme => ({
17
17
  correct: styles.correct(theme, 'stroke'),
18
18
  correctArrow: styles.correct(theme),
19
19
  incorrect: styles.incorrect(theme, 'stroke'),
20
- incorrectArrow: styles.incorrect(theme)
20
+ incorrectArrow: styles.incorrect(theme),
21
21
  });
22
22
 
23
- export const RayLine = props => {
23
+ export const RayLine = (props) => {
24
24
  const { graphProps, from, to, classes, disabled, correctness, className, ...rest } = props;
25
25
  const { scale } = graphProps;
26
26
  const { domain, range } = getAdjustedGraphLimits(graphProps);
@@ -42,12 +42,7 @@ export const RayLine = props => {
42
42
  x2={scale.x(aToB.x)}
43
43
  y2={scale.y(aToB.y)}
44
44
  {...rest}
45
- className={classNames(
46
- classes.line,
47
- disabled && classes.disabled,
48
- classes[correctness],
49
- className
50
- )}
45
+ className={classNames(classes.line, disabled && classes.disabled, classes[correctness], className)}
51
46
  markerEnd={`url(#${props.markerId || markerId}-${suffix})`}
52
47
  />
53
48
  </g>
@@ -62,7 +57,7 @@ RayLine.propTypes = {
62
57
  graphProps: PropTypes.any,
63
58
  from: types.PointType,
64
59
  to: types.PointType,
65
- markerId: PropTypes.string
60
+ markerId: PropTypes.string,
66
61
  };
67
62
 
68
63
  const StyledRay = withStyles(rayStyles)(RayLine);
@@ -6,13 +6,13 @@ import { types } from '@pie-lib/plot';
6
6
  import { withStyles } from '@material-ui/core/styles';
7
7
  import classNames from 'classnames';
8
8
 
9
- const lineStyles = theme => ({
9
+ const lineStyles = (theme) => ({
10
10
  line: styles.line(theme),
11
11
  disabled: styles.disabled(theme),
12
12
  correct: styles.correct(theme, 'stroke'),
13
- incorrect: styles.incorrect(theme, 'stroke')
13
+ incorrect: styles.incorrect(theme, 'stroke'),
14
14
  });
15
- export const Line = props => {
15
+ export const Line = (props) => {
16
16
  const { className, classes, correctness, disabled, graphProps, from, to, ...rest } = props;
17
17
  const { scale } = graphProps;
18
18
 
@@ -24,12 +24,7 @@ export const Line = props => {
24
24
  y1={scale.y(from.y)}
25
25
  x2={scale.x(to.x)}
26
26
  y2={scale.y(to.y)}
27
- className={classNames(
28
- classes.line,
29
- disabled && classes.disabled,
30
- classes[correctness],
31
- className
32
- )}
27
+ className={classNames(classes.line, disabled && classes.disabled, classes[correctness], className)}
33
28
  {...rest}
34
29
  />
35
30
  );
@@ -42,7 +37,7 @@ Line.propTypes = {
42
37
  disabled: PropTypes.bool,
43
38
  graphProps: PropTypes.any,
44
39
  from: types.PointType,
45
- to: types.PointType
40
+ to: types.PointType,
46
41
  };
47
42
 
48
43
  const StyledLine = withStyles(lineStyles)(Line);
@@ -7,12 +7,12 @@ export const ArrowHead = ({ size, transform, points }) => (
7
7
  ArrowHead.propTypes = {
8
8
  points: PropTypes.string,
9
9
  size: PropTypes.number,
10
- transform: PropTypes.string
10
+ transform: PropTypes.string,
11
11
  };
12
12
  ArrowHead.defaultProps = {
13
13
  points: '',
14
14
  size: 10,
15
- transform: ''
15
+ transform: '',
16
16
  };
17
17
  export const genUid = () => {
18
18
  const v = (Math.random() * 1000).toFixed(0);
@@ -37,8 +37,8 @@ export const ArrowMarker = ({ id, size, className }) => {
37
37
  ArrowMarker.propTypes = {
38
38
  id: PropTypes.string,
39
39
  size: PropTypes.number,
40
- className: PropTypes.string
40
+ className: PropTypes.string,
41
41
  };
42
42
  ArrowMarker.defaultProps = {
43
- size: 5
43
+ size: 5,
44
44
  };
@@ -23,7 +23,7 @@ export const lineTool = (type, Component) => () => ({
23
23
  return {
24
24
  type,
25
25
  building: true,
26
- from: point
26
+ from: point,
27
27
  };
28
28
  }
29
29
 
@@ -32,14 +32,14 @@ export const lineTool = (type, Component) => () => ({
32
32
  }
33
33
 
34
34
  return { ...mark, building: false, to: point };
35
- }
35
+ },
36
36
  });
37
37
 
38
- export const lineToolComponent = Component => {
38
+ export const lineToolComponent = (Component) => {
39
39
  return class LineToolComponent extends React.Component {
40
40
  static propTypes = {
41
41
  ...types.ToolPropTypeFields,
42
- graphProps: types.GraphPropsType.isRequired
42
+ graphProps: types.GraphPropsType.isRequired,
43
43
  };
44
44
 
45
45
  constructor(props) {
@@ -55,8 +55,7 @@ export const lineToolComponent = Component => {
55
55
 
56
56
  this.setState({ mark: undefined }, () => {
57
57
  const { type } = update;
58
- const shouldNotChange =
59
- type && (type === 'parabola' || type === 'sine') && sameAxes(update.from, update.to);
58
+ const shouldNotChange = type && (type === 'parabola' || type === 'sine') && sameAxes(update.from, update.to);
60
59
 
61
60
  if (!isEqual(mark, update) && !shouldNotChange) {
62
61
  onChange(mark, update);
@@ -144,7 +143,7 @@ const dragOpts = () => ({
144
143
  const area = utils.lineToArea(props.from, props.to);
145
144
  return utils.bounds(area, domain, range);
146
145
  },
147
- anchorPoint: props => {
146
+ anchorPoint: (props) => {
148
147
  const { from } = props;
149
148
  return from;
150
149
  },
@@ -152,9 +151,9 @@ const dragOpts = () => ({
152
151
  const { from, to } = props;
153
152
  return {
154
153
  from: utils.point(from).add(utils.point(delta)),
155
- to: utils.point(to).add(utils.point(delta))
154
+ to: utils.point(to).add(utils.point(delta)),
156
155
  };
157
- }
156
+ },
158
157
  });
159
158
 
160
159
  export const lineBase = (Comp, opts) => {
@@ -178,10 +177,10 @@ export const lineBase = (Comp, opts) => {
178
177
  disabled: PropTypes.bool,
179
178
  labelNode: PropTypes.object,
180
179
  labelModeEnabled: PropTypes.bool,
181
- changeMarkProps: PropTypes.func
180
+ changeMarkProps: PropTypes.func,
182
181
  };
183
182
 
184
- onChangePoint = point => {
183
+ onChangePoint = (point) => {
185
184
  const { middle, onChange } = this.props;
186
185
  const { from, to } = point;
187
186
 
@@ -215,7 +214,7 @@ export const lineBase = (Comp, opts) => {
215
214
  onChange(updated);
216
215
  };
217
216
 
218
- dragFrom = draggedFrom => {
217
+ dragFrom = (draggedFrom) => {
219
218
  const { from, to } = this.props;
220
219
 
221
220
  if (from.label) {
@@ -227,7 +226,7 @@ export const lineBase = (Comp, opts) => {
227
226
  }
228
227
  };
229
228
 
230
- dragTo = draggedTo => {
229
+ dragTo = (draggedTo) => {
231
230
  const { from, to } = this.props;
232
231
 
233
232
  if (to.label) {
@@ -280,7 +279,7 @@ export const lineBase = (Comp, opts) => {
280
279
  correctness,
281
280
  onClick,
282
281
  labelNode,
283
- labelModeEnabled
282
+ labelModeEnabled,
284
283
  } = this.props;
285
284
  const common = { graphProps, onDragStart, onDragStop, disabled, correctness, onClick };
286
285
  const angle = to ? trig.toDegrees(trig.angle(from, to)) : 0;
@@ -293,39 +292,39 @@ export const lineBase = (Comp, opts) => {
293
292
  if (from && from.hasOwnProperty('label')) {
294
293
  fromLabelNode = ReactDOM.createPortal(
295
294
  <MarkLabel
296
- inputRef={r => (this.input.from = r)}
295
+ inputRef={(r) => (this.input.from = r)}
297
296
  disabled={!labelModeEnabled}
298
297
  mark={from}
299
298
  graphProps={graphProps}
300
- onChange={label => this.labelChange({ ...from, label }, 'from')}
299
+ onChange={(label) => this.labelChange({ ...from, label }, 'from')}
301
300
  />,
302
- labelNode
301
+ labelNode,
303
302
  );
304
303
  }
305
304
 
306
305
  if (to && to.hasOwnProperty('label')) {
307
306
  toLabelNode = ReactDOM.createPortal(
308
307
  <MarkLabel
309
- inputRef={r => (this.input.to = r)}
308
+ inputRef={(r) => (this.input.to = r)}
310
309
  disabled={!labelModeEnabled}
311
310
  mark={to}
312
311
  graphProps={graphProps}
313
- onChange={label => this.labelChange({ ...to, label }, 'to')}
312
+ onChange={(label) => this.labelChange({ ...to, label }, 'to')}
314
313
  />,
315
- labelNode
314
+ labelNode,
316
315
  );
317
316
  }
318
317
 
319
318
  if (middle && middle.hasOwnProperty('label')) {
320
319
  lineLabelNode = ReactDOM.createPortal(
321
320
  <MarkLabel
322
- inputRef={r => (this.input.middle = r)}
321
+ inputRef={(r) => (this.input.middle = r)}
323
322
  disabled={!labelModeEnabled}
324
323
  mark={middle}
325
324
  graphProps={graphProps}
326
- onChange={label => this.labelChange({ ...middle, label }, 'middle')}
325
+ onChange={(label) => this.labelChange({ ...middle, label }, 'middle')}
327
326
  />,
328
- labelNode
327
+ labelNode,
329
328
  );
330
329
  }
331
330
  }
@@ -384,23 +383,23 @@ export const styles = {
384
383
  transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
385
384
  '&:hover': {
386
385
  strokeWidth: 6,
387
- stroke: color.primaryDark()
388
- }
386
+ stroke: color.primaryDark(),
387
+ },
389
388
  }),
390
389
  arrow: () => ({
391
- fill: color.secondary()
390
+ fill: color.secondary(),
392
391
  }),
393
392
  disabledArrow: () => ({
394
- ...disabled()
393
+ ...disabled(),
395
394
  }),
396
395
  disabled: () => ({
397
396
  ...disabled('stroke'),
398
- strokeWidth: 2
397
+ strokeWidth: 2,
399
398
  }),
400
399
  correct: (theme, key) => ({
401
- ...correct(key)
400
+ ...correct(key),
402
401
  }),
403
402
  incorrect: (theme, key) => ({
404
- ...incorrect(key)
405
- })
403
+ ...incorrect(key),
404
+ }),
406
405
  };
@@ -17,40 +17,24 @@ export class RawLinePath extends React.Component {
17
17
  correctness: PropTypes.string,
18
18
  from: types.PointType,
19
19
  to: types.PointType,
20
- isDragging: PropTypes.bool
20
+ isDragging: PropTypes.bool,
21
21
  };
22
22
 
23
23
  static defaultProps = {
24
24
  from: {},
25
- to: {}
25
+ to: {},
26
26
  };
27
27
 
28
28
  render() {
29
29
  /* eslint-disable no-unused-vars */
30
- const {
31
- data,
32
- classes,
33
- className,
34
- disabled,
35
- correctness,
36
- from,
37
- to,
38
- graphProps,
39
- isDragging,
40
- ...rest
41
- } = this.props;
30
+ const { data, classes, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
42
31
  /* eslint-enable */
43
32
 
44
33
  return (
45
34
  <React.Fragment>
46
35
  <vx.LinePath
47
36
  data={data}
48
- className={classNames(
49
- classes.drawLine,
50
- disabled && classes.disabled,
51
- classes[correctness],
52
- className
53
- )}
37
+ className={classNames(classes.drawLine, disabled && classes.disabled, classes[correctness], className)}
54
38
  {...rest}
55
39
  />
56
40
  <vx.LinePath
@@ -60,7 +44,7 @@ export class RawLinePath extends React.Component {
60
44
  isDragging && classes.dragging,
61
45
  disabled && classes.disabled,
62
46
  classes[correctness],
63
- className
47
+ className,
64
48
  )}
65
49
  {...rest}
66
50
  />
@@ -71,31 +55,31 @@ export class RawLinePath extends React.Component {
71
55
 
72
56
  const dragging = () => ({
73
57
  strokeWidth: 7,
74
- stroke: color.secondaryLight()
58
+ stroke: color.secondaryLight(),
75
59
  });
76
60
 
77
- export const LinePath = withStyles(theme => ({
61
+ export const LinePath = withStyles((theme) => ({
78
62
  drawLine: {
79
63
  fill: 'none',
80
64
  strokeWidth: 2,
81
- stroke: color.secondaryLight()
65
+ stroke: color.secondaryLight(),
82
66
  },
83
67
  line: {
84
68
  strokeWidth: 6,
85
69
  fill: 'none',
86
70
  transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
87
71
  stroke: 'transparent',
88
- '&:hover': dragging(theme)
72
+ '&:hover': dragging(theme),
89
73
  },
90
74
  dragging: dragging(theme),
91
75
  disabled: {
92
76
  ...disabled('stroke'),
93
- strokeWidth: 2
77
+ strokeWidth: 2,
94
78
  },
95
79
  correct: {
96
- ...correct('stroke')
80
+ ...correct('stroke'),
97
81
  },
98
82
  incorrect: {
99
- ...incorrect('stroke')
100
- }
83
+ ...incorrect('stroke'),
84
+ },
101
85
  }))(RawLinePath);
@@ -5,7 +5,7 @@ import { LinePath } from '../line/line-path';
5
5
  import { curveMonotoneX } from '@vx/curve';
6
6
  import { lineBase, lineToolComponent } from './index';
7
7
 
8
- const toRootEdge = m => {
8
+ const toRootEdge = (m) => {
9
9
  const out = { ...m };
10
10
  out.root = { ...m.from };
11
11
  out.edge = m.to ? { ...m.to } : undefined;
@@ -14,7 +14,7 @@ const toRootEdge = m => {
14
14
  return out;
15
15
  };
16
16
 
17
- const toFromTo = m => {
17
+ const toFromTo = (m) => {
18
18
  const out = { ...m };
19
19
  out.from = { ...m.root };
20
20
  out.to = m.edge ? { ...m.edge } : undefined;
@@ -23,8 +23,8 @@ const toFromTo = m => {
23
23
  return out;
24
24
  };
25
25
 
26
- export const rootEdgeToFromToWrapper = BaseComp => {
27
- const Wrapper = props => {
26
+ export const rootEdgeToFromToWrapper = (BaseComp) => {
27
+ const Wrapper = (props) => {
28
28
  const m = toFromTo(props.mark);
29
29
 
30
30
  const onChange = (current, next) => {
@@ -36,38 +36,27 @@ export const rootEdgeToFromToWrapper = BaseComp => {
36
36
 
37
37
  Wrapper.propTypes = {
38
38
  onChange: PropTypes.func,
39
- mark: PropTypes.object
39
+ mark: PropTypes.object,
40
40
  };
41
41
 
42
42
  return Wrapper;
43
43
  };
44
44
 
45
- export const rootEdgeComponent = RootEdgeComp => {
45
+ export const rootEdgeComponent = (RootEdgeComp) => {
46
46
  const BaseComponent = lineToolComponent(RootEdgeComp);
47
47
  return rootEdgeToFromToWrapper(BaseComponent);
48
48
  };
49
49
 
50
- const withPointsGenerationLinePath = getPoints => {
51
- const LinePathComponent = props => {
52
- const {
53
- graphProps,
54
- from,
55
- to,
56
- onClick,
57
- onDragStart,
58
- onDragStop,
59
- onChange,
60
- disabled,
61
- correctness,
62
- ...rest
63
- } = props;
50
+ const withPointsGenerationLinePath = (getPoints) => {
51
+ const LinePathComponent = (props) => {
52
+ const { graphProps, from, to, onClick, onDragStart, onDragStop, onChange, disabled, correctness, ...rest } = props;
64
53
 
65
54
  const { dataPoints } = getPoints({
66
55
  graphProps: props.graphProps,
67
56
  root: from,
68
- edge: to
57
+ edge: to,
69
58
  });
70
- const raw = dataPoints.map(d => [graphProps.scale.x(d.x), graphProps.scale.y(d.y)]);
59
+ const raw = dataPoints.map((d) => [graphProps.scale.x(d.x), graphProps.scale.y(d.y)]);
71
60
 
72
61
  const common = {
73
62
  onClick,
@@ -76,7 +65,7 @@ const withPointsGenerationLinePath = getPoints => {
76
65
  onDragStop,
77
66
  onChange,
78
67
  disabled,
79
- correctness
68
+ correctness,
80
69
  };
81
70
 
82
71
  return <LinePath data={raw} from={from} to={to} curve={curveMonotoneX} {...common} {...rest} />;
@@ -90,12 +79,12 @@ const withPointsGenerationLinePath = getPoints => {
90
79
  onDragStop: PropTypes.func,
91
80
  onChange: PropTypes.func,
92
81
  disabled: PropTypes.bool,
93
- correctness: PropTypes.string
82
+ correctness: PropTypes.string,
94
83
  };
95
84
  return LinePathComponent;
96
85
  };
97
86
 
98
- export const withRootEdge = getPoints => {
87
+ export const withRootEdge = (getPoints) => {
99
88
  const LinePathComp = withPointsGenerationLinePath(getPoints);
100
89
  return lineBase(LinePathComp);
101
90
  };
@@ -15,33 +15,22 @@ export class RawArrow extends React.Component {
15
15
  y: PropTypes.number,
16
16
  from: PropTypes.shape({
17
17
  x: PropTypes.number,
18
- y: PropTypes.number
18
+ y: PropTypes.number,
19
19
  }).isRequired,
20
20
  to: PropTypes.shape({
21
21
  x: PropTypes.number,
22
- y: PropTypes.number
22
+ y: PropTypes.number,
23
23
  }),
24
- graphProps: types.GraphPropsType.isRequired
24
+ graphProps: types.GraphPropsType.isRequired,
25
25
  };
26
26
 
27
27
  static defaultProps = {
28
28
  from: {},
29
- to: {}
29
+ to: {},
30
30
  };
31
31
 
32
32
  render() {
33
- const {
34
- classes,
35
- className,
36
- x,
37
- y,
38
- disabled,
39
- correctness,
40
- graphProps,
41
- from,
42
- to,
43
- ...rest
44
- } = this.props;
33
+ const { classes, className, x, y, disabled, correctness, graphProps, from, to, ...rest } = this.props;
45
34
  // x & y are the initial coordinates for the arrow
46
35
  // from & to are used only to calculate the angle that the arrow should be rotated with
47
36
 
@@ -58,15 +47,7 @@ export class RawArrow extends React.Component {
58
47
  }
59
48
 
60
49
  return (
61
- <g
62
- className={classNames(
63
- classes.point,
64
- disabled && classes.disabled,
65
- classes[correctness],
66
- className
67
- )}
68
- {...rest}
69
- >
50
+ <g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
70
51
  <polygon
71
52
  points={points}
72
53
  transform={`
@@ -14,21 +14,11 @@ export default class Arrow extends React.Component {
14
14
  x: PropTypes.number.isRequired,
15
15
  y: PropTypes.number.isRequired,
16
16
  angle: PropTypes.number.isRequired,
17
- graphProps: types.GraphPropsType.isRequired
17
+ graphProps: types.GraphPropsType.isRequired,
18
18
  };
19
19
 
20
20
  render() {
21
- const {
22
- classes,
23
- angle,
24
- className,
25
- x,
26
- y,
27
- disabled,
28
- correctness,
29
- graphProps,
30
- ...rest
31
- } = this.props;
21
+ const { classes, angle, className, x, y, disabled, correctness, graphProps, ...rest } = this.props;
32
22
 
33
23
  const size = thinnerShapesNeeded(graphProps) ? 12 : 14;
34
24
  const { scale } = graphProps;
@@ -42,15 +32,7 @@ export default class Arrow extends React.Component {
42
32
  ${scaledX - size}, ${scaledY + size / 2}`;
43
33
 
44
34
  return (
45
- <g
46
- className={classNames(
47
- classes.point,
48
- disabled && classes.disabled,
49
- classes[correctness],
50
- className
51
- )}
52
- {...rest}
53
- >
35
+ <g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
54
36
  <ArrowHead size={size} transform={transform} points={points} />
55
37
  </g>
56
38
  );
@@ -16,7 +16,7 @@ export class RawBp extends React.Component {
16
16
  labelNode: PropTypes.object,
17
17
  x: PropTypes.number,
18
18
  y: PropTypes.number,
19
- graphProps: types.GraphPropsType.isRequired
19
+ graphProps: types.GraphPropsType.isRequired,
20
20
  };
21
21
 
22
22
  constructor(props) {
@@ -43,12 +43,7 @@ export class RawBp extends React.Component {
43
43
 
44
44
  return (
45
45
  <g
46
- className={classNames(
47
- classes.point,
48
- disabled && classes.disabled,
49
- classes[correctness],
50
- className
51
- )}
46
+ className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)}
52
47
  onMouseEnter={() => this.setState({ showCoordinates: true })}
53
48
  onMouseLeave={() => this.setState({ showCoordinates: false })}
54
49
  {...rest}
@@ -58,10 +53,7 @@ export class RawBp extends React.Component {
58
53
  {labelNode &&
59
54
  coordinatesOnHover &&
60
55
  showCoordinates &&
61
- ReactDOM.createPortal(
62
- <CoordinatesLabel graphProps={graphProps} x={x} y={y} />,
63
- labelNode
64
- )}
56
+ ReactDOM.createPortal(<CoordinatesLabel graphProps={graphProps} x={x} y={y} />, labelNode)}
65
57
  </g>
66
58
  );
67
59
  }
@@ -14,14 +14,14 @@ const opts = {
14
14
 
15
15
  return utils.bounds(area, domain, range);
16
16
  },
17
- anchorPoint: props => {
17
+ anchorPoint: (props) => {
18
18
  const { x, y } = props;
19
19
 
20
20
  return { x, y };
21
21
  },
22
22
  fromDelta: (props, delta) => {
23
23
  return utils.point(props).add(utils.point(delta));
24
- }
24
+ },
25
25
  };
26
26
 
27
27
  const styles = () => {
@@ -29,24 +29,24 @@ const styles = () => {
29
29
  point: {
30
30
  '& circle, & polygon': {
31
31
  cursor: 'pointer',
32
- fill: color.secondary()
33
- }
32
+ fill: color.secondary(),
33
+ },
34
34
  },
35
35
  disabled: {
36
36
  '& circle, & polygon': {
37
- ...disabled()
38
- }
37
+ ...disabled(),
38
+ },
39
39
  },
40
40
  correct: {
41
41
  '& circle, & polygon': {
42
- ...correct()
43
- }
42
+ ...correct(),
43
+ },
44
44
  },
45
45
  incorrect: {
46
46
  '& circle, & polygon': {
47
- ...incorrect()
48
- }
49
- }
47
+ ...incorrect(),
48
+ },
49
+ },
50
50
  };
51
51
  };
52
52
 
@@ -2,14 +2,14 @@ import { color } from '@pie-lib/render-ui';
2
2
 
3
3
  export const disabled = (key = 'fill') => ({
4
4
  [key]: color.disabled(),
5
- pointerEvents: 'none'
5
+ pointerEvents: 'none',
6
6
  });
7
7
 
8
8
  export const correct = (key = 'fill') => ({
9
9
  [key]: color.correct(),
10
- pointerEvents: 'none'
10
+ pointerEvents: 'none',
11
11
  });
12
12
  export const incorrect = (key = 'fill') => ({
13
13
  [key]: color.incorrect(),
14
- pointerEvents: 'none'
14
+ pointerEvents: 'none',
15
15
  });
@@ -4,7 +4,7 @@ export const ToolPropTypeFields = {
4
4
  mark: PropTypes.any,
5
5
  onChange: PropTypes.func,
6
6
  onDragStart: PropTypes.func,
7
- onDragStop: PropTypes.func
7
+ onDragStop: PropTypes.func,
8
8
  };
9
9
 
10
10
  export const ToolPropType = PropTypes.shape(ToolPropTypeFields);