@pie-lib/graphing 2.46.0-mui-update.0 → 3.0.0-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 (118) hide show
  1. package/CHANGELOG.md +8 -97
  2. package/lib/axis/axes.js +7 -13
  3. package/lib/axis/axes.js.map +1 -1
  4. package/lib/coordinates-label.js +2 -0
  5. package/lib/coordinates-label.js.map +1 -1
  6. package/lib/grid-setup.js +30 -36
  7. package/lib/grid-setup.js.map +1 -1
  8. package/lib/grid.js +1 -1
  9. package/lib/grid.js.map +1 -1
  10. package/lib/key-legend.js +6 -7
  11. package/lib/key-legend.js.map +1 -1
  12. package/lib/labels.js +4 -2
  13. package/lib/labels.js.map +1 -1
  14. package/lib/mark-label.js +16 -9
  15. package/lib/mark-label.js.map +1 -1
  16. package/lib/toggle-bar.js +12 -16
  17. package/lib/toggle-bar.js.map +1 -1
  18. package/lib/tool-menu.js +1 -3
  19. package/lib/tool-menu.js.map +1 -1
  20. package/lib/tools/circle/component.js +1 -2
  21. package/lib/tools/circle/component.js.map +1 -1
  22. package/lib/tools/point/component.js +1 -1
  23. package/lib/tools/point/component.js.map +1 -1
  24. package/lib/tools/polygon/component.js +2 -2
  25. package/lib/tools/polygon/component.js.map +1 -1
  26. package/lib/tools/polygon/line.js +2 -2
  27. package/lib/tools/polygon/line.js.map +1 -1
  28. package/lib/tools/shared/icons/CorrectSVG.js +9 -0
  29. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
  30. package/lib/tools/shared/icons/IncorrectSVG.js +9 -0
  31. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
  32. package/lib/tools/shared/icons/MissingSVG.js +9 -0
  33. package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
  34. package/lib/tools/shared/line/index.js +14 -6
  35. package/lib/tools/shared/line/index.js.map +1 -1
  36. package/lib/tools/shared/line/line-path.js +2 -3
  37. package/lib/tools/shared/line/line-path.js.map +1 -1
  38. package/lib/tools/shared/line/with-root-edge.js +1 -1
  39. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  40. package/lib/tools/shared/point/arrow-point.js +1 -3
  41. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  42. package/lib/tools/shared/point/arrow.js +1 -2
  43. package/lib/tools/shared/point/arrow.js.map +1 -1
  44. package/package.json +25 -16
  45. package/src/__tests__/graph-with-controls.test.jsx +28 -11
  46. package/src/__tests__/graph.test.jsx +104 -168
  47. package/src/__tests__/grid.test.jsx +8 -6
  48. package/src/__tests__/labels.test.jsx +25 -8
  49. package/src/__tests__/mark-label.test.jsx +12 -17
  50. package/src/__tests__/toggle-bar.test.jsx +92 -17
  51. package/src/__tests__/tool-menu.test.jsx +61 -12
  52. package/src/__tests__/undo-redo.test.jsx +7 -8
  53. package/src/__tests__/utils.js +3 -0
  54. package/src/axis/__tests__/arrow.test.jsx +16 -17
  55. package/src/axis/__tests__/axes.test.jsx +118 -122
  56. package/src/axis/axes.jsx +7 -12
  57. package/src/coordinates-label.jsx +1 -0
  58. package/src/grid-setup.jsx +6 -6
  59. package/src/grid.jsx +1 -1
  60. package/src/key-legend.jsx +1 -1
  61. package/src/labels.jsx +2 -0
  62. package/src/mark-label.jsx +10 -1
  63. package/src/toggle-bar.jsx +7 -25
  64. package/src/tool-menu.jsx +1 -1
  65. package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
  66. package/src/tools/circle/__tests__/component.test.jsx +17 -189
  67. package/src/tools/circle/component.jsx +1 -1
  68. package/src/tools/line/__tests__/component.test.jsx +7 -7
  69. package/src/tools/point/__tests__/component.test.jsx +18 -43
  70. package/src/tools/point/component.jsx +1 -1
  71. package/src/tools/polygon/__tests__/component.test.jsx +18 -162
  72. package/src/tools/polygon/__tests__/line.test.jsx +7 -10
  73. package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
  74. package/src/tools/polygon/component.jsx +2 -2
  75. package/src/tools/polygon/line.jsx +3 -2
  76. package/src/tools/ray/__tests__/component.test.jsx +7 -8
  77. package/src/tools/segment/__tests__/component.test.jsx +7 -8
  78. package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
  79. package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
  80. package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
  81. package/src/tools/shared/icons/MissingSVG.jsx +10 -0
  82. package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
  83. package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
  84. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
  85. package/src/tools/shared/line/index.jsx +13 -5
  86. package/src/tools/shared/line/line-path.jsx +2 -2
  87. package/src/tools/shared/line/with-root-edge.jsx +1 -1
  88. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
  89. package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
  90. package/src/tools/shared/point/arrow-point.jsx +1 -1
  91. package/src/tools/shared/point/arrow.jsx +1 -1
  92. package/src/tools/vector/__tests__/component.test.jsx +7 -8
  93. package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
  94. package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
  95. package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
  96. package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
  97. package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
  98. package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
  99. package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
  100. package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
  101. package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
  102. package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
  103. package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
  104. package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
  105. package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
  106. package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
  107. package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
  108. package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
  109. package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
  110. package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
  111. package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
  112. package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
  113. package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
  114. package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
  115. package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
  116. package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
  117. package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
  118. package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
@@ -1,25 +1,24 @@
1
- import { shallow } from 'enzyme';
1
+ import { render } from '@pie-lib/test-utils';
2
2
  import React from 'react';
3
3
  import UndoRedo from '../undo-redo';
4
4
 
5
5
  describe('UndoRedo', () => {
6
- let w;
7
6
  let onUndo = jest.fn();
8
7
  let onRedo = jest.fn();
9
8
  let onReset = jest.fn();
10
- const wrapper = (extras) => {
9
+ const renderComponent = (extras) => {
11
10
  const defaults = {
12
11
  onUndo,
13
12
  onRedo,
14
13
  onReset,
15
14
  };
16
15
  const props = { ...defaults, ...extras };
17
- return shallow(<UndoRedo {...props} />);
16
+ return render(<UndoRedo {...props} />);
18
17
  };
19
- describe('snapshot', () => {
20
- it('renders', () => {
21
- w = wrapper();
22
- expect(w).toMatchSnapshot();
18
+ describe('rendering', () => {
19
+ it('renders without crashing', () => {
20
+ const { container } = renderComponent();
21
+ expect(container.firstChild).toBeInTheDocument();
23
22
  });
24
23
  });
25
24
  });
@@ -1,6 +1,9 @@
1
1
  export const scaleMock = () => {
2
2
  const fn = jest.fn((n) => n);
3
3
  fn.invert = jest.fn((n) => n);
4
+ fn.domain = jest.fn(() => fn);
5
+ fn.range = jest.fn(() => fn);
6
+ fn.copy = jest.fn(() => scaleMock());
4
7
  return fn;
5
8
  };
6
9
 
@@ -1,11 +1,10 @@
1
- import { shallow } from 'enzyme';
1
+ import { render } from '@pie-lib/test-utils';
2
2
  import React from 'react';
3
3
  import { Arrow } from '../arrow';
4
4
 
5
5
  describe('Arrow', () => {
6
- let w;
7
6
  let onChange = jest.fn();
8
- const wrapper = (extras) => {
7
+ const renderComponent = (extras) => {
9
8
  const defaults = {
10
9
  classes: {},
11
10
  className: 'className',
@@ -16,24 +15,24 @@ describe('Arrow', () => {
16
15
  },
17
16
  };
18
17
  const props = { ...defaults, ...extras };
19
- return shallow(<Arrow {...props} />);
18
+ return render(<Arrow {...props} />);
20
19
  };
21
- describe('snapshot', () => {
22
- it('up', () => {
23
- w = wrapper({ direction: 'up' });
24
- expect(w).toMatchSnapshot();
20
+ describe('rendering', () => {
21
+ it('renders with direction up', () => {
22
+ const { container } = renderComponent({ direction: 'up' });
23
+ expect(container.firstChild).toBeInTheDocument();
25
24
  });
26
- it('down', () => {
27
- w = wrapper({ direction: 'down' });
28
- expect(w).toMatchSnapshot();
25
+ it('renders with direction down', () => {
26
+ const { container } = renderComponent({ direction: 'down' });
27
+ expect(container.firstChild).toBeInTheDocument();
29
28
  });
30
- it('left', () => {
31
- w = wrapper({ direction: 'left' });
32
- expect(w).toMatchSnapshot();
29
+ it('renders with direction left', () => {
30
+ const { container } = renderComponent({ direction: 'left' });
31
+ expect(container.firstChild).toBeInTheDocument();
33
32
  });
34
- it('right', () => {
35
- w = wrapper({ direction: 'right' });
36
- expect(w).toMatchSnapshot();
33
+ it('renders with direction right', () => {
34
+ const { container } = renderComponent({ direction: 'right' });
35
+ expect(container.firstChild).toBeInTheDocument();
37
36
  });
38
37
  });
39
38
  });
@@ -1,13 +1,12 @@
1
- import { shallow } from 'enzyme';
1
+ import { render } from '@pie-lib/test-utils';
2
2
  import React from 'react';
3
3
  import { graphProps } from '../../__tests__/utils';
4
4
 
5
5
  import Axes, { RawXAxis, RawYAxis, firstNegativeValue, sharedValues } from '../axes';
6
6
 
7
7
  describe('RawXAxis', () => {
8
- let w;
9
8
  let onChange = jest.fn();
10
- const wrapper = (extras) => {
9
+ const renderComponent = (extras) => {
11
10
  const defaults = {
12
11
  classes: {},
13
12
  className: 'className',
@@ -19,22 +18,25 @@ describe('RawXAxis', () => {
19
18
  up: true,
20
19
  down: true,
21
20
  },
21
+ columnTicksValues: [-1, 0, 1],
22
+ skipValues: [],
23
+ distanceFromOriginToFirstNegativeY: 0,
24
+ dy: 0,
22
25
  };
23
26
  const props = { ...defaults, ...extras };
24
- return shallow(<RawXAxis {...props} />);
27
+ return render(<RawXAxis {...props} />);
25
28
  };
26
- describe('snapshot', () => {
27
- it('renders', () => {
28
- w = wrapper();
29
- expect(w).toMatchSnapshot();
29
+ describe('rendering', () => {
30
+ it('renders without crashing', () => {
31
+ const { container } = renderComponent();
32
+ expect(container.firstChild).toBeInTheDocument();
30
33
  });
31
34
  });
32
35
  });
33
36
 
34
37
  describe('RawYAxis', () => {
35
- let w;
36
38
  let onChange = jest.fn();
37
- const wrapper = (extras) => {
39
+ const renderComponent = (extras) => {
38
40
  const defaults = {
39
41
  classes: {},
40
42
  className: 'className',
@@ -46,14 +48,16 @@ describe('RawYAxis', () => {
46
48
  up: true,
47
49
  down: true,
48
50
  },
51
+ rowTickValues: [-1, 0, 1],
52
+ skipValues: [],
49
53
  };
50
54
  const props = { ...defaults, ...extras };
51
- return shallow(<RawYAxis {...props} />);
55
+ return render(<RawYAxis {...props} />);
52
56
  };
53
- describe('snapshot', () => {
54
- it('renders', () => {
55
- w = wrapper();
56
- expect(w).toMatchSnapshot();
57
+ describe('rendering', () => {
58
+ it('renders without crashing', () => {
59
+ const { container } = renderComponent();
60
+ expect(container.firstChild).toBeInTheDocument();
57
61
  });
58
62
  });
59
63
  });
@@ -61,11 +65,13 @@ describe('RawYAxis', () => {
61
65
  const customScaleMock = (distance) => {
62
66
  const fn = jest.fn((n) => n * distance);
63
67
  fn.invert = jest.fn((n) => n * distance);
68
+ fn.domain = jest.fn(() => fn);
69
+ fn.range = jest.fn(() => fn);
70
+ fn.copy = jest.fn(() => customScaleMock(distance));
64
71
  return fn;
65
72
  };
66
73
 
67
- describe.only('Axes', () => {
68
- let w;
74
+ describe('Axes', () => {
69
75
  let onChange = jest.fn();
70
76
 
71
77
  const customGraphProps = {
@@ -88,7 +94,7 @@ describe.only('Axes', () => {
88
94
  },
89
95
  };
90
96
 
91
- const wrapper = (extras) => {
97
+ const renderComponent = (extras) => {
92
98
  const defaults = {
93
99
  classes: {},
94
100
  className: 'className',
@@ -97,124 +103,114 @@ describe.only('Axes', () => {
97
103
  };
98
104
 
99
105
  const props = { ...defaults, ...extras };
100
- return shallow(<Axes {...props} />);
106
+ return render(<Axes {...props} />);
101
107
  };
102
- describe('xValues', () => {
103
- it('renders', () => {
104
- w = wrapper();
105
- const result = w.instance().xValues();
106
- expect(result).toEqual({
107
- columnTicksValues: expect.arrayContaining([-2, -1, 0, 1, 2]),
108
- distanceFromOriginToFirstNegativeX: 150,
109
- firstNegativeX: -1,
110
- });
108
+ describe('rendering', () => {
109
+ it('renders without crashing', () => {
110
+ const { container } = renderComponent();
111
+ expect(container.firstChild).toBeInTheDocument();
111
112
  });
112
113
  });
113
- describe('yValues', () => {
114
- it('renders', () => {
115
- w = wrapper();
116
- const result = w.instance().yValues();
117
- expect(result).toEqual({
118
- rowTickValues: expect.arrayContaining([-2, -1, 0, 1, 2]),
119
- distanceFromOriginToFirstNegativeY: 200,
120
- firstNegativeY: -1,
121
- });
122
- });
123
- });
124
- });
125
-
126
- describe('firstNegativeValue should return undefiend for undefined interval', () => {
127
- const interval = undefined;
128
- const result = firstNegativeValue(interval);
129
- expect(result).toEqual(undefined);
130
- });
131
-
132
- describe('firstNegativeValue should return undefiend for empty interval', () => {
133
- const interval = [];
134
- const result = firstNegativeValue(interval);
135
- expect(result).toEqual(undefined);
136
114
  });
137
115
 
138
- describe('firstNegativeValue should return undefined if there is no negative in interval array', () => {
139
- const interval = [1, 5, 7, 4, 5];
140
- const result = firstNegativeValue(interval);
141
- expect(result).toEqual(undefined);
142
- });
143
-
144
- describe('firstNegativeValue should return first negative number from interval', () => {
145
- const interval = [1, 5, 7, -2, 4, 5, -1];
146
- const result = firstNegativeValue(interval);
147
- expect(result).toEqual(-2);
148
- });
149
-
150
- describe('skipValue should be empty array if firstNegativeValue for one of the axes is undefined', () => {
151
- // x
152
- const intervalX = [1, 2, 3, 4, 5, 6];
153
- const firstNegativeX = firstNegativeValue(intervalX);
154
- const distanceFromOriginToFirstNegativeX = -22;
155
-
156
- // y
157
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
158
- const firstNegativeY = firstNegativeValue(intervalY);
159
- const distanceFromOriginToFirstNegativeY = -22;
116
+ describe('firstNegativeValue', () => {
117
+ it('should return undefined for undefined interval', () => {
118
+ const interval = undefined;
119
+ const result = firstNegativeValue(interval);
120
+ expect(result).toEqual(undefined);
121
+ });
160
122
 
161
- const deltaAllowance = 5;
123
+ it('should return undefined for empty interval', () => {
124
+ const interval = [];
125
+ const result = firstNegativeValue(interval);
126
+ expect(result).toEqual(undefined);
127
+ });
162
128
 
163
- const result = sharedValues(
164
- firstNegativeX,
165
- firstNegativeY,
166
- distanceFromOriginToFirstNegativeX,
167
- distanceFromOriginToFirstNegativeY,
168
- deltaAllowance,
169
- );
129
+ it('should return undefined if there is no negative in interval array', () => {
130
+ const interval = [1, 5, 7, 4, 5];
131
+ const result = firstNegativeValue(interval);
132
+ expect(result).toEqual(undefined);
133
+ });
170
134
 
171
- expect(result).toEqual([]);
135
+ it('should return first negative number from interval', () => {
136
+ const interval = [1, 5, 7, -2, 4, 5, -1];
137
+ const result = firstNegativeValue(interval);
138
+ expect(result).toEqual(-2);
139
+ });
172
140
  });
173
141
 
174
- describe('skipValue should be empty array if firstNegativeX and firstNegativeY are equal but they do not overlap', () => {
175
- // x
176
- const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
177
- const firstNegativeX = firstNegativeValue(intervalX);
178
- const distanceFromOriginToFirstNegativeX = -7;
179
-
180
- // y
181
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
182
- const firstNegativeY = firstNegativeValue(intervalY);
183
- const distanceFromOriginToFirstNegativeY = -22;
184
-
185
- const deltaAllowance = 5;
186
-
187
- const result = sharedValues(
188
- firstNegativeX,
189
- firstNegativeY,
190
- distanceFromOriginToFirstNegativeX,
191
- distanceFromOriginToFirstNegativeY,
192
- deltaAllowance,
193
- );
142
+ describe('sharedValues', () => {
143
+ it('should be empty array if firstNegativeValue for one of the axes is undefined', () => {
144
+ // x
145
+ const intervalX = [1, 2, 3, 4, 5, 6];
146
+ const firstNegativeX = firstNegativeValue(intervalX);
147
+ const distanceFromOriginToFirstNegativeX = -22;
148
+
149
+ // y
150
+ const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
151
+ const firstNegativeY = firstNegativeValue(intervalY);
152
+ const distanceFromOriginToFirstNegativeY = -22;
153
+
154
+ const deltaAllowance = 5;
155
+
156
+ const result = sharedValues(
157
+ firstNegativeX,
158
+ firstNegativeY,
159
+ distanceFromOriginToFirstNegativeX,
160
+ distanceFromOriginToFirstNegativeY,
161
+ deltaAllowance,
162
+ );
163
+
164
+ expect(result).toEqual([]);
165
+ });
194
166
 
195
- expect(result).toEqual([]);
196
- });
167
+ it('should be empty array if firstNegativeX and firstNegativeY are equal but they do not overlap', () => {
168
+ // x
169
+ const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
170
+ const firstNegativeX = firstNegativeValue(intervalX);
171
+ const distanceFromOriginToFirstNegativeX = -7;
197
172
 
198
- describe('skipValue should be -1 if firstNegativeX and firstNegativeY are equal and they overlap', () => {
199
- // x
200
- const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
201
- const firstNegativeX = firstNegativeValue(intervalX);
202
- const distanceFromOriginToFirstNegativeX = -20;
173
+ // y
174
+ const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
175
+ const firstNegativeY = firstNegativeValue(intervalY);
176
+ const distanceFromOriginToFirstNegativeY = -22;
203
177
 
204
- // y
205
- const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
206
- const firstNegativeY = firstNegativeValue(intervalY);
207
- const distanceFromOriginToFirstNegativeY = -22;
178
+ const deltaAllowance = 5;
208
179
 
209
- const deltaAllowance = 5;
180
+ const result = sharedValues(
181
+ firstNegativeX,
182
+ firstNegativeY,
183
+ distanceFromOriginToFirstNegativeX,
184
+ distanceFromOriginToFirstNegativeY,
185
+ deltaAllowance,
186
+ );
210
187
 
211
- const result = sharedValues(
212
- firstNegativeX,
213
- firstNegativeY,
214
- distanceFromOriginToFirstNegativeX,
215
- distanceFromOriginToFirstNegativeY,
216
- deltaAllowance,
217
- );
188
+ expect(result).toEqual([]);
189
+ });
218
190
 
219
- expect(result).toEqual([-1]);
191
+ it('should be -1 if firstNegativeX and firstNegativeY are equal and they overlap', () => {
192
+ // x
193
+ const intervalX = [-1, -2, 1, 2, 3, 4, 5, 6];
194
+ const firstNegativeX = firstNegativeValue(intervalX);
195
+ const distanceFromOriginToFirstNegativeX = -20;
196
+
197
+ // y
198
+ const intervalY = [-1, -2, 1, 2, 3, 4, 5, 6];
199
+ const firstNegativeY = firstNegativeValue(intervalY);
200
+ const distanceFromOriginToFirstNegativeY = -22;
201
+
202
+ const deltaAllowance = 5;
203
+ const dy = -20; // dy needs to be within the range for the condition to pass
204
+
205
+ const result = sharedValues(
206
+ firstNegativeX,
207
+ firstNegativeY,
208
+ distanceFromOriginToFirstNegativeX,
209
+ distanceFromOriginToFirstNegativeY,
210
+ deltaAllowance,
211
+ dy,
212
+ );
213
+
214
+ expect(result).toEqual([-1]);
215
+ });
220
216
  });
package/src/axis/axes.jsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Axis } from '@vx/axis';
2
+ import { Axis } from '@visx/axis';
3
3
  import { types } from '@pie-lib/plot';
4
4
  import PropTypes from 'prop-types';
5
5
  import Arrow from './arrow';
@@ -41,11 +41,11 @@ const StyledAxisLabelHolder = styled('div')(({ theme }) => ({
41
41
  }));
42
42
 
43
43
  const StyledAxesGroup = styled('g')(() => ({
44
- '& .vx-axis-line': {
44
+ '& .visx-axis-line': {
45
45
  stroke: color.defaults.PRIMARY,
46
46
  strokeWidth: 3,
47
47
  },
48
- '& .vx-axis-tick': {
48
+ '& .visx-axis-tick': {
49
49
  fill: color.defaults.PRIMARY,
50
50
  '& line': {
51
51
  stroke: color.defaults.PRIMARY,
@@ -102,12 +102,6 @@ export class RawXAxis extends React.Component {
102
102
  } = this.props;
103
103
  const { scale, domain, size, range } = graphProps || {};
104
104
 
105
- // Having 0 as a number in columnTicksValues does not make 0 to show up
106
- // so we use this trick, by defining it as a string:
107
- const tickValues =
108
- (domain.labelStep || range.labelStep) && domain.min <= 0 ? ['0', ...columnTicksValues] : columnTicksValues;
109
- // However, the '0' has to be displayed only if other tick labels (y-axis or x-axis) are displayed
110
-
111
105
  const labelProps = (label) => {
112
106
  const y = skipValues && skipValues[0] === label ? distanceFromOriginToFirstNegativeY + 4 : dy;
113
107
 
@@ -115,8 +109,8 @@ export class RawXAxis extends React.Component {
115
109
  ...tickLabelStyles,
116
110
  textAnchor: 'middle',
117
111
  y: y,
118
- dx: label === '0' ? -10 : 0,
119
- dy: label === '0' ? -7 : 0,
112
+ dx: label === 0 ? -10 : 0,
113
+ dy: label === 0 ? -7 : 0,
120
114
  };
121
115
  };
122
116
 
@@ -134,7 +128,8 @@ export class RawXAxis extends React.Component {
134
128
  rangePadding={8}
135
129
  tickFormat={(value) => value}
136
130
  tickLabelProps={labelProps}
137
- tickValues={tickValues}
131
+ tickValues={columnTicksValues}
132
+ hideZero={!(domain.labelStep || range.labelStep) && domain.min <= 0}
138
133
  />
139
134
  {includeArrows && includeArrows.left && (
140
135
  <StyledArrow direction="left" x={domain.min} y={0} scale={scale} />
@@ -17,6 +17,7 @@ const StyledInputBase = styled(InputBase)(({ theme }) => ({
17
17
  },
18
18
  }));
19
19
 
20
+ // eslint-disable-next-line react/prop-types
20
21
  export const getLabelPosition = (graphProps, x, y, labelLength) => {
21
22
  const { scale, domain, range } = graphProps;
22
23
  // treat corner cases for maximum and minimum
@@ -12,23 +12,23 @@ import { NumberTextFieldCustom, Toggle } from '@pie-lib/config-ui';
12
12
  import EditableHTML from '@pie-lib/editable-html';
13
13
  import { styled } from '@mui/material/styles';
14
14
 
15
- const Wrapper = styled('div')(({ theme }) => ({
15
+ const Wrapper = styled('div')(() => ({
16
16
  width: '450px',
17
17
  }));
18
18
 
19
- const Content = styled('div')(({ theme }) => ({
19
+ const Content = styled('div')(() => ({
20
20
  display: 'flex',
21
21
  flexDirection: 'column',
22
22
  width: '100%',
23
23
  }));
24
24
 
25
- const ColumnView = styled('div')(({ theme }) => ({
25
+ const ColumnView = styled('div')(() => ({
26
26
  display: 'flex',
27
27
  flexDirection: 'column',
28
28
  alignItems: 'center',
29
29
  }));
30
30
 
31
- const RowView = styled('div')(({ theme }) => ({
31
+ const RowView = styled('div')(() => ({
32
32
  display: 'flex',
33
33
  justifyContent: 'space-around',
34
34
  alignItems: 'center',
@@ -60,13 +60,13 @@ const ItalicText = styled(Typography)(({ theme }) => ({
60
60
  margin: `${theme.spacing(1)} 0`,
61
61
  }));
62
62
 
63
- const Dimensions = styled('div')(({ theme }) => ({
63
+ const Dimensions = styled('div')(() => ({
64
64
  display: 'flex',
65
65
  justifyContent: 'space-between',
66
66
  alignItems: 'center',
67
67
  }));
68
68
 
69
- const DisabledText = styled(Typography)(({ theme }) => ({
69
+ const DisabledText = styled(Typography)(() => ({
70
70
  color: color.disabled(),
71
71
  }));
72
72
 
package/src/grid.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import * as vx from '@vx/grid';
3
+ import * as vx from '@visx/grid';
4
4
  import { types } from '@pie-lib/plot';
5
5
  import { getTickValues } from './utils';
6
6
 
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { color } from '@pie-lib/render-ui';
5
5
 
6
- const StyledContainer = styled('div')(({ theme }) => ({
6
+ const StyledContainer = styled('div')(() => ({
7
7
  backgroundColor: color.defaults.WHITE,
8
8
  padding: '20px',
9
9
  width: '355px',
package/src/labels.jsx CHANGED
@@ -64,6 +64,7 @@ class RawLabel extends React.Component {
64
64
  placeholder: PropTypes.string,
65
65
  graphProps: types.GraphPropsType.isRequired,
66
66
  onChange: PropTypes.func,
67
+ mathMlOptions: PropTypes.object,
67
68
  };
68
69
 
69
70
  static defaultProps = {
@@ -138,6 +139,7 @@ export class Labels extends React.Component {
138
139
  value: PropTypes.shape(LabelType),
139
140
  graphProps: PropTypes.object,
140
141
  onChange: PropTypes.object,
142
+ mathMlOptions: PropTypes.object,
141
143
  };
142
144
 
143
145
  static defaultProps = {};
@@ -38,7 +38,7 @@ const StyledInputMissing = styled('div')(({ theme }) => ({
38
38
  fontWeight: 'bold',
39
39
  }));
40
40
 
41
- const StyledIncorrect = styled('div')(({ theme }) => ({
41
+ const StyledIncorrect = styled('div')(() => ({
42
42
  float: 'right',
43
43
  padding: 0,
44
44
  borderRadius: '4px',
@@ -116,6 +116,15 @@ const LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, onCha
116
116
  />
117
117
  );
118
118
 
119
+ LabelInput.propTypes = {
120
+ _ref: PropTypes.func,
121
+ externalInputRef: PropTypes.func,
122
+ label: PropTypes.string,
123
+ disabled: PropTypes.bool,
124
+ inputStyle: PropTypes.object,
125
+ onChange: PropTypes.func,
126
+ };
127
+
119
128
  export const MarkLabel = (props) => {
120
129
  const [input, setInput] = useState(null);
121
130
  const _ref = useCallback((node) => setInput(node));
@@ -60,9 +60,10 @@ MiniButton.propTypes = {
60
60
  selected: PropTypes.bool,
61
61
  value: PropTypes.string,
62
62
  onClick: PropTypes.func,
63
+ language: PropTypes.string,
63
64
  };
64
65
 
65
- const StyledToolsContainer = styled('div')(({ theme }) => ({
66
+ const StyledToolsContainer = styled('div')(() => ({
66
67
  display: 'flex',
67
68
  flexWrap: 'wrap',
68
69
  }));
@@ -96,14 +97,12 @@ export class ToggleBar extends React.Component {
96
97
  moveTool = (dragIndex, hoverIndex) => {
97
98
  const { options, onChangeToolsOrder } = this.props;
98
99
  const newOptions = arrayMove(options, dragIndex, hoverIndex);
99
- console.log('New Options Order:', newOptions);
100
100
  onChangeToolsOrder(newOptions);
101
101
  };
102
102
 
103
103
  handleDragEnd = (event) => {
104
104
  const { active, over } = event;
105
-
106
- console.log('Drag End Event:', event);
105
+
107
106
  if (!over || !active) return;
108
107
 
109
108
  const activeData = active.data.current;
@@ -112,7 +111,7 @@ export class ToggleBar extends React.Component {
112
111
  if (activeData?.type === 'tool' && overData?.type === 'tool') {
113
112
  const dragIndex = activeData.index;
114
113
  const hoverIndex = overData.index;
115
-
114
+
116
115
  if (dragIndex !== hoverIndex) {
117
116
  this.moveTool(dragIndex, hoverIndex);
118
117
  }
@@ -158,22 +157,8 @@ export class ToggleBar extends React.Component {
158
157
  }
159
158
 
160
159
  // DragTool functional component using @dnd-kit hooks
161
- function DragTool({
162
- children,
163
- index,
164
- draggable,
165
- moveTool,
166
- toolRef,
167
- value
168
- }) {
169
- const {
170
- attributes,
171
- listeners,
172
- setNodeRef: setDragNodeRef,
173
- transform,
174
- transition,
175
- isDragging,
176
- } = useDraggable({
160
+ function DragTool({ children, index, draggable, toolRef, value }) {
161
+ const { attributes, listeners, setNodeRef: setDragNodeRef, transform, transition, isDragging } = useDraggable({
177
162
  id: `tool-${value}-${index}`,
178
163
  disabled: !draggable,
179
164
  data: {
@@ -183,10 +168,7 @@ function DragTool({
183
168
  },
184
169
  });
185
170
 
186
- const {
187
- setNodeRef: setDropNodeRef,
188
- isOver,
189
- } = useDroppable({
171
+ const { setNodeRef: setDropNodeRef } = useDroppable({
190
172
  id: `drop-tool-${value}-${index}`,
191
173
  data: {
192
174
  type: 'tool',
package/src/tool-menu.jsx CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
4
 
5
- import ToggleBar, { MiniButton } from './toggle-bar';
5
+ import ToggleBar from './toggle-bar';
6
6
 
7
7
  export class ToolMenu extends React.Component {
8
8
  static propTypes = {