@pie-lib/graphing 2.14.21 → 2.14.22-next.1618
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.
- package/CHANGELOG.json +1 -1017
- package/CHANGELOG.md +159 -24
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/axis/axes.js +5 -5
- package/lib/axis/axes.js.map +1 -1
- package/lib/container/index.js +1 -4
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js +5 -3
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +8 -15
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +29 -12
- package/lib/graph.js.map +1 -1
- package/lib/grid.js +6 -14
- package/lib/grid.js.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +246 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/label-svg-icon.js +56 -0
- package/lib/label-svg-icon.js.map +1 -0
- package/lib/labels.js +2 -1
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +167 -56
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +3 -4
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +2 -22
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/component.js +35 -0
- package/lib/tools/absolute/component.js.map +1 -0
- package/lib/tools/absolute/index.js +63 -0
- package/lib/tools/absolute/index.js.map +1 -0
- package/lib/tools/circle/bg-circle.js +4 -3
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +34 -15
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/exponential/component.js +34 -0
- package/lib/tools/exponential/component.js.map +1 -0
- package/lib/tools/exponential/index.js +71 -0
- package/lib/tools/exponential/index.js.map +1 -0
- package/lib/tools/index.js +26 -6
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +2 -1
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js +6 -5
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/point/component.js +14 -9
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/polygon/component.js +25 -12
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/line.js +12 -6
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +6 -3
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +2 -1
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js +2 -1
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +36 -0
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -0
- package/lib/tools/shared/icons/IncorrectSVG.js +36 -0
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -0
- package/lib/tools/shared/icons/MissingSVG.js +35 -0
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -0
- package/lib/tools/shared/line/index.js +51 -19
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +13 -7
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +19 -8
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +1 -1
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +1 -1
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +43 -7
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +4 -1
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +16 -7
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/sine/component.js +13 -4
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/vector/component.js +2 -1
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js +0 -1
- package/lib/undo-redo.js.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +12 -7
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +237 -0
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +211 -0
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +54 -0
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +30 -0
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +45 -0
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +7 -0
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +13 -0
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +14 -0
- package/src/__tests__/graph-with-controls.test.jsx +147 -0
- package/src/__tests__/graph.test.jsx +230 -0
- package/src/__tests__/grid.test.jsx +20 -0
- package/src/__tests__/labels.test.jsx +38 -0
- package/src/__tests__/mark-label.test.jsx +68 -0
- package/src/__tests__/toggle-bar.test.jsx +36 -0
- package/src/__tests__/tool-menu.test.jsx +29 -0
- package/src/__tests__/undo-redo.test.jsx +25 -0
- package/src/__tests__/use-debounce.test.js +21 -0
- package/src/__tests__/utils.js +38 -0
- package/src/__tests__/utils.test.js +151 -0
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +33 -0
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +122 -0
- package/src/axis/__tests__/arrow.test.jsx +39 -0
- package/src/axis/__tests__/axes.test.jsx +220 -0
- package/src/axis/axes.jsx +5 -5
- package/src/container/index.jsx +2 -4
- package/src/coordinates-label.jsx +4 -3
- package/src/graph-with-controls.jsx +8 -10
- package/src/graph.jsx +22 -10
- package/src/grid.jsx +8 -10
- package/src/index.js +2 -2
- package/src/key-legend.jsx +145 -0
- package/src/label-svg-icon.jsx +39 -0
- package/src/labels.jsx +2 -1
- package/src/mark-label.jsx +149 -52
- package/src/toggle-bar.jsx +1 -2
- package/src/tool-menu.jsx +3 -26
- package/src/tools/absolute/__tests__/component.test.jsx +54 -0
- package/src/tools/absolute/component.jsx +23 -0
- package/src/tools/absolute/index.js +31 -0
- package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +46 -0
- package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +293 -0
- package/src/tools/circle/__tests__/bg-circle.test.jsx +28 -0
- package/src/tools/circle/__tests__/component.test.jsx +228 -0
- package/src/tools/circle/bg-circle.jsx +5 -4
- package/src/tools/circle/component.jsx +22 -8
- package/src/tools/exponential/__tests__/component.test.jsx +54 -0
- package/src/tools/exponential/component.jsx +23 -0
- package/src/tools/exponential/index.js +39 -0
- package/src/tools/index.js +38 -5
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +20 -0
- package/src/tools/line/__tests__/component.test.jsx +36 -0
- package/src/tools/line/component.jsx +2 -1
- package/src/tools/parabola/__tests__/component.test.jsx +49 -0
- package/src/tools/parabola/component.jsx +7 -6
- package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +40 -0
- package/src/tools/point/__tests__/component.test.jsx +66 -0
- package/src/tools/point/component.jsx +12 -6
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +415 -0
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +45 -0
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +52 -0
- package/src/tools/polygon/__tests__/component.test.jsx +226 -0
- package/src/tools/polygon/__tests__/index.test.js +65 -0
- package/src/tools/polygon/__tests__/line.test.jsx +25 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
- package/src/tools/polygon/component.jsx +39 -11
- package/src/tools/polygon/line.jsx +15 -7
- package/src/tools/polygon/polygon.jsx +7 -3
- package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +23 -0
- package/src/tools/ray/__tests__/component.test.jsx +29 -0
- package/src/tools/ray/component.jsx +2 -1
- package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +14 -0
- package/src/tools/segment/__tests__/component.test.jsx +28 -0
- package/src/tools/segment/component.jsx +2 -1
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +27 -0
- package/src/tools/shared/__tests__/arrow-head.test.jsx +34 -0
- package/src/tools/shared/icons/CorrectSVG.jsx +22 -0
- package/src/tools/shared/icons/IncorrectSVG.jsx +20 -0
- package/src/tools/shared/icons/MissingSVG.jsx +21 -0
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +360 -0
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +58 -0
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +63 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +255 -0
- package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
- package/src/tools/shared/line/index.jsx +39 -13
- package/src/tools/shared/line/line-path.jsx +18 -7
- package/src/tools/shared/line/with-root-edge.jsx +10 -3
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +56 -0
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +44 -0
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +87 -0
- package/src/tools/shared/point/__tests__/base-point.test.jsx +84 -0
- package/src/tools/shared/point/arrow-point.jsx +4 -1
- package/src/tools/shared/point/arrow.jsx +4 -1
- package/src/tools/shared/point/base-point.jsx +28 -3
- package/src/tools/shared/point/index.jsx +7 -2
- package/src/tools/shared/styles.js +8 -3
- package/src/tools/sine/__tests__/component.test.jsx +51 -0
- package/src/tools/sine/component.jsx +7 -7
- package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +12 -0
- package/src/tools/vector/__tests__/component.test.jsx +26 -0
- package/src/tools/vector/component.jsx +2 -1
- package/src/undo-redo.jsx +0 -1
- package/src/utils.js +1 -1
- package/legacy.png +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`BasePoint snapshot renders 1`] = `
|
|
4
|
+
<RawBp
|
|
5
|
+
className="className"
|
|
6
|
+
classes={
|
|
7
|
+
Object {
|
|
8
|
+
"correct": "RawBp-correct-4",
|
|
9
|
+
"disabled": "RawBp-disabled-2",
|
|
10
|
+
"disabledSecondary": "RawBp-disabledSecondary-3",
|
|
11
|
+
"incorrect": "RawBp-incorrect-5",
|
|
12
|
+
"missing": "RawBp-missing-6",
|
|
13
|
+
"point": "RawBp-point-1",
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
graphProps={
|
|
17
|
+
Object {
|
|
18
|
+
"domain": Object {
|
|
19
|
+
"max": 1,
|
|
20
|
+
"min": 0,
|
|
21
|
+
"step": 1,
|
|
22
|
+
},
|
|
23
|
+
"range": Object {
|
|
24
|
+
"max": 1,
|
|
25
|
+
"min": 0,
|
|
26
|
+
"step": 1,
|
|
27
|
+
},
|
|
28
|
+
"scale": Object {
|
|
29
|
+
"x": [MockFunction],
|
|
30
|
+
"y": [MockFunction],
|
|
31
|
+
},
|
|
32
|
+
"size": Object {
|
|
33
|
+
"height": 400,
|
|
34
|
+
"width": 400,
|
|
35
|
+
},
|
|
36
|
+
"snap": Object {
|
|
37
|
+
"x": [MockFunction],
|
|
38
|
+
"y": [MockFunction],
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
onChange={[MockFunction]}
|
|
43
|
+
/>
|
|
44
|
+
`;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { shallow } from 'enzyme/build';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ArrowPoint } from '../index';
|
|
4
|
+
import { graphProps } from '../../../../__tests__/utils';
|
|
5
|
+
import { bounds } from '../../../../utils';
|
|
6
|
+
import { gridDraggable, utils } from '@pie-lib/plot';
|
|
7
|
+
|
|
8
|
+
const { xy } = utils;
|
|
9
|
+
jest.mock('../../../../utils', () => {
|
|
10
|
+
const { point } = jest.requireActual('../../../../utils');
|
|
11
|
+
return {
|
|
12
|
+
bounds: jest.fn(),
|
|
13
|
+
point,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
jest.mock('@pie-lib/plot', () => {
|
|
18
|
+
const { types, utils } = jest.requireActual('@pie-lib/plot');
|
|
19
|
+
return {
|
|
20
|
+
gridDraggable: jest.fn((opts) => (Comp) => Comp),
|
|
21
|
+
types,
|
|
22
|
+
utils,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('ArrowPoint', () => {
|
|
27
|
+
let w;
|
|
28
|
+
let onChange = jest.fn();
|
|
29
|
+
const wrapper = (extras) => {
|
|
30
|
+
const defaults = {
|
|
31
|
+
classes: {},
|
|
32
|
+
className: 'className',
|
|
33
|
+
onChange,
|
|
34
|
+
graphProps: graphProps(),
|
|
35
|
+
from: xy(0, 0),
|
|
36
|
+
to: xy(1, 1),
|
|
37
|
+
};
|
|
38
|
+
const props = { ...defaults, ...extras };
|
|
39
|
+
return shallow(<ArrowPoint {...props} />);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
describe('snapshot', () => {
|
|
43
|
+
it('renders', () => {
|
|
44
|
+
w = wrapper();
|
|
45
|
+
expect(w).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('gridDraggable options', () => {
|
|
49
|
+
let opts;
|
|
50
|
+
let domain;
|
|
51
|
+
let range;
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
domain = {
|
|
54
|
+
min: 0,
|
|
55
|
+
max: 1,
|
|
56
|
+
step: 1,
|
|
57
|
+
};
|
|
58
|
+
range = {
|
|
59
|
+
min: 0,
|
|
60
|
+
max: 1,
|
|
61
|
+
step: 1,
|
|
62
|
+
};
|
|
63
|
+
const w = wrapper();
|
|
64
|
+
opts = gridDraggable.mock.calls[0][0];
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('bounds', () => {
|
|
68
|
+
it('calls utils.bounds with area', () => {
|
|
69
|
+
const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
|
|
70
|
+
expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('anchorPoint', () => {
|
|
74
|
+
it('returns x/y', () => {
|
|
75
|
+
const result = opts.anchorPoint({ x: 0, y: 0 });
|
|
76
|
+
expect(result).toEqual({ x: 0, y: 0 });
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('fromDelta', () => {
|
|
81
|
+
it('returns a new point from the x/y + delta', () => {
|
|
82
|
+
const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
|
|
83
|
+
expect(result).toEqual({ x: 0, y: 3 });
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { shallow } from 'enzyme/build';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { BasePoint } from '../index';
|
|
4
|
+
import { gridDraggable } from '@pie-lib/plot';
|
|
5
|
+
import { graphProps } from '../../../../__tests__/utils';
|
|
6
|
+
import { bounds } from '../../../../utils';
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../../utils', () => {
|
|
9
|
+
const { point } = jest.requireActual('../../../../utils');
|
|
10
|
+
return {
|
|
11
|
+
bounds: jest.fn(),
|
|
12
|
+
point,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
jest.mock('@pie-lib/plot', () => {
|
|
17
|
+
const { types, utils } = jest.requireActual('@pie-lib/plot');
|
|
18
|
+
return {
|
|
19
|
+
gridDraggable: jest.fn((opts) => (Comp) => Comp),
|
|
20
|
+
types,
|
|
21
|
+
utils,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('BasePoint', () => {
|
|
26
|
+
let w;
|
|
27
|
+
let onChange = jest.fn();
|
|
28
|
+
const wrapper = (extras) => {
|
|
29
|
+
const defaults = {
|
|
30
|
+
classes: {},
|
|
31
|
+
className: 'className',
|
|
32
|
+
onChange,
|
|
33
|
+
graphProps: graphProps(),
|
|
34
|
+
};
|
|
35
|
+
const props = { ...defaults, ...extras };
|
|
36
|
+
return shallow(<BasePoint {...props} />);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
describe('snapshot', () => {
|
|
40
|
+
it('renders', () => {
|
|
41
|
+
w = wrapper();
|
|
42
|
+
expect(w).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('gridDraggable options', () => {
|
|
46
|
+
let opts;
|
|
47
|
+
let domain;
|
|
48
|
+
let range;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
domain = {
|
|
51
|
+
min: 0,
|
|
52
|
+
max: 1,
|
|
53
|
+
step: 1,
|
|
54
|
+
};
|
|
55
|
+
range = {
|
|
56
|
+
min: 0,
|
|
57
|
+
max: 1,
|
|
58
|
+
step: 1,
|
|
59
|
+
};
|
|
60
|
+
const w = wrapper();
|
|
61
|
+
opts = gridDraggable.mock.calls[0][0];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('bounds', () => {
|
|
65
|
+
it('calls utils.bounds with area', () => {
|
|
66
|
+
const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
|
|
67
|
+
expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('anchorPoint', () => {
|
|
71
|
+
it('returns x/y', () => {
|
|
72
|
+
const result = opts.anchorPoint({ x: 0, y: 0 });
|
|
73
|
+
expect(result).toEqual({ x: 0, y: 0 });
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('fromDelta', () => {
|
|
78
|
+
it('returns a new point from the x/y + delta', () => {
|
|
79
|
+
const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
|
|
80
|
+
expect(result).toEqual({ x: 0, y: 3 });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -47,7 +47,10 @@ export class RawArrow extends React.Component {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
<g
|
|
50
|
+
<g
|
|
51
|
+
className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
52
|
+
{...rest}
|
|
53
|
+
>
|
|
51
54
|
<polygon
|
|
52
55
|
points={points}
|
|
53
56
|
transform={`
|
|
@@ -32,7 +32,10 @@ export default class Arrow extends React.Component {
|
|
|
32
32
|
${scaledX - size}, ${scaledY + size / 2}`;
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<g
|
|
35
|
+
<g
|
|
36
|
+
className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
37
|
+
{...rest}
|
|
38
|
+
>
|
|
36
39
|
<ArrowHead size={size} transform={transform} points={points} />
|
|
37
40
|
</g>
|
|
38
41
|
);
|
|
@@ -5,6 +5,9 @@ import { types } from '@pie-lib/plot';
|
|
|
5
5
|
import CoordinatesLabel from '../../../coordinates-label';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
7
|
import { thinnerShapesNeeded } from '../../../utils';
|
|
8
|
+
import MissingSVG from '../icons/MissingSVG';
|
|
9
|
+
import CorrectSVG from '../icons/CorrectSVG';
|
|
10
|
+
import IncorrectSVG from '../icons/IncorrectSVG';
|
|
8
11
|
|
|
9
12
|
export class RawBp extends React.Component {
|
|
10
13
|
static propTypes = {
|
|
@@ -38,11 +41,31 @@ export class RawBp extends React.Component {
|
|
|
38
41
|
// we need to remove style from props
|
|
39
42
|
// eslint-disable-next-line no-unused-vars,react/prop-types
|
|
40
43
|
style,
|
|
44
|
+
onClick,
|
|
45
|
+
// Refactored RawBp component by isolating onTouchStart and onTouchEnd handlers to the outer circle, resolving erratic touch event behavior.
|
|
46
|
+
// Remaining props are now applied only to the inner circle for improved event handling consistency.
|
|
47
|
+
onTouchStart,
|
|
48
|
+
onTouchEnd,
|
|
41
49
|
...rest
|
|
42
50
|
} = this.props;
|
|
43
51
|
const { showCoordinates } = this.state;
|
|
44
52
|
const { scale } = graphProps;
|
|
45
53
|
const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
|
|
54
|
+
let SvgComponent;
|
|
55
|
+
switch (correctness) {
|
|
56
|
+
case 'missing':
|
|
57
|
+
SvgComponent = MissingSVG;
|
|
58
|
+
break;
|
|
59
|
+
case 'correct':
|
|
60
|
+
SvgComponent = CorrectSVG;
|
|
61
|
+
break;
|
|
62
|
+
case 'incorrect':
|
|
63
|
+
SvgComponent = IncorrectSVG;
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
SvgComponent = null;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
46
69
|
|
|
47
70
|
return (
|
|
48
71
|
<>
|
|
@@ -53,15 +76,17 @@ export class RawBp extends React.Component {
|
|
|
53
76
|
cy={scale.y(y)}
|
|
54
77
|
onMouseEnter={() => this.setState({ showCoordinates: true })}
|
|
55
78
|
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
56
|
-
{
|
|
79
|
+
onTouchStart={onTouchStart}
|
|
80
|
+
onTouchEnd={onTouchEnd}
|
|
81
|
+
onClick={onClick}
|
|
57
82
|
/>
|
|
58
83
|
<g
|
|
59
|
-
className={classNames(classes.point, disabled && classes.
|
|
84
|
+
className={classNames(classes.point, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
60
85
|
onMouseEnter={() => this.setState({ showCoordinates: true })}
|
|
61
86
|
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
62
|
-
{...rest}
|
|
63
87
|
>
|
|
64
88
|
<circle {...rest} r={r} cx={scale.x(x)} cy={scale.y(y)} />
|
|
89
|
+
{SvgComponent && <SvgComponent scale={scale} x={x} y={y} />}
|
|
65
90
|
{labelNode &&
|
|
66
91
|
coordinatesOnHover &&
|
|
67
92
|
showCoordinates &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
2
2
|
import { gridDraggable } from '@pie-lib/plot';
|
|
3
3
|
import * as utils from '../../../utils';
|
|
4
|
-
import { disabled, correct, incorrect, missing } from '../styles';
|
|
4
|
+
import { disabled, correct, incorrect, missing, disabledSecondary } from '../styles';
|
|
5
5
|
import { RawBp } from './base-point';
|
|
6
6
|
import { RawArrow } from './arrow-point';
|
|
7
7
|
import { color } from '@pie-lib/render-ui';
|
|
@@ -29,7 +29,7 @@ const styles = () => {
|
|
|
29
29
|
point: {
|
|
30
30
|
'& circle, & polygon': {
|
|
31
31
|
cursor: 'pointer',
|
|
32
|
-
fill: color.
|
|
32
|
+
fill: color.defaults.BLACK,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
disabled: {
|
|
@@ -37,6 +37,11 @@ const styles = () => {
|
|
|
37
37
|
...disabled(),
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
disabledSecondary: {
|
|
41
|
+
'& circle, & polygon': {
|
|
42
|
+
...disabledSecondary(),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
40
45
|
correct: {
|
|
41
46
|
'& circle, & polygon': {
|
|
42
47
|
...correct(),
|
|
@@ -5,16 +5,21 @@ export const disabled = (key = 'fill') => ({
|
|
|
5
5
|
pointerEvents: 'none',
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
+
export const disabledSecondary = (key = 'fill') => ({
|
|
9
|
+
[key]: color.disabledSecondary(),
|
|
10
|
+
pointerEvents: 'none',
|
|
11
|
+
});
|
|
12
|
+
|
|
8
13
|
export const correct = (key = 'fill') => ({
|
|
9
|
-
[key]: color.
|
|
14
|
+
[key]: color.correctWithIcon(),
|
|
10
15
|
pointerEvents: 'none',
|
|
11
16
|
});
|
|
12
17
|
export const incorrect = (key = 'fill') => ({
|
|
13
|
-
[key]: color.
|
|
18
|
+
[key]: color.incorrectWithIcon(),
|
|
14
19
|
pointerEvents: 'none',
|
|
15
20
|
});
|
|
16
21
|
|
|
17
22
|
export const missing = (key = 'fill') => ({
|
|
18
|
-
[key]: color.
|
|
23
|
+
[key]: color.missingWithIcon(),
|
|
19
24
|
pointerEvents: 'none',
|
|
20
25
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { withRootEdge } from '../../shared/line/with-root-edge';
|
|
2
|
+
import { buildDataPoints, sinY } from '@pie-lib/graphing-utils';
|
|
3
|
+
import { utils } from '@pie-lib/plot';
|
|
4
|
+
|
|
5
|
+
import { graphProps as getGraphProps } from '../../../__tests__/utils';
|
|
6
|
+
|
|
7
|
+
const { xy } = utils;
|
|
8
|
+
jest.mock('@pie-lib/graphing-utils', () => ({
|
|
9
|
+
sinY: jest.fn().mockReturnValue(0),
|
|
10
|
+
buildDataPoints: jest.fn().mockReturnValue([]),
|
|
11
|
+
parabolaFromTwoPoints: jest.fn(() => jest.fn()),
|
|
12
|
+
getAmplitudeAndFreq: jest.fn().mockReturnValue({ freq: 4, amplitude: 1 }),
|
|
13
|
+
FREQ_DIVIDER: 16,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock('../../shared/line/with-root-edge', () => ({
|
|
17
|
+
withRootEdge: jest.fn(),
|
|
18
|
+
rootEdgeComponent: jest.fn(),
|
|
19
|
+
}));
|
|
20
|
+
describe('Parabola', () => {
|
|
21
|
+
let fnBody;
|
|
22
|
+
let graphProps;
|
|
23
|
+
let root;
|
|
24
|
+
let edge;
|
|
25
|
+
let result;
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
require('../component');
|
|
28
|
+
fnBody = withRootEdge.mock.calls[0][0];
|
|
29
|
+
graphProps = getGraphProps();
|
|
30
|
+
root = xy(0, 0);
|
|
31
|
+
edge = xy(1, 1);
|
|
32
|
+
|
|
33
|
+
result = fnBody({ graphProps, root, edge });
|
|
34
|
+
});
|
|
35
|
+
it('fnBody is not null', () => {
|
|
36
|
+
expect(fnBody).toBeDefined();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('calls buildDataPoints', () => {
|
|
40
|
+
const { domain, range } = graphProps;
|
|
41
|
+
expect(buildDataPoints).toHaveBeenCalledWith({ ...domain, step: 0.25 }, range, root, edge, expect.anything());
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('calls sinY', () => {
|
|
45
|
+
expect(sinY).toHaveBeenCalledWith(1, 4, expect.anything());
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns dataPoints', () => {
|
|
49
|
+
expect(result).toEqual({ root, edge, dataPoints: [] });
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -4,29 +4,29 @@ import { withRootEdge, rootEdgeComponent } from '../shared/line/with-root-edge';
|
|
|
4
4
|
|
|
5
5
|
const log = debug('pie-lib:graphing:sine');
|
|
6
6
|
|
|
7
|
-
log('sine...');
|
|
8
|
-
|
|
9
7
|
const Sine = withRootEdge((props) => {
|
|
10
|
-
const {
|
|
8
|
+
const { root, edge, graphProps } = props;
|
|
9
|
+
const { domain, range } = graphProps;
|
|
11
10
|
|
|
12
|
-
const { root, edge } = props;
|
|
13
11
|
const { amplitude, freq } = getAmplitudeAndFreq(root, edge);
|
|
14
12
|
const interval = freq / FREQ_DIVIDER;
|
|
13
|
+
|
|
15
14
|
log('[getPoints] amplitude:', amplitude, 'freq:', freq);
|
|
16
15
|
|
|
17
16
|
const dataPoints =
|
|
18
17
|
edge && edge.x === root.x
|
|
19
18
|
? []
|
|
20
19
|
: buildDataPoints(
|
|
21
|
-
domain
|
|
22
|
-
|
|
20
|
+
{ ...domain, step: interval },
|
|
21
|
+
range,
|
|
23
22
|
root,
|
|
24
23
|
edge,
|
|
25
|
-
interval,
|
|
26
24
|
sinY(amplitude, freq, { phase: root.x, vertical: root.y }),
|
|
27
25
|
);
|
|
26
|
+
|
|
28
27
|
return { root: props.root, edge: props.edge, dataPoints };
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
const Component = rootEdgeComponent(Sine);
|
|
31
|
+
|
|
32
32
|
export default Component;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Line } from '../component';
|
|
4
|
+
import { graphProps as getGraphProps } from '../../../__tests__/utils';
|
|
5
|
+
import { utils } from '@pie-lib/plot';
|
|
6
|
+
|
|
7
|
+
describe('Line', () => {
|
|
8
|
+
let w;
|
|
9
|
+
const wrapper = (extras) => {
|
|
10
|
+
const defaults = {
|
|
11
|
+
classes: {},
|
|
12
|
+
className: 'className',
|
|
13
|
+
graphProps: getGraphProps(),
|
|
14
|
+
from: utils.xy(0, 0),
|
|
15
|
+
to: utils.xy(1, 1),
|
|
16
|
+
};
|
|
17
|
+
const props = { ...defaults, ...extras };
|
|
18
|
+
return shallow(<Line {...props} />);
|
|
19
|
+
};
|
|
20
|
+
describe('snapshot', () => {
|
|
21
|
+
it('renders', () => {
|
|
22
|
+
const w = wrapper();
|
|
23
|
+
expect(w).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -10,6 +10,7 @@ import { getDistanceBetweenTwoPoints } from '../../utils';
|
|
|
10
10
|
const lineStyles = (theme) => ({
|
|
11
11
|
line: styles.line(theme),
|
|
12
12
|
disabled: styles.disabled(theme),
|
|
13
|
+
disabledSecondary: styles.disabledSecondary(theme),
|
|
13
14
|
correct: styles.correct(theme, 'stroke'),
|
|
14
15
|
incorrect: styles.incorrect(theme, 'stroke'),
|
|
15
16
|
missing: styles.missing(theme, 'stroke'),
|
|
@@ -32,7 +33,7 @@ export const Line = (props) => {
|
|
|
32
33
|
|
|
33
34
|
return (
|
|
34
35
|
<line
|
|
35
|
-
className={classNames(classes.line, disabled && classes.
|
|
36
|
+
className={classNames(classes.line, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
36
37
|
x1={startPoint.x}
|
|
37
38
|
y1={startPoint.y}
|
|
38
39
|
x2={endPoint.x}
|
package/src/undo-redo.jsx
CHANGED
|
@@ -40,7 +40,6 @@ export class UndoRedo extends React.Component {
|
|
|
40
40
|
const styles = (theme) => ({
|
|
41
41
|
button: {
|
|
42
42
|
color: color.text(),
|
|
43
|
-
backgroundColor: color.background(),
|
|
44
43
|
marginBottom: theme.spacing.unit / 2,
|
|
45
44
|
'&:not(:last-of-type)': {
|
|
46
45
|
marginRight: theme.spacing.unit / 2,
|
package/src/utils.js
CHANGED
|
@@ -203,7 +203,7 @@ export const isDuplicatedMark = (mark, marks, oldMark) => {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
const duplicated = filteredMarks.find((m) => {
|
|
206
|
-
if (type === 'circle' || type === 'parabola' || type === 'sine') {
|
|
206
|
+
if (type === 'circle' || type === 'parabola' || type === 'sine' || type === 'absolute' || type === 'exponential') {
|
|
207
207
|
const { root, edge } = mark;
|
|
208
208
|
|
|
209
209
|
return (equalPoints(root, m.root) && equalPoints(edge, m.edge)) || (type === 'circle' && isSameCircle(m, mark));
|
package/legacy.png
DELETED
|
Binary file
|